Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/280.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用import在简单python代码中导入tensorflow时出错_Python_Ubuntu_Tensorflow - Fatal编程技术网

使用import在简单python代码中导入tensorflow时出错

使用import在简单python代码中导入tensorflow时出错,python,ubuntu,tensorflow,Python,Ubuntu,Tensorflow,我试图在tensorflow中只使用一行运行示例代码—导入tensorflow作为tf。但它给出了这个错误 Traceback (most recent call last): File "sample.py", line 1, in <module> import tensorflow as tf File "/home/djlimdiwala/.local/lib/python2.7/site-packages/tensorflow/__init__.py", l

我试图在tensorflow中只使用一行运行示例代码—导入tensorflow作为tf。但它给出了这个错误

Traceback (most recent call last):   File "sample.py", line 1, in <module>
    import tensorflow as tf   File "/home/djlimdiwala/.local/lib/python2.7/site-packages/tensorflow/__init__.py", line 24, in <module>
    from tensorflow.python import *   File "/home/djlimdiwala/.local/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 72, in <module>
    raise ImportError(msg) ImportError: Traceback (most recent call last):   File "/home/djlimdiwala/.local/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 61, in <module>
    from tensorflow.python import pywrap_tensorflow   File "/home/djlimdiwala/.local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 28, in <module>
    _pywrap_tensorflow = swig_import_helper()   File "/home/djlimdiwala/.local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow', fp, pathname, description) ImportError: libcudart.so.8.0: cannot open shared object file: No such file or directory



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.
Traceback(最近一次调用last):文件“sample.py”,第1行,在
导入tensorflow作为tf文件“/home/djlimdiwala/.local/lib/python2.7/site packages/tensorflow/_init__.py”,第24行,在
从tensorflow.python import*文件“/home/djlimdiwala/.local/lib/python2.7/site packages/tensorflow/python/_init__.py”,第72行,在
raise ImportError(msg)ImportError:Traceback(最近一次调用最后一次):文件“/home/djlimdiwala/.local/lib/python2.7/site packages/tensorflow/python/_uuuuinit_uuu.py”,第61行,在
从tensorflow.python导入pywrap_tensorflow文件“/home/djlimdiwala/.local/lib/python2.7/site packages/tensorflow/python/pywrap_tensorflow.py”,第28行,在
_pywrap\u tensorflow=swig\u import\u helper()文件“/home/djlimdiwala/.local/lib/python2.7/site packages/tensorflow/python/pywrap\u tensorflow.py”,swig\u import\u helper中的第24行
_mod=imp.load_module(“'u pywrap_tensorflow',fp,pathname,description)ImportError:libcudart.so.8.0:无法打开共享对象文件:没有此类文件或目录
未能加载本机TensorFlow运行时。
看见https://github.com/tensorflow/tensorflow/blob/master/tensorflow/g3doc/get_started/os_setup.md#import_error
因为一些常见的原因和解决方案。请求帮助时,请在此错误消息上方包含整个堆栈跟踪。
有人能帮忙吗?

关注这一部分: “ImportError:libcudart.so.8.0:无法打开共享对象文件:没有此类文件或目录”

之所以消息显示是因为TunSoFrand找不到安装英伟达CUDA库的地方。尝试将其与tensorflow一起正确安装


如果您使用的是预构建的TensorFlow二进制文件(包含在其网站中),请在安装前检查支持的cuda和cudnn版本。那些预构建的TensorFlow版本仅支持特定版本。

它会给您带来此错误,因为当您安装cuda时,它不会保存其在环境中的位置

ImportError: libcudart.so.8.0: cannot open shared object file: No such file or directory
将路径导出到cuda库:

sudo ldconfig /usr/local/cuda/lib64
cuda_版本:8.0

cuDNN_版本:5.1


看起来您需要安装cuda驱动程序。这里有一组非常好的说明:试着先使用CPU开始工作。