Skip to content

Commit 761e6de

Browse files
author
Vijay Vasudevan
authored
Cherry-pick into r0.10 cuda configure fix and gif.BUILD missing headers (tensorflow#4041)
* Add missing headers to gif BUILD definition. % :.../gif/giflib-5.1.4/lib$ ls dgif_lib.c gif_err.c gif_hash.h Makefile.am openbsd-reallocarray.c egif_lib.c gif_font.c gif_lib.h Makefile.in quantize.c gifalloc.c gif_hash.c gif_lib_private.h Makefile.unx Change: 131121931 * cuda_configure: Use env variables that match those used in configure script. (tensorflow#4034) Issue tensorflow#4002
1 parent 5d3492d commit 761e6de

File tree

4 files changed

+36
-24
lines changed

4 files changed

+36
-24
lines changed

configure

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ while true; do
9898
fi
9999
fi
100100
if [ -e "$GCC_HOST_COMPILER_PATH" ]; then
101-
export CC=$GCC_HOST_COMPILER_PATH
101+
export GCC_HOST_COMPILER_PATH
102102
break
103103
fi
104104
echo "Invalid gcc path. ${GCC_HOST_COMPILER_PATH} cannot be found" 1>&2
@@ -142,7 +142,7 @@ while true; do
142142

143143
if [ -e "${CUDA_TOOLKIT_PATH}/${CUDA_RT_LIB_PATH}" ]; then
144144
export CUDA_TOOLKIT_PATH
145-
export CUDA_VERSION=$TF_CUDA_VERSION
145+
export TF_CUDA_VERSION
146146
break
147147
fi
148148
echo "Invalid path to CUDA $TF_CUDA_VERSION toolkit. ${CUDA_TOOLKIT_PATH}/${CUDA_RT_LIB_PATH} cannot be found"
@@ -203,15 +203,15 @@ while true; do
203203
fi
204204

205205
if [ -e "$CUDNN_INSTALL_PATH/${CUDA_DNN_LIB_ALT_PATH}" -o -e "$CUDNN_INSTALL_PATH/${CUDA_DNN_LIB_PATH}" ]; then
206-
export CUDNN_VERSION=$TF_CUDNN_VERSION
206+
export TF_CUDNN_VERSION
207207
export CUDNN_INSTALL_PATH
208208
break
209209
fi
210210

211211
if [ "$OSNAME" == "Linux" ]; then
212212
CUDNN_PATH_FROM_LDCONFIG="$(ldconfig -p | sed -n 's/.*libcudnn.so .* => \(.*\)/\1/p')"
213213
if [ -e "${CUDNN_PATH_FROM_LDCONFIG}${TF_CUDNN_EXT}" ]; then
214-
export CUDNN_VERSION=$TF_CUDNN_VERSION
214+
export TF_CUDNN_VERSION
215215
export CUDNN_INSTALL_PATH="$(dirname ${CUDNN_PATH_FROM_LDCONFIG})"
216216
break
217217
fi
@@ -263,7 +263,7 @@ EOF
263263
exit 1
264264
fi
265265
else
266-
export CUDA_COMPUTE_CAPABILITIES=$TF_CUDA_COMPUTE_CAPABILITIES
266+
export TF_CUDA_COMPUTE_CAPABILITIES
267267
break
268268
fi
269269
TF_CUDA_COMPUTE_CAPABILITIES=""

gif.BUILD

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,18 @@ SOURCES = [
99
"quantize.c",
1010
]
1111

12+
HEADERS = [
13+
"gif_hash.h",
14+
"gif_lib.h",
15+
"gif_lib_private.h",
16+
]
17+
1218
prefix_dir = "giflib-5.1.4/lib"
1319

1420
cc_library(
1521
name = "gif",
1622
srcs = [prefix_dir + "/" + source for source in SOURCES],
17-
hdrs = [prefix_dir + "/gif_lib.h"],
23+
hdrs = [prefix_dir + "/" + hdrs for hdrs in HEADERS],
1824
includes = [prefix_dir],
1925
defines = [
2026
"HAVE_CONFIG_H",

tensorflow/tools/ci_build/Dockerfile.gpu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ ENV LD_LIBRARY_PATH /usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64
2424
ENV CUDA_TOOLKIT_PATH /usr/local/cuda
2525
ENV CUDNN_INSTALL_PATH /usr/lib/x86_64-linux-gnu
2626
ENV TF_NEED_CUDA 1
27-
ENV CUDA_COMPUTE_CAPABILITIES 3.0,5.2
27+
ENV TF_CUDA_COMPUTE_CAPABILITIES 3.0,5.2

third_party/gpus/cuda_configure.bzl

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,25 @@
33
44
`cuda_configure` depends on the following environment variables:
55
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
88
* `CUDA_TOOLKIT_PATH`: The path to the CUDA toolkit. Default is
99
`/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
1111
use the system default.
12-
* `CUDNN_VERSION`: The version of the cuDNN library.
12+
* `TF_CUDNN_VERSION`: The version of the cuDNN library.
1313
* `CUDNN_INSTALL_PATH`: The path to the cuDNN library. Default is
1414
`/usr/local/cuda`.
15-
* `CUDA_COMPUTE_CAPABILITIES`: The CUDA compute capabilities. Default is
15+
* `TF_CUDA_COMPUTE_CAPABILITIES`: The CUDA compute capabilities. Default is
1616
`3.5,5.2`.
1717
"""
1818

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"
1925

2026
_DEFAULT_CUDA_VERSION = ""
2127
_DEFAULT_CUDNN_VERSION = ""
@@ -30,8 +36,8 @@ _DEFAULT_CUDA_COMPUTE_CAPABILITIES = ["3.5", "5.2"]
3036
def find_cc(repository_ctx):
3137
"""Find the C++ compiler."""
3238
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()
3541
if not cc_name:
3642
cc_name = "gcc"
3743
if cc_name.startswith("/"):
@@ -93,8 +99,8 @@ def _enable_cuda(repository_ctx):
9399
def _cuda_toolkit_path(repository_ctx):
94100
"""Finds the cuda toolkit directory."""
95101
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()
98104
if not repository_ctx.path(cuda_toolkit_path).exists:
99105
fail("Cannot find cuda toolkit path.")
100106
return cuda_toolkit_path
@@ -103,34 +109,34 @@ def _cuda_toolkit_path(repository_ctx):
103109
def _cudnn_install_basedir(repository_ctx):
104110
"""Finds the cudnn install directory."""
105111
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()
108114
if not repository_ctx.path(cudnn_install_path).exists:
109115
fail("Cannot find cudnn install path.")
110116
return cudnn_install_path
111117

112118

113119
def _cuda_version(repository_ctx):
114120
"""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()
117123
else:
118124
return ""
119125

120126

121127
def _cudnn_version(repository_ctx):
122128
"""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()
125131
else:
126132
return ""
127133

128134

129135
def _compute_capabilities(repository_ctx):
130136
"""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:
132138
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]
134140
capabilities = capabilities_str.split(",")
135141
for capability in capabilities:
136142
# Workaround for Skylark's lack of support for regex. This check should

0 commit comments

Comments
 (0)