python - 如何修复 python 3.7.1 上的导入 TensorFlow 错误?

标签 python python-3.x tensorflow neural-network conv-neural-network

我正在研究暗流上的 YOLO 对象检测。导入tensorflow确实会弹出错误,错误如下。我已经为 10.0 安装了 CUDA 10.0 和 cuDNN 7.5 仍然遇到这个问题,不知道为什么,我已经尝试了所有可能的解决方案。

我的系统是ASUS GL-502VS GTX1070

>import tensorflow as tf
Traceback (most recent call last):
File "C:\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in 
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in 
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Anaconda3\lib\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 "C:\Anaconda3\lib\imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "C:\Anaconda3\lib\imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: DLL load failed: The specified module could not be found.

>During handling of the above exception, another exception occurred:

>Traceback (most recent call last):
File "", line 1, in 
File "C:\Anaconda3\lib\site-packages\tensorflow_init_.py", line 24, in 
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "C:\Anaconda3\lib\site-packages\tensorflow\python_init_.py", line 49, in 
from tensorflow.python import pywrap_tensorflow
File "C:\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in 
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in 
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in 
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Anaconda3\lib\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 "C:\Anaconda3\lib\imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "C:\Anaconda3\lib\imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: DLL load failed: The specified module could not be found.

Failed to load the native TensorFlow runtime.

See https://www.tensorflow.org/install/errors

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

最佳答案

在运行脚本之前尝试一下:

export CUDA_HOME=/usr/bin/cuda # or /usr/bin/cuda-10, it depends on your installation
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$CUDA_HOME/lib64

关于python - 如何修复 python 3.7.1 上的导入 TensorFlow 错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57379475/

相关文章:

python - (Python Scipy) 如何展平 csr_matrix 并将其附加到另一个 csr_matrix?

python - 如何创建 Matplotlib fiddle 图

python - 对于 MNIST 图像,前馈 ANN 的测试精度一直停留在 42%

python - 推出网络认证系统

python - 为什么没有构造函数参数的类需要括号

python-3.x - 使用 NLTK 和 Spacy 的 NLP 命名实体识别

python - 使用 Python 进行阶乘计算

python - 使用Rawpy读取tensorflow的map方法内的原始图像文件

machine-learning - 为什么测试精度高于训练精度

python - 当查询在 Django 中以原子方式不返回任何行时,如何将新行插入表中?