首页 > 解决方案 > 如何修复 python 3.7.1 上的 Import TensorFlow 错误?

问题描述

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

我的系统是华硕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.

标签: pythonpython-3.xtensorflowneural-networkconv-neural-network

解决方案


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

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

推荐阅读