我成功安装了TensorFlow,但是当我尝试从tensorflow.org运行示例测试代码时:
import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))
我收到以下错误消息:
> ImportError: Traceback (most recent call last): File
> "/home/ivan/.local/lib/python3.5/site-packages/tensorflow/python/pywrap_tensorflow.py",
> line 58, in <module>
> from tensorflow.python.pywrap_tensorflow_internal import * File "/home/ivan/.local/lib/python3.5/site-packages/tensorflow/python/pywrap_tensorflow_internal.py",
> line 28, in <module>
> _pywrap_tensorflow_internal = swig_import_helper() File "/home/ivan/.local/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 "/usr/lib/python3.5/imp.py", line 242,
> in load_module
> return load_dynamic(name, filename, file) File "/usr/lib/python3.5/imp.py", line 342, in load_dynamic
> return _load(spec) ImportError: libcublas.so.9.0: cannot open shared object file: No such file or directory
我在Ubuntu 16.04上。
答案 0 :(得分:0)
Tensorflow无法找到您的CUDA 9.0目录。我的猜测是你不小心为cpu安装了tensorflow-gpu而不是tensorflow。见 installation guide了解更多信息。
如果您有可用的gpu,您为CUDA安装了太新的tf版本(因为v1.6需要CUDA 9),或者您忘记更新allowing only possible combinations
环境变量以便cuda在tenoflow中可以看到路径。