python - 如何修复 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.
解决方案
在运行脚本之前尝试一下:
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
推荐阅读
- rest - Call REST API with and without user context
- docker - Docker daemon memory consumption grows over time
- google-cloud-firestore - 允许未注册用户查询 Firestore 以检查电子邮件是否已存在
- stanford-nlp - Warnings on Spanish text processing Stanford CoreNLP Number in types > column for ... is probably priority
- java - Address already in use in spring boot, can we tell spring to reuse the same address?
- javascript - vuejs在输入时为数字添加逗号
- excel - 禁用对机密选项卡的访问
- java - 如何在 java 中将我的答案四舍五入到小数点后三位,以便 10.5 应打印为 105.000
- vba - 如何在 ms Access 中使用组合框显示表中字段的值,同时向用户提供要编辑的选项列表?
- ruby-on-rails - 在视图中加载记录后如何更新记录的属性?