matlab调用tenserflow,在Matlab中通过Python导入Tensorflow

我尝试使用一个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/单独的过程来实现这一点。我错过了什么明显的东西吗?在

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值