3
3
4
4
`cuda_configure` depends on the following environment variables:
5
5
6
- * `ENABLE_CUDA `: Whether to enable building with CUDA.
7
- * `CC `: The GCC host compiler path
6
+ * `TF_NEED_CUDA `: Whether to enable building with CUDA.
7
+ * `GCC_HOST_COMPILER_PATH `: The GCC host compiler path
8
8
* `CUDA_TOOLKIT_PATH`: The path to the CUDA toolkit. Default is
9
9
`/usr/local/cuda`.
10
- * `CUDA_VERSION `: The version of the CUDA toolkit. If this is blank, then
10
+ * `TF_CUDA_VERSION `: The version of the CUDA toolkit. If this is blank, then
11
11
use the system default.
12
- * `CUDNN_VERSION `: The version of the cuDNN library.
12
+ * `TF_CUDNN_VERSION `: The version of the cuDNN library.
13
13
* `CUDNN_INSTALL_PATH`: The path to the cuDNN library. Default is
14
14
`/usr/local/cuda`.
15
- * `CUDA_COMPUTE_CAPABILITIES `: The CUDA compute capabilities. Default is
15
+ * `TF_CUDA_COMPUTE_CAPABILITIES `: The CUDA compute capabilities. Default is
16
16
`3.5,5.2`.
17
17
"""
18
18
19
+ _GCC_HOST_COMPILER_PATH = "GCC_HOST_COMPILER_PATH"
20
+ _CUDA_TOOLKIT_PATH = "CUDA_TOOLKIT_PATH"
21
+ _TF_CUDA_VERSION = "TF_CUDA_VERSION"
22
+ _TF_CUDNN_VERSION = "TF_CUDNN_VERSION"
23
+ _CUDNN_INSTALL_PATH = "CUDNN_INSTALL_PATH"
24
+ _TF_CUDA_COMPUTE_CAPABILITIES = "TF_CUDA_COMPUTE_CAPABILITIES"
19
25
20
26
_DEFAULT_CUDA_VERSION = ""
21
27
_DEFAULT_CUDNN_VERSION = ""
@@ -30,8 +36,8 @@ _DEFAULT_CUDA_COMPUTE_CAPABILITIES = ["3.5", "5.2"]
30
36
def find_cc (repository_ctx ):
31
37
"""Find the C++ compiler."""
32
38
cc_name = "gcc"
33
- if "CC" in repository_ctx .os .environ :
34
- cc_name = repository_ctx .os .environ ["CC" ].strip ()
39
+ if _GCC_HOST_COMPILER_PATH in repository_ctx .os .environ :
40
+ cc_name = repository_ctx .os .environ [_GCC_HOST_COMPILER_PATH ].strip ()
35
41
if not cc_name :
36
42
cc_name = "gcc"
37
43
if cc_name .startswith ("/" ):
@@ -93,8 +99,8 @@ def _enable_cuda(repository_ctx):
93
99
def _cuda_toolkit_path (repository_ctx ):
94
100
"""Finds the cuda toolkit directory."""
95
101
cuda_toolkit_path = _DEFAULT_CUDA_TOOLKIT_PATH
96
- if "CUDA_TOOLKIT_PATH" in repository_ctx .os .environ :
97
- cuda_toolkit_path = repository_ctx .os .environ ["CUDA_TOOLKIT_PATH" ].strip ()
102
+ if _CUDA_TOOLKIT_PATH in repository_ctx .os .environ :
103
+ cuda_toolkit_path = repository_ctx .os .environ [_CUDA_TOOLKIT_PATH ].strip ()
98
104
if not repository_ctx .path (cuda_toolkit_path ).exists :
99
105
fail ("Cannot find cuda toolkit path." )
100
106
return cuda_toolkit_path
@@ -103,34 +109,34 @@ def _cuda_toolkit_path(repository_ctx):
103
109
def _cudnn_install_basedir (repository_ctx ):
104
110
"""Finds the cudnn install directory."""
105
111
cudnn_install_path = _DEFAULT_CUDNN_INSTALL_PATH
106
- if "CUDNN_INSTALL_PATH" in repository_ctx .os .environ :
107
- cudnn_install_path = repository_ctx .os .environ ["CUDNN_INSTALL_PATH" ].strip ()
112
+ if _CUDNN_INSTALL_PATH in repository_ctx .os .environ :
113
+ cudnn_install_path = repository_ctx .os .environ [_CUDNN_INSTALL_PATH ].strip ()
108
114
if not repository_ctx .path (cudnn_install_path ).exists :
109
115
fail ("Cannot find cudnn install path." )
110
116
return cudnn_install_path
111
117
112
118
113
119
def _cuda_version (repository_ctx ):
114
120
"""Detects the cuda version."""
115
- if "CUDA_VERSION" in repository_ctx .os .environ :
116
- return repository_ctx .os .environ ["CUDA_VERSION" ].strip ()
121
+ if _TF_CUDA_VERSION in repository_ctx .os .environ :
122
+ return repository_ctx .os .environ [_TF_CUDA_VERSION ].strip ()
117
123
else :
118
124
return ""
119
125
120
126
121
127
def _cudnn_version (repository_ctx ):
122
128
"""Detects the cudnn version."""
123
- if "CUDNN_VERSION" in repository_ctx .os .environ :
124
- return repository_ctx .os .environ ["CUDNN_VERSION" ].strip ()
129
+ if _TF_CUDNN_VERSION in repository_ctx .os .environ :
130
+ return repository_ctx .os .environ [_TF_CUDNN_VERSION ].strip ()
125
131
else :
126
132
return ""
127
133
128
134
129
135
def _compute_capabilities (repository_ctx ):
130
136
"""Returns a list of strings representing cuda compute capabilities."""
131
- if "CUDA_COMPUTE_CAPABILITIES" not in repository_ctx .os .environ :
137
+ if _TF_CUDA_COMPUTE_CAPABILITIES not in repository_ctx .os .environ :
132
138
return _DEFAULT_CUDA_COMPUTE_CAPABILITIES
133
- capabilities_str = repository_ctx .os .environ ["CUDA_COMPUTE_CAPABILITIES" ]
139
+ capabilities_str = repository_ctx .os .environ [_TF_CUDA_COMPUTE_CAPABILITIES ]
134
140
capabilities = capabilities_str .split ("," )
135
141
for capability in capabilities :
136
142
# Workaround for Skylark's lack of support for regex. This check should
0 commit comments