安装tensorflow时报错:
Traceback (most recent call last):
File "<frozen importlib._bootstrap>", line 985, in _gcd_import
File "<frozen importlib._bootstrap>", line 968, in _find_and_load
File "<frozen importlib._bootstrap>", line 957, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 666, in _load_unlocked
File "<frozen importlib._bootstrap>", line 577, in module_from_spec
File "<frozen importlib._bootstrap_external>", line 938, in create_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
ImportError: DLL load failed: 找不到指定的模块。
我在安装tensorflow-gpu1.3版本时代码报错,于是我降低版本,重新安装了tensorflow-gpu1.12,但还是报了相同的错误。
我参考了:https://github.com/tensorflow/tensorflow/issues/22794
重新设置了本地的cuda和|cudnn的版本:cuda9和cudnn7.4.15。
然后重启电脑,代码没有报错,但是输出下列内容:
>>> import tensorflow
C:\Users\29414\anaconda3\envs\tf_gpu1.2\lib\site-packages\tensorflow\python\framework\dtypes.py:523: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint8 = np.dtype([("qint8", np.int8, 1)])
C:\Users\29414\anaconda3\envs\tf_gpu1.2\lib\site-packages\tensorflow\python\framework\dtypes.py:524: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_quint8 = np.dtype([("quint8", np.uint8, 1)])
C:\Users\29414\anaconda3\envs\tf_gpu1.2\lib\site-packages\tensorflow\python\framework\dtypes.py:525: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint16 = np.dtype([("qint16", np.int16, 1)])
C:\Users\29414\anaconda3\envs\tf_gpu1.2\lib\site-packages\tensorflow\python\framework\dtypes.py:526: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_quint16 = np.dtype([("quint16", np.uint16, 1)])
C:\Users\29414\anaconda3\envs\tf_gpu1.2\lib\site-packages\tensorflow\python\framework\dtypes.py:527: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint32 = np.dtype([("qint32", np.int32, 1)])
C:\Users\29414\anaconda3\envs\tf_gpu1.2\lib\site-packages\tensorflow\python\framework\dtypes.py:532: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
np_resource = np.dtype([("resource", np.ubyte, 1)])
原因是numpy版本和tensorflow版本不适配导致。所有重新下载numpy==1.15.4,问题解决。
注意:是__version__ , 不是_verison_ 有两个下划线。
简单总结:
导致报错的原因是:cuda版本问题和库包不适配问题。
附上tensorflow历史版本链接:
https://pypi.org/project/tensorflow-gpu/1.1.0/#history