未能加载TensorFlow运行时;图书馆不加载:@rpath / libcudnn.5.dylib '

时间:2022-03-25 21:15:38

I've installed Tensorflow into a fresh virtual environment on OSX 10.12: https://www.tensorflow.org/install/install_mac#installing_with_virtualenv

我已经在OSX 10.12上安装了一个新的虚拟环境:https://www.tensorflow.org/install/install_mac#installing_with_virtualenv。

In one attempt I installed both of these in a fresh virtualenv:

在一次尝试中,我将这两种方法都安装在了一个新的virtualenv中:

 $ pip3 install --upgrade tensorflow
 $ pip3 install --upgrade tensorflow-gpu

In another attempt I only installed this in a fresh virtualenv:

在另一次尝试中,我只是把它安装在一个新的虚拟环境中:

 $ pip3 install --upgrade tensorflow-gpu

I think this is the error:

我认为这是错误的:

Library not loaded: @rpath/libcudnn.5.dylib

The installation provided libcudnn.6.dylib but not libcudnn.5.dylib

libcudnn.6提供的安装。dylib但不是libcudnn.5.dylib

I believe my question is distinct from these two

我认为我的问题与这两个截然不同。

Failed to load the native TensorFlow runtime. Reason : Image not found. What am I doing wrong?

未能加载本机TensorFlow运行时。原因:图像未找到。我做错了什么?

Tensorflow error [image not found]

张量误差[图像未找到]

as their errors involve libcudart:

因为他们的错误涉及到libcudart:

 Library not loaded: @rpath/libcudart.8.0.dylib

Trace:

跟踪:

(tensorflow) Dione:tensorflow peterbecich$ python3
Python 3.4.6 (default, Apr 23 2017, 17:16:17) 
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
>>> Traceback (most recent call last):
  File "/Users/peterbecich/tensorflow/lib/python3.4/site-packages/tensorflow/python/pywrap_tensorflow.py", line 41, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "/Users/peterbecich/tensorflow/lib/python3.4/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "/Users/peterbecich/tensorflow/lib/python3.4/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
  File "/Users/peterbecich/tensorflow/lib/python3.4/imp.py", line 243, in load_module
    return load_dynamic(name, filename, file)
ImportError: dlopen(/Users/peterbecich/tensorflow/lib/python3.4/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so, 10): Library not loaded: @rpath/libcudnn.5.dylib
  Referenced from: /Users/peterbecich/tensorflow/lib/python3.4/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so
  Reason: image not found

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/peterbecich/tensorflow/lib/python3.4/site-packages/tensorflow/__init__.py", line 24, in <module>
    from tensorflow.python import *
  File "/Users/peterbecich/tensorflow/lib/python3.4/site-packages/tensorflow/python/__init__.py", line 51, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "/Users/peterbecich/tensorflow/lib/python3.4/site-packages/tensorflow/python/pywrap_tensorflow.py", line 52, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "/Users/peterbecich/tensorflow/lib/python3.4/site-packages/tensorflow/python/pywrap_tensorflow.py", line 41, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "/Users/peterbecich/tensorflow/lib/python3.4/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "/Users/peterbecich/tensorflow/lib/python3.4/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
  File "/Users/peterbecich/tensorflow/lib/python3.4/imp.py", line 243, in load_module
    return load_dynamic(name, filename, file)
ImportError: dlopen(/Users/peterbecich/tensorflow/lib/python3.4/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so, 10): Library not loaded: @rpath/libcudnn.5.dylib
  Referenced from: /Users/peterbecich/tensorflow/lib/python3.4/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so
  Reason: image not found


Failed to load the native TensorFlow runtime.

Paths set in CUDA setup:

CUDA设置的路径:

(tensorflow) Dione:~ peterbecich$ echo $LD_LIBRARY_PATH 
/usr/local/cuda/lib/:
(tensorflow) Dione:~ peterbecich$ echo $DYLD_LIBRARY_PATH 
/usr/local/cuda/lib:/usr/local/cuda/:/usr/local/cuda/extras/CUPTI/lib

Clang version from outdated Command Line Tools, due to this: https://github.com/caffe2/caffe2/issues/318#issuecomment-295555763

Clang版本来自于过时的命令行工具,这是由于:https://github.com/2/3/318 #发布-295555763。

Dione:~ peterbecich$ clang --version
Apple LLVM version 7.3.0 (clang-703.0.31)
Target: x86_64-apple-darwin16.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

nvcc version:

学校网站版本:

(tensorflow) Dione:~ peterbecich$ nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2016 NVIDIA Corporation
Built on Tue_Jan_10_13:22:46_CST_2017
Cuda compilation tools, release 8.0, V8.0.61

pip in virtual environment:

皮普在虚拟环境:

(tensorflow) Dione:~ peterbecich$ pip3 --version
pip 9.0.1 from /Users/peterbecich/tensorflow/lib/python3.4/site-packages (python 3.4)

libcudnn is a symbolic link in /usr/local/cuda/lib. Interestingly, the missing file is libcudnn.5.dylib and libcudnn.6.dynlib is available:

libcudnn是/usr/local/cuda/lib中的一个符号链接。有趣的是,丢失的文件是libcudnn5。dylib libcudnn.6。dynlib可用:

  /ssh:Dione.local:/usr/local/cuda/lib:
  total 672
  drwxr-xr-x  83 peterbecich  wheel   2.8K May 24 12:32 .
  drwxr-xr-x  17 peterbecich  wheel   578B May 24 11:28 ..
  lrwxr-xr-x   1 root         wheel    50B Jan 11 17:33 libcublas.8.0.dylib -> /Developer/NVIDIA/CUDA-8.0/lib/libcublas.8.0.dylib
  lrwxr-xr-x   1 root         wheel    46B Jan 11 17:33 libcublas.dylib -> /Developer/NVIDIA/CUDA-8.0/lib/libcublas.dylib
  lrwxr-xr-x   1 root         wheel    49B Jan 11 17:33 libcublas_device.a -> /Developer/NVIDIA/CUDA-8.0/lib/libcublas_device.a
  lrwxr-xr-x   1 root         wheel    49B Jan 11 17:33 libcublas_static.a -> /Developer/NVIDIA/CUDA-8.0/lib/libcublas_static.a
  -rwxr-xr-x   1 root         wheel    13K Jan 11 17:31 libcuda.dylib
  lrwxr-xr-x   1 root         wheel    45B Jan 11 17:33 libcudadevrt.a -> /Developer/NVIDIA/CUDA-8.0/lib/libcudadevrt.a
  lrwxr-xr-x   1 root         wheel    50B Jan 11 17:33 libcudart.8.0.dylib -> /Developer/NVIDIA/CUDA-8.0/lib/libcudart.8.0.dylib
  lrwxr-xr-x   1 root         wheel    46B Jan 11 17:33 libcudart.dylib -> /Developer/NVIDIA/CUDA-8.0/lib/libcudart.dylib
  lrwxr-xr-x   1 root         wheel    49B Jan 11 17:33 libcudart_static.a -> /Developer/NVIDIA/CUDA-8.0/lib/libcudart_static.a
  lrwxr-xr-x   1 root         wheel    47B May 24 12:32 libcudnn.6.dylib -> /Developer/NVIDIA/CUDA-8.0/lib/libcudnn.6.dylib
  lrwxr-xr-x   1 root         wheel    45B May 24 12:32 libcudnn.dylib -> /Developer/NVIDIA/CUDA-8.0/lib/libcudnn.dylib
  lrwxr-xr-x   1 root         wheel    48B May 24 12:32 libcudnn_static.a -> /Developer/NVIDIA/CUDA-8.0/lib/libcudnn_static.a
  lrwxr-xr-x   1 root         wheel    49B Jan 11 17:33 
.
.
.

Real location of libcudnn:

真正的libcudnn的位置:

  /ssh:Dione.local:/Developer/NVIDIA/CUDA-8.0/lib:
  total 2825680
  .
  .
  .
  lrwxr-xr-x   1 root         wheel    19B Jan 11 17:32 libcudart.dylib -> libcudart.8.0.dylib
  -rw-r--r--   1 root         wheel   598K Jan 11 17:32 libcudart_static.a
  -rwxr-xr-x@  1 peterbecich  staff   144M Apr 12 14:12 libcudnn.6.dylib
  lrwxr-xr-x@  1 peterbecich  staff    16B Apr 12 14:16 libcudnn.dylib -> libcudnn.6.dylib
  .
  .

deviceQuery from the Nvidia CUDA samples:

来自Nvidia CUDA样品的deviceQuery:

(tensorflow) Dione:release peterbecich$ ./deviceQuery 
./deviceQuery Starting...

 CUDA Device Query (Runtime API) version (CUDART static linking)

Detected 1 CUDA Capable device(s)

Device 0: "GeForce GT 750M"
  CUDA Driver Version / Runtime Version          8.0 / 8.0
  CUDA Capability Major/Minor version number:    3.0
  Total amount of global memory:                 2048 MBytes (2147024896 bytes)
  ( 2) Multiprocessors, (192) CUDA Cores/MP:     384 CUDA Cores
  GPU Max Clock rate:                            926 MHz (0.93 GHz)
  Memory Clock rate:                             2508 Mhz
  Memory Bus Width:                              128-bit
  L2 Cache Size:                                 262144 bytes
  Maximum Texture Dimension Size (x,y,z)         1D=(65536), 2D=(65536, 65536), 3D=(4096, 4096, 4096)
  Maximum Layered 1D Texture Size, (num) layers  1D=(16384), 2048 layers
  Maximum Layered 2D Texture Size, (num) layers  2D=(16384, 16384), 2048 layers
  Total amount of constant memory:               65536 bytes
  Total amount of shared memory per block:       49152 bytes
  Total number of registers available per block: 65536
  Warp size:                                     32
  Maximum number of threads per multiprocessor:  2048
  Maximum number of threads per block:           1024
  Max dimension size of a thread block (x,y,z): (1024, 1024, 64)
  Max dimension size of a grid size    (x,y,z): (2147483647, 65535, 65535)
  Maximum memory pitch:                          2147483647 bytes
  Texture alignment:                             512 bytes
  Concurrent copy and kernel execution:          Yes with 1 copy engine(s)
  Run time limit on kernels:                     Yes
  Integrated GPU sharing Host Memory:            No
  Support host page-locked memory mapping:       Yes
  Alignment requirement for Surfaces:            Yes
  Device has ECC support:                        Disabled
  Device supports Unified Addressing (UVA):      Yes
  Device PCI Domain ID / Bus ID / location ID:   0 / 1 / 0
  Compute Mode:
     < Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >

deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 8.0, CUDA Runtime Version = 8.0, NumDevs = 1, Device0 = GeForce GT 750M
Result = PASS

Thanks very much for your time in reviewing this.

非常感谢您在这方面的时间。

2 个解决方案

#1


2  

Symbolic links from libcudnn.5.dylib to the available libcudnn.6.dylib solved it. I put links in both /Developer/NVIDIA/CUDA-8.0/lib and /usr/local/cuda/lib:

从libcudnn.5符号链接。dylib到可用的libcudnn6。dylib解决它。我在两个/Developer/NVIDIA/CUDA-8.0/lib和/usr/local/cuda/lib中放置了链接:

 16 May 24 14:12 libcudnn.5.dylib -> libcudnn.6.dylib

Successful import:

成功的导入:

Dione:tensorflow peterbecich$ source ~/tensorflow/bin/activate
(tensorflow) Dione:tensorflow peterbecich$ python3
Python 3.4.6 (default, Apr 23 2017, 17:16:17) 
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
>>> 

#2


0  

Doing the symlink fixed the import for me, but I still ran into problems later when training a model:

对我来说,做符号链接修复了导入,但是在培训模型时,我还是遇到了一些问题:

2017-09-11 21:57:26.922561: I tensorflow/core/common_runtime/gpu/gpu_device.cc:977] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GTX 1060 6GB, pci bus id: 0000:01:00.0)
2017-09-11 21:57:28.920558: E tensorflow/stream_executor/cuda/cuda_dnn.cc:352] Loaded runtime CuDNN library: 6021 (compatibility version 6000) but source was compiled with 5105 (compatibility version 5100).  If using a binary install, upgrade your CuDNN library to match.  If building from sources, make sure the library loaded at runtime matches a compatible version specified during compile configuration.

I removed the symlink and reinstalled cuDNN V5.1 from https://developer.nvidia.com/cudnn

我从https://developer.nvidia.com/cudnn删除了symlink并重新安装了cuDNN V5.1。

#1


2  

Symbolic links from libcudnn.5.dylib to the available libcudnn.6.dylib solved it. I put links in both /Developer/NVIDIA/CUDA-8.0/lib and /usr/local/cuda/lib:

从libcudnn.5符号链接。dylib到可用的libcudnn6。dylib解决它。我在两个/Developer/NVIDIA/CUDA-8.0/lib和/usr/local/cuda/lib中放置了链接:

 16 May 24 14:12 libcudnn.5.dylib -> libcudnn.6.dylib

Successful import:

成功的导入:

Dione:tensorflow peterbecich$ source ~/tensorflow/bin/activate
(tensorflow) Dione:tensorflow peterbecich$ python3
Python 3.4.6 (default, Apr 23 2017, 17:16:17) 
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
>>> 

#2


0  

Doing the symlink fixed the import for me, but I still ran into problems later when training a model:

对我来说,做符号链接修复了导入,但是在培训模型时,我还是遇到了一些问题:

2017-09-11 21:57:26.922561: I tensorflow/core/common_runtime/gpu/gpu_device.cc:977] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GTX 1060 6GB, pci bus id: 0000:01:00.0)
2017-09-11 21:57:28.920558: E tensorflow/stream_executor/cuda/cuda_dnn.cc:352] Loaded runtime CuDNN library: 6021 (compatibility version 6000) but source was compiled with 5105 (compatibility version 5100).  If using a binary install, upgrade your CuDNN library to match.  If building from sources, make sure the library loaded at runtime matches a compatible version specified during compile configuration.

I removed the symlink and reinstalled cuDNN V5.1 from https://developer.nvidia.com/cudnn

我从https://developer.nvidia.com/cudnn删除了symlink并重新安装了cuDNN V5.1。