2017-03-03 2 views
1

Ich habe Python3 und TensorFlow 1.0 auf meinem Mac installiert und es funktioniert gut, wenn ich Code in "Terminal" mit der Befehlszeile ausführen.Einstellung TensorFlow auf Mac mit PyCharm

$ python3 /Users/yeongsanggim/git/pythonstudy/study/tf01.py 
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcublas.8.0.dylib locally 
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcudnn.5.dylib locally 
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcufft.8.0.dylib locally 
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcuda.1.dylib locally 
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcurand.8.0.dylib locally 

Aber wenn ich IntelliJ oder PyCharm und den gleichen Code ausführen,

/Library/Frameworks/Python.framework/Versions/3.4/bin/python3.4 /Users/yeongsanggim/git/pythonstudy/study/tf01.py 
Traceback (most recent call last): 
    File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/tensorflow/python/__init__.py", line 61, in <module> 
from tensorflow.python import pywrap_tensorflow 
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/tensorflow/python/pywrap_tensorflow.py", line 28, in <module> 
    _pywrap_tensorflow = swig_import_helper() 
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/tensorflow/python/pywrap_tensorflow.py", line 24, in swig_import_helper 
_mod = imp.load_module('_pywrap_tensorflow', fp, pathname, description) 
    File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/imp.py", line 243, in load_module 
return load_dynamic(name, filename, file) 
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/tensorflow/python/_pywrap_tensorflow.so, 10): Library not loaded: @rpath/libcudart.8.0.dylib 
Referenced from: /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/tensorflow/python/_pywrap_tensorflow.so 
Reason: image not found 

During handling of the above exception, another exception occurred: 

Traceback (most recent call last): 
File "/Users/yeongsanggim/git/pythonstudy/study/tf01.py", line 1, in <module> 
import tensorflow as tf 
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/tensorflow/__init__.py", line 24, in <module> 
from tensorflow.python import * 
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/tensorflow/python/__init__.py", line 72, in <module> 
raise ImportError(msg) 
ImportError: Traceback (most recent call last): 
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/tensorflow/python/__init__.py", line 61, in <module> 
from tensorflow.python import pywrap_tensorflow 
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/tensorflow/python/pywrap_tensorflow.py", line 28, in <module> 
_pywrap_tensorflow = swig_import_helper() 
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/tensorflow/python/pywrap_tensorflow.py", line 24, in swig_import_helper 
_mod = imp.load_module('_pywrap_tensorflow', fp, pathname, description) 
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/imp.py", line 243, in load_module 
return load_dynamic(name, filename, file) 
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/tensorflow/python/_pywrap_tensorflow.so, 10): Library not loaded: @rpath/libcudart.8.0.dylib 
    Referenced from: /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/tensorflow/python/_pywrap_tensorflow.so 
    Reason: image not found 


Failed to load the native TensorFlow runtime. 

See  https://github.com/tensorflow/tensorflow/blob/master/tensorflow/g3doc/get_started/os_setup.md#import_error 

for some common reasons and solutions. Include the entire stack trace 
above this error message when asking for help. 

Process finished with exit code 1 

Warum ist das passiert ??? Wie kann ich das beheben?

+0

[dies] (http://stackoverflow.com/questions/42398672/pycharm-remote-interpreter-and-tensorflow-can-not-import-cudart-so) kann von Interesse sein –

Antwort

2
export DYLD_LIBRARY_PATH=/usr/local/cuda/lib 

Wählen Sie "Konfiguration bearbeiten". Sie sehen eine Umgebungsoption, in der Sie auf das Feld ... klicken müssen und den für Ihren Fall zutreffenden DYLD_LIBRARY_PATH eingeben müssen.

Beachten Sie, dass es eine Umgebungsoption für die spezifische Datei gibt, an der Sie gerade arbeiten (im linken Feld markiert) und für Defaults (legen Sie DYLD _... ebenfalls dort ab, wenn Sie zukünftige Dateien erstellen möchten Dies). Beachten Sie, dass Sie diese Konfig speichern müssen, sonst wird PyCharm nicht geschlossen.

Verwandte Themen