我尝试使用一个Python脚本,它使用Keras/Tensorflow作为一个更大的Matlab项目的一部分。Matlab可以很好地运行Python模块。直接从终端运行Python脚本可以很好地工作。但两者的结合却以一种有趣的方式失败了:
Matlab:% tensorflowTest.m
mod = py.importlib.import_module('tensorf');
py.importlib.reload(mod);
Python:
^{pr2}$
结果是:Error using pywrap_tensorflow> (line 52)
Python Error: ImportError: Traceback (most recent call last):
File "/home/cfedk/shared/anaconda3/envs/keras/lib/python3.5/site-packages/tensorflow/python/pywrap_tensorflow.py", line 41, in
from tensorflow.python.pywrap_tensorflow_internal import *
File "/home/cfedk/shared/anaconda3/envs/keras/lib/python3.5/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in
_pywrap_tensorflow_internal = swig_import_helper()
File "/home/cfedk/shared/anaconda3/envs/keras/lib/python3.5/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 "/home/cfedk/shared/anaconda3/envs/keras/lib/python3.5/imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "/home/cfedk/shared/anaconda3/envs/keras/lib/python3.5/imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: libcudnn.so.6: cannot open shared object file: No such file or directory
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/install_sources#common_installation_problems
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
Error in __init__> (line 49)
from tensorflow.python import pywrap_tensorflow
Error in __init__> (line 24)
from tensorflow.python import *
Error in tensorf> (line 1)
import tensorflow
Error in _call_with_frames_removed (line 222)
Error in exec_module (line 678)
Error in _load_unlocked (line 673)
Error in _find_and_load_unlocked (line 958)
Error in _find_and_load (line 969)
Error in _gcd_import (line 986)
Error in __init__>import_module (line 126)
return _bootstrap._gcd_import(name[level:], package, level)
这很有趣,因为ImportError: libcudnn.so.6: cannot open shared object file: No such file or directory是我们在安装libcuddn之前看到的,或者LD_LIBRARY_PATH设置不正确。在
如果直接导入tensorflow,也会发生这种情况:py.importlib.import_module('tensorflow');
我宁愿使用RPC/单独的过程来实现这一点。我错过了什么明显的东西吗?在