1. 程式人生 > >安裝TensorFlow後 import tensorflow 報錯

安裝TensorFlow後 import tensorflow 報錯

安裝TensorFlow後 

import tensorflow

提示以下錯誤:(解決方法在最後)

tensorflow安裝成功,import tensorflow時出錯。

ImportError: DLL load failed: 記憶體位置訪問無效。

During handling of the above exception, another exception occurred:


Traceback (most recent call last):


File "D:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\site-p


ackages\tensorflow\python\__init__.py", line 66, in <module>


from tensorflow.python import pywrap_tensorflow


File "D:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\site-p


ackages\tensorflow\python\pywrap_tensorflow.py", line 21, in <module>


_pywrap_tensorflow = swig_import_helper()


File "D:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\site-p


ackages\tensorflow\python\pywrap_tensorflow.py", line 20, in swig_import_helper


return importlib.import_module('_pywrap_tensorflow')


File "D:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\import


lib\__init__.py", line 126, in import_module


return _bootstrap._gcd_import(name[level:], package, level)


ImportError: No module named '_pywrap_tensorflow'

解決方法:我安裝的TensorFlow版本是tensorflow_gpu-1.1.0-cp35-cp35m-win_amd64.whl(即:TensorFlow1.1 Python3.5 Windows64位)

將版本改為cuda8.0+cudnn8.0即可正常匯入。

ps:至於為什麼要用這個版本我也不知道,開始的時候我用的cuda8.0+cudnn6.0就老是報上面的錯