OSX Sierra Tensorflow build error: ld: file not found: @rpath/CUDA.framework/Versions/A/CUDA

社会主义新天地 提交于 2020-01-17 07:08:05

问题


I have followed the instruction in: https://gist.github.com/notilas/a30e29ce514970e821a34153c1e78b3f

But cannot complete it.

  • OSX: Sierra
  • Tensorflow version 1.1.0 (Google says v1.2 does not support OSX CUDA)
  • CUDA Tool kit : 8.0
  • CUDNN : 6.0
  • Xcode : 7.2.1
  • Anaconda : 4.2 (Python version 3.5)

Error Log:

ERROR: /Users/so041e/ml/tensorflow/tensorflow/python/BUILD:2534:1: Linking of rule '//tensorflow/python:_pywrap_tensorflow_internal.so' failed: link_dynamic_library.sh failed: error executing command external/bazel_tools/tools/cpp/link_dynamic_library.sh no ignored ignored ignored external/local_config_cuda/crosstool/clang/bin/crosstool_wrapper_driver_is_not_gcc -shared -o ... (remaining 455 argument(s) skipped): com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 1. clang: warning: argument unused during compilation: '-pthread' ld: file not found: @rpath/CUDA.framework/Versions/A/CUDA for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) Target //tensorflow/tools/pip_package:build_pip_package failed to build Use --verbose_failures to see the command lines of failed build steps.

[.bash_profile]

export PATH="/Users/so041e/anaconda/bin:$PATH"
export CUDA_HOME=/usr/local/cuda
export HOME=/Users/so041e
export PATH="$CUDA_HOME/bin:$PATH"
export DYLD_LIBRARY_PATH="/usr/local/cuda/lib:/Developer/NVIDIA/CUDA8.0/lib":$DYLD_LIBRARY_PATH
export LD_LIBRARY_PATH=$DYLD_LIBRARY_PATH
export PATH=$DYLD_LIBRARY_PATH:$PATH
export PATH="//anaconda/bin:$PATH"                                                                                       

Moved CUDNN lib and include to /user/local/cuda

sudo mv -v cuda/lib/libcudnn* /usr/local/cuda/lib
sudo mv -v cuda/include/cudnn.h /usr/local/cuda/include

Didn't use "vent" Just used single python 3.5 at this moment. Tried both, but no difference.

bazel build --config=cuda --config=opt --action_env PATH --action_env LD_LIBRARY_PATH --action_env DYLD_LIBRARY_PATH //tensorflow/tools/pip_package:build_pip_package
bazel build --config=cuda //tensorflow/tools/pip_package:build_pip_package

回答1:


This might be a bit late, but I had this exact same problem and I managed to fix it.

First, @rpath/CUDA.framework/Versions/A/CUDA is a dynamic library install name for libcuda.dylib, which is found in /usr/local/cuda/lib. So do

otool -l /usr/local/cuda/lib/libcuda.dylib

Check where you see @rpath/CUDA.framework/Versions/A/CUDA; on my system it was in the command LC_REEXPORT_DYLIB. From here, it seems dyld doesn't resolve the @rpath for the LC_REEXPORT_DYLIB command, only LC_LOAD*_DYLIB commands. Meaning, it looks for the literal path "@rpath/CUDA.framework/Versions/A/CUDA". So you're going to have to change that by doing

sudo install_name_tool -change @rpath/CUDA.framework/Versions/A/CUDA \ 
    /Library/Frameworks/CUDA.framework/Versions/A/CUDA \
    /usr/local/cuda/lib/libcuda.dylib

This should resolve your problem.

Now why your system (and mine) has this install name for libcuda.dylib? I have absolutely no clue.



来源:https://stackoverflow.com/questions/44714830/osx-sierra-tensorflow-build-error-ld-file-not-found-rpath-cuda-framework-ver

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!