我已将Tensorflow安装到OSX 10.12上的全新虚拟环境中:https://www.tensorflow.org/install/install_mac#installing_with_virtualenv
在一次尝试中,我将这两个安装在一个新的virtualenv中:
$ pip3 install --upgrade tensorflow
$ pip3 install --upgrade tensorflow-gpu
在另一次尝试中,我只在一个新的virtualenv中安装了它:
$ pip3 install --upgrade tensorflow-gpu
我认为这是错误:
Library not loaded: @rpath/libcudnn.5.dylib
安装提供了libcudnn.6.dylib
但未提供libcudnn.5.dylib
我相信我的问题与这两个不同
Failed to load the native TensorFlow runtime. Reason : Image not found. What am I doing wrong?
Tensorflow error [image not found]
因为他们的错误涉及libcudart
:
Library not loaded: @rpath/libcudart.8.0.dylib
跟踪:
(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.
在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版本,原因是:https://github.com/caffe2/caffe2/issues/318#issuecomment-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
版本:
(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
虚拟环境中的点子:
(tensorflow) Dione:~ peterbecich$ pip3 --version
pip 9.0.1 from /Users/peterbecich/tensorflow/lib/python3.4/site-packages (python 3.4)
libcudnn
是/usr/local/cuda/lib
中的符号链接。有趣的是,丢失的文件为libcudnn.5.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
.
.
.
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
.
.
来自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
非常感谢您抽出时间审核此事。
答案 0 :(得分:2)
从libcudnn.5.dylib
到可用libcudnn.6.dylib
的符号链接解决了这个问题。我在/Developer/NVIDIA/CUDA-8.0/lib
和/usr/local/cuda/lib
中添加了链接:
16 May 24 14:12 libcudnn.5.dylib -> libcudnn.6.dylib
成功导入:
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
>>>
答案 1 :(得分:1)
使用符号链接为我修复了导入,但是在训练模型后我仍遇到问题:
$scope.setRecaptchaId = function(widgetId) {
$scope.recaptchaId = widgetId;
return;
};
$scope.letter.mresponse = vcRecaptchaService.getResponse($scope.recaptchaId);
我删除了符号链接,并从https://developer.nvidia.com/cudnn
重新安装了cuDNN V5.1