当前位置: 首页 > 知识库问答 >
问题:

在带有bazel的windows上使用cuda支持构建tenorflow错误

靳高明
2023-03-14

我正试图通过bazel在Windows 10 64位上编译支持CUDA的TensorFlow。我的系统是这样设置的:

  • Windows 10 64bit
  • 具有CUDA功能6.1的Nvidia GeForce 1050
  • CUDA Toolkit v8.0-

我还设置了以下环境变量:

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具备其网站所需的所有步骤(https://docs.bazel.build/versions/master/install-windows.html)

MSYS2设置了其网站(http://www.msys2.org/)所需的所有步骤

我设法完成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

之后,我使用以下命令设置了一些其他环境变量:

set BUILD_OPTS='--cpu=x64_windows_msvc --host_cpu=x64_windows_msvc --copt=/w --verbose_failures --experimental_ui --config=cuda'

为了防止这个错误

$ 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

然后我使用以下命令开始bazel构建

bazel build -c opt $BUILD_OPTS //tensorflow/tools/pip_package:build_pip_package

这是问题开始的地方。这是指向完整日志的链接。

知道为什么吗?

共有1个答案

乌俊健
2023-03-14

日志的重要部分是:

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_平台。cc(48)有strcmp

编译器抱怨strcasecmp,因此必须对#define'ingstrcmp进行strcasecmp。不管是什么情况,你能在--verbose_失败的情况下运行构建吗?这将显示Bazel正在执行的命令。这可能暗示了正在发生的事情。

此外,我在你的环境中也看到了这一点:

BAZEL_VC=C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC
BAZEL_VS=C:/Program Files (x86)/Microsoft Visual Studio 14.0

您只需要设置其中一个。我建议保留BAZEL_VC,因为它指向一个更新的编译器。我承认我不知道定义两个环境时会发生什么,Bazel是否更喜欢其中一个。但我知道只定义其中一个就可以了。

 类似资料:
  • Im使用CMake生成visual studio 2013解决方案。下一步我将尝试构建它,但出现以下错误: 构建NVCC(设备)对象模块/核心/CMakeFiles/cuda_compile.dir/src/cuda/Debug/cuda_compile_generated_gpu_mat.cu.obj nvcc致命:不支持的gpu体系结构“compute_11” 我尝试版本2.10和3.0与cu

  • 我目前正在按照这里的说明使用bazel从源代码构建tenorflow。 设置配置并尝试构建配置后,出现以下错误: Cuda配置错误:将C:/Program Files/NVIDIA GPU Computing读取到olkit/Cuda/v9时出错。0/include/cudnn。h:爪哇。伊奥。IOException:错误:src/main/native/win-dows/processes jn

  • 我正在尝试在windows 10上安装tensorflow,并遵循以下链接:https://www.tensorflow.org/install/install_sources 我已经成功安装了bazel。问题是当我使用这个命令时 要安装tensorflow,msys显示以下错误。 错误:C:/compiler/tensorflow/tensorflow/python/BUILD:4855:1:没

  • 我的苹果笔记本电脑专业版没有英伟达图形处理器。所以不可能运行CUDA。我想知道TensorFlow的早期版本中哪些支持苹果操作系统的图形处理器?我如何在Anaconda上安装?

  • 我能够在Ubuntu18.04和Bazel以及openJDK 10.0.1上成功地构建并使用TensorFlow,但是当我尝试构建TensorFlow Java库时,我遇到了以下错误: 错误:缺少输入文件“@local_jdk/:jre/lib/resources”。jar' 错误:/home/kim/tensorflow/tensorflow/java/BUILD:20:1: ///tensor

  • 我目前正在移植一个Android应用程序到codename one。对于新的应用程序,这是一个在iOS、Android和Windows Phone上工作的要求。在默认的codename one数据库类的描述中,它说Windows Phone不被支持,应该只用于“非常大的数据处理”。相反,更便携的存储类别应该用于小型存储。 本机应用程序目前使用几个具有相当困难的查询的SQLite表。我不会说数据量很