[英]error building tensorflow with cuda support on windows with bazel
I'm trying to compile TensorFlow with CUDA support on Windows 10 64bit via bazel. 我正在尝试通过bazel在Windows 10 64bit上编译具有CUDA支持的TensorFlow。 This is how my system is set-up:
这是我的系统设置方式:
C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v8.0
C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v8.0
C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v8.0
C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v8.0
C:\\Users\\eliam\\bazel\\0.7.0
C:\\Users\\eliam\\bazel\\0.7.0
C:\\Users\\eliam\\tensorflow
C:\\Users\\eliam\\tensorflow
I've also already set these environment variables: 我还已经设置了以下环境变量:
BAZEL_PYTHON=C:/Users/eliam/Miniconda3
BAZEL_SH=C:/msys64/usr/bin/bash.exe
BAZEL_VC=C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC
BAZEL_VS=C:/Program Files (x86)/Microsoft Visual Studio 14.0
CUDA_PATH=C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v8.0
CUDA_TOOLKIT_PATH=C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v8.0
LD_LIBRARY_PATH=C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v8.0/lib/x64
PYTHON_BIN_PATH=C:/Users/eliam/Miniconda3/python.exe
PYTHON_PATH=C:/Users/eliam/Miniconda3/python.exe
PYTHONPATH=C:/Users/eliam/Miniconda3/python.exe
PYTHON_LIB_PATH=C:/Users/eliam/Miniconda3/lib/site-packages
PATH=C:\Users\eliam\bazel\0.7.0;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\bin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\lib\x64;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\include;%PATH%
Bazel is set up with all the steps required by its website ( https://docs.bazel.build/versions/master/install-windows.html ) 已设置Bazel网站所需的所有步骤( https://docs.bazel.build/versions/master/install-windows.html )
MSYS2 is set up with all the steps required by its website ( http://www.msys2.org/ ) 通过其网站( http://www.msys2.org/ )设置MSYS2所需的所有步骤。
I manage to complete the configure.py without issues. 我设法完成configure.py没有问题。
python ./configure.py
You have bazel 0.7.0 installed.
Do you wish to build TensorFlow with XLA JIT support? [y/N]:
No XLA JIT support will be enabled for TensorFlow.
Do you wish to build TensorFlow with GDR support? [y/N]:
No GDR support will be enabled for TensorFlow.
Do you wish to build TensorFlow with VERBS support? [y/N]:
No VERBS support will be enabled for TensorFlow.
Do you wish to build TensorFlow with CUDA support? [y/N]: y
CUDA support will be enabled for TensorFlow.
Please specify the CUDA SDK version you want to use, e.g. 7.0. [Leave empty to default to CUDA 8.0]:
Please specify the cuDNN version you want to use. [Leave empty to default to cuDNN 6.0]:
Please specify the location where cuDNN 6 library is installed. Refer to README.md for more details. [Default is C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v8.0]:
Please specify a list of comma-separated Cuda compute capabilities you want to build with.
You can find the compute capability of your device at: https://developer.nvidia.com/cuda-gpus.
Please note that each additional compute capability significantly increases your build time and binary size. [Default is: 3.5,5.2]
Do you wish to build TensorFlow with MPI support? [y/N]:
No MPI support will be enabled for TensorFlow.
Please specify optimization flags to use during compilation when bazel option "--config=opt" is specified [Default is -march=native]:
Add "--config=mkl" to your bazel command to build with MKL support.
Please note that MKL on MacOS or windows is still not supported.
If you would like to use a local MKL instead of downloading, please set the environment variable "TF_MKL_ROOT" every time before build.
Configuration finished
After that I set some other environment variables with the following command: 之后,我使用以下命令设置其他一些环境变量:
set BUILD_OPTS='--cpu=x64_windows_msvc --host_cpu=x64_windows_msvc --copt=/w --verbose_failures --experimental_ui --config=cuda'
In order to prevent this error 为了防止这个错误
$ bazel build -c opt --config=cuda --verbose_failures --subcommands //tensorflow/cc:tutorials_example_trainer
..............
WARNING: The lower priority option '-c opt' does not override the previous value '-c opt'.
____Loading package: tensorflow/cc
____Loading package: @local_config_cuda//crosstool
____Loading package: @local_config_xcode//
ERROR: No toolchain found for cpu 'x64_windows'. Valid cpus are: [
k8,
piii,
arm,
darwin,
ppc,
].
____Elapsed time: 10.196s
Then I start bazel build, using the following command 然后,使用以下命令开始构建bazel
bazel build -c opt $BUILD_OPTS //tensorflow/tools/pip_package:build_pip_package
This is where the problems begin. 这是问题开始的地方。 This is a link to the complete log.
这是完整日志的链接 。
Any idea why? 知道为什么吗?
The important part of the log is this: 日志的重要部分是:
ERROR: C:/msys64/home/eliam/tensorflow/tensorflow/stream_executor/BUILD:52:1: C++ compilation of rule '//tensorflow/stream_executor:cuda_platform' failed (Exit 2).
tensorflow/stream_executor/cuda/cuda_platform.cc(48): error C3861: 'strcasecmp': identifier not found
tensorflow/stream_executor/cuda/cuda_platform.cc(50): error C3861: 'strcasecmp': identifier not found
tensorflow/stream_executor/cuda/cuda_platform.cc(52): error C3861: 'strcasecmp': identifier not found
Target //tensorflow/cc:tutorials_example_trainer failed to build
tensorflow/stream_executor/cuda/cuda_platform.cc(48) has strcmp
in it. tensorflow / stream_executor / cuda / cuda_platform.cc(48)中包含
strcmp
。
The compiler complains about strcasecmp
, therefore something must be #define
'ing strcmp
to strcasecmp
. 编译器抱怨
strcasecmp
,因此必须有所#define
“荷兰国际集团strcmp
到strcasecmp
。 Whatever the case, could you run the build with --verbose_failures
? 无论如何,您是否可以使用
--verbose_failures
运行构建? That'll show the command Bazel was executing. 这将显示Bazel正在执行的命令。 That may hint on what's happening.
这可能暗示正在发生的事情。
Also, I see this in your envvars: 另外,我在您的envvars中看到了这一点:
BAZEL_VC=C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC
BAZEL_VS=C:/Program Files (x86)/Microsoft Visual Studio 14.0
You only need to set one of these. 您只需设置其中之一。 I recommend keeping
BAZEL_VC
since that points to a newer compiler. 我建议保留
BAZEL_VC
因为它指向更新的编译器。 I admit I don't know what happens when both envvars are defined, whether Bazel prefers one to the other. 我承认我不知道定义了两个envvar时会发生什么,Bazel是否更喜欢一个。 But I do know it works fine with just one of them defined.
但是我知道只定义其中之一就可以正常工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.