【问题标题】:Bazel build error with Cuda on Windows 10, how resolve it?Bazel 在 Windows 10 上使用 Cuda 构建错误,如何解决?
【发布时间】:2021-02-15 10:01:03
【问题描述】:

我正在尝试通过 Bazel 在 Windows 10 64bit 上通过以下指令编译一个具有 CUDA 支持(GeForce3090 需要 cc 8.6)的 Tensorflow 核心:https://www.tensorflow.org/install/source_windows

我使用这个构建字符串: bazel build --config=opt --config=cuda --define=no_tensorflow_py_deps=true //tensorflow/tools/pip_package:build_pip_package

我得到错误,如下所示:

我该如何解决这个问题?

谢谢。

  > D:\Python\tensorflow>bazel build --config=opt --config=cuda
    > --define=no_tensorflow_py_deps=true //tensorflow/tools/pip_package:build_pip_package Extracting Bazel
    > installation... WARNING: Ignoring JAVA_HOME, because it must point to
    > a JDK, not a JRE. Starting local Bazel server and connecting to it...
    > WARNING: The following configs were expanded more than once: [cuda,
    > using_cuda]. For repeatable flags, repeats are counted twice and may
    > lead to unexpected behavior. INFO: Options provided by the client:  
    > Inherited 'common' options: --isatty=1 --terminal_columns=237 INFO:
    > Reading rc options for 'build' from d:\python\tensorflow\.bazelrc:  
    > Inherited 'common' options: --experimental_repo_remote_exec INFO:
    > Options provided by the client:   'build' options:
    > --python_path=C:/Program Files/Python37/python.exe INFO: Reading rc options for 'build' from d:\python\tensorflow\.bazelrc:   'build'
    > options: --apple_platform_type=macos --define
    > framework_shared_object=true --define open_source_build=true
    > --java_toolchain=//third_party/toolchains/java:tf_java_toolchain --host_java_toolchain=//third_party/toolchains/java:tf_java_toolchain --define=tensorflow_enable_mlir_generated_gpu_kernels=0 --define=use_fast_cpp_protos=true --define=allow_oversize_protos=true --spawn_strategy=standalone -c opt --announce_rc --define=grpc_no_ares=true --noincompatible_remove_legacy_whole_archive --noincompatible_prohibit_aapt1 --enable_platform_specific_config --config=short_logs --config=v2 INFO: Reading rc options for 'build' from d:\python\tensorflow\.tf_configure.bazelrc:   'build' options:
    > --action_env PYTHON_BIN_PATH=C:/Program Files/Python37/python.exe --action_env PYTHON_LIB_PATH=C:/Program Files/Python37/lib/site-packages --python_path=C:/Program
    > Files/Python37/python.exe --config=xla --action_env
    > CUDA_TOOLKIT_PATH=C:/Program Files/NVIDIA GPU Computing
    > Toolkit/CUDA/v11.1 --action_env TF_CUDA_COMPUTE_CAPABILITIES=5.2,8.6
    > --config=cuda --action_env TF_CONFIGURE_IOS=0 INFO: Found applicable config definition build:short_logs in file
    > d:\python\tensorflow\.bazelrc: --output_filter=DONT_MATCH_ANYTHING
    > INFO: Found applicable config definition build:v2 in file
    > d:\python\tensorflow\.bazelrc: --define=tf_api_version=2
    > --action_env=TF2_BEHAVIOR=1 INFO: Found applicable config definition build:xla in file d:\python\tensorflow\.bazelrc:
    > --define=with_xla_support=true INFO: Found applicable config definition build:cuda in file d:\python\tensorflow\.bazelrc:
    > --config=using_cuda --define=using_cuda_nvcc=true INFO: Found applicable config definition build:using_cuda in file
    > d:\python\tensorflow\.bazelrc: --define=using_cuda=true --action_env
    > TF_NEED_CUDA=1 --crosstool_top=@local_config_cuda//crosstool:toolchain
    > --define=tensorflow_enable_mlir_generated_gpu_kernels=1 INFO: Found applicable config definition build:opt in file
    > d:\python\tensorflow\.tf_configure.bazelrc: --copt=/arch:SSE4.2
    > --define with_default_optimizations=true INFO: Found applicable config definition build:cuda in file d:\python\tensorflow\.bazelrc:
    > --config=using_cuda --define=using_cuda_nvcc=true INFO: Found applicable config definition build:using_cuda in file
    > d:\python\tensorflow\.bazelrc: --define=using_cuda=true --action_env
    > TF_NEED_CUDA=1 --crosstool_top=@local_config_cuda//crosstool:toolchain
    > --define=tensorflow_enable_mlir_generated_gpu_kernels=1 INFO: Found applicable config definition build:windows in file
    > d:\python\tensorflow\.bazelrc: --copt=/W0 --copt=/D_USE_MATH_DEFINES
    > --host_copt=/D_USE_MATH_DEFINES --cxxopt=/std:c++14 --host_cxxopt=/std:c++14 --config=monolithic --copt=-DWIN32_LEAN_AND_MEAN --host_copt=-DWIN32_LEAN_AND_MEAN --copt=-DNOGDI --host_copt=-DNOGDI --copt=/experimental:preprocessor --host_copt=/experimental:preprocessor --linkopt=/DEBUG --host_linkopt=/DEBUG --linkopt=/OPT:REF --host_linkopt=/OPT:REF --linkopt=/OPT:ICF --host_linkopt=/OPT:ICF --experimental_strict_action_env=true --verbose_failures --distinct_host_configuration=false INFO: Found applicable config definition build:monolithic in file d:\python\tensorflow\.bazelrc:
    > --define framework_shared_object=false DEBUG: Rule 'io_bazel_rules_go' indicated that a canonical reproducible form can be obtained by
    > modifying arguments shallow_since = "1557349968 -0400" DEBUG:
    > Repository io_bazel_rules_go instantiated at:   no stack
    > (--record_rule_instantiation_callstack not enabled) Repository rule
    > git_repository defined at:  
    > C:/users/vladimir/_bazel_vladimir/sd7zocps/external/bazel_tools/tools/build_defs/repo/git.bzl:195:33:
    > in <toplevel> INFO: Repository local_config_cuda instantiated at:   no
    > stack (--record_rule_instantiation_callstack not enabled) Repository
    > rule cuda_configure defined at:  
    > D:/python/tensorflow/third_party/gpus/cuda_configure.bzl:1418:33: in
    > <toplevel> 

------------------------------------------------------------------------
**ERROR: An error occurred during the fetch of repository
    > 'local_config_cuda':**    Traceback (most recent call last):
    >         File "D:/python/tensorflow/third_party/gpus/cuda_configure.bzl", line 1388
    >                 _create_local_cuda_repository(<1 more arguments>)
    >         File "D:/python/tensorflow/third_party/gpus/cuda_configure.bzl", line 1064,
    > in _create_local_cuda_repository
    >                 _find_libs(repository_ctx, <2 more arguments>)
    >         File "D:/python/tensorflow/third_party/gpus/cuda_configure.bzl", line 599,
    > in _find_libs
    >                 _check_cuda_libs(repository_ctx, <2 more arguments>)
    >         File "D:/python/tensorflow/third_party/gpus/cuda_configure.bzl", line 501,
    > in _check_cuda_libs
    >                 execute(repository_ctx, <1 more arguments>)***
    >         File "D:/python/tensorflow/third_party/remote_config/common.bzl", line 217,
    > in execute
    >                 fail(<1 more arguments>) Repository command failed "C:/Program" is not an internal or external command, executable
    > program, or batch file. 

---------------------------------------------------------------------------

ERROR: Skipping
    > '//tensorflow/tools/pip_package:build_pip_package': no such package
    > '@local_config_cuda//cuda': Traceback (most recent call last):
    >         File "D:/python/tensorflow/third_party/gpus/cuda_configure.bzl", line 1388
    >                 _create_local_cuda_repository(<1 more arguments>)
    >         File "D:/python/tensorflow/third_party/gpus/cuda_configure.bzl", line 1064,
    > in _create_local_cuda_repository
    >                 _find_libs(repository_ctx, <2 more arguments>)
    >         File "D:/python/tensorflow/third_party/gpus/cuda_configure.bzl", line 599,
    > in _find_libs
    >                 _check_cuda_libs(repository_ctx, <2 more arguments>)
    >         File "D:/python/tensorflow/third_party/gpus/cuda_configure.bzl", line 501,
    > in _check_cuda_libs
    >                 execute(repository_ctx, <1 more arguments>)
    >         File "D:/python/tensorflow/third_party/remote_config/common.bzl", line 217,
    > in execute
    >                 fail(<1 more arguments>) Repository command failed "C:/Program" is not an internal or external command, executable
    > program, or batch file. WARNING: Target pattern parsing failed. ERROR:
    > no such package '@local_config_cuda//cuda': Traceback (most recent
    > call last):
    >         File "D:/python/tensorflow/third_party/gpus/cuda_configure.bzl", line 1388
    >                 _create_local_cuda_repository(<1 more arguments>)
    >         File "D:/python/tensorflow/third_party/gpus/cuda_configure.bzl", line 1064,
    > in _create_local_cuda_repository
    >                 _find_libs(repository_ctx, <2 more arguments>)
    >         File "D:/python/tensorflow/third_party/gpus/cuda_configure.bzl", line 599,
    > in _find_libs
    >                 _check_cuda_libs(repository_ctx, <2 more arguments>)
    >         File "D:/python/tensorflow/third_party/gpus/cuda_configure.bzl", line 501,
    > in _check_cuda_libs
    >                 execute(repository_ctx, <1 more arguments>)
    >         File "D:/python/tensorflow/third_party/remote_config/common.bzl", line 217,
    > in execute
    >                 fail(<1 more arguments>) Repository command failed "C:/Program" is not an internal or external command, executable
    > program, or batch file. INFO: Elapsed time: 47.934s INFO: 0 processes.
    > FAILED: Build did NOT complete successfully (0 packages loaded)
    >     currently loading: tensorflow/tools/pip_package

【问题讨论】:

  • 在windows上,当你有一个带有空格的路径时,你经常需要在它周围加上引号“...”。我不确定是哪一个导致了这里的问题,但这里有几个例子:PYTHON_BIN_PATH=C:/Program Files/Python37/python.exeCUDA_TOOLKIT_PATH=C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.1。尝试在您的构建规范中找到每个类似的示例并正确使用引号。
  • 它的文件 ".tf_configur"e 以 avtomatically 的形式出现: build --action_env PYTHON_BIN_PATH="C:/Program Files/Python37/python.exe" build --action_env PYTHON_LIB_PATH="C:/Program Files /Python37/lib/site-packages" build --python_path="C:/Program Files/Python37/python.exe" build --config=xla build --action_env CUDA_TOOLKIT_PATH="C:/Program Files/NVIDIA GPU 计算工具包/CUDA/v11.1" build --action_env TF_CUDA_COMPUTE_CAPABILITIES="5.2,8.6" .... 有引号

标签: tensorflow bazel


【解决方案1】:

总结: 我通过以下步骤解决了这个问题:

  1. 将 Python 从 C:\Program Files\Python... 移动到 C:\Python... 在我们需要更改 PATH 变量中的对应字符串之后 2)检查并删除另一个 bash 安装,除了 msys64,检查:passway C:\msys64\usr\bin 是否存在于您的 PATH 变量中

【讨论】:

    猜你喜欢
    • 2019-01-03
    • 1970-01-01
    • 2022-11-11
    • 1970-01-01
    • 1970-01-01
    • 2016-04-04
    • 2019-05-19
    • 1970-01-01
    相关资源
    最近更新 更多