WIndow 10 安裝 keras 問題
依據 Day66-Win10 安裝 TensorFlow-gpu & Keras.jpynb 的步驟安裝 tensorflow GPU 版本,在命列視窗可以正確執行 from tensorflow.python.client import device_lib ,得到結果 :
[name: "/device:CPU:0"
device_type: "CPU"
memory_limit: 268435456
locality {
}
incarnation: 5721589636836635419
, name: "/device:GPU:0"
device_type: "GPU"
memory_limit: 4939723571
locality {
bus_id: 1
links {
}
}
incarnation: 11233030928978555017
physical_device_desc: "device: 0, name: GeForce GTX 1060, pci bus id: 0000:01:00.0, compute capability: 6.1"
]
但是使用 jupyter notebook 啟動 jupyter 後,執行 from tensorflow.python.client import device_lib 卻出現下列錯誤訊息 :
ImportError Traceback (most recent call last) ~\Anaconda3\envs\tensorflow-gpu-35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py in <module>() 57---> 58from tensorflow.python.pywrap_tensorflow_internal import* 59from tensorflow.python.pywrap_tensorflow_internal import __version__ ~\Anaconda3\envs\tensorflow-gpu-35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py in <module>() 27return _mod ---> 28_pywrap_tensorflow_internal = swig_import_helper() 29del swig_import_helper ~\Anaconda3\envs\tensorflow-gpu-35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py in swig_import_helper() 23try:---> 24_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description) 25finally:~\Anaconda3\envs\tensorflow-gpu-35\lib\imp.py in load_module(name, file, filename, details) 242else:--> 243return load_dynamic(name, filename, file) 244elif type_ == PKG_DIRECTORY:~\Anaconda3\envs\tensorflow-gpu-35\lib\imp.py in load_dynamic(name, path, file) 342 name=name, loader=loader, origin=path) --> 343return _load(spec) 344ImportError: DLL load failed: 找不到指定的模組。 During handling of the above exception, another exception occurred: ImportError Traceback (most recent call last) <ipython-input-3-da13e3b73546> in <module>()----> 1from tensorflow.python.client import devide_lib 2 print(device_lib.list_local_devices())~\Anaconda3\envs\tensorflow-gpu-35\lib\site-packages\tensorflow\__init__.py in <module>() 22 23# pylint: disable=g-bad-import-order---> 24from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import 25 26try:~\Anaconda3\envs\tensorflow-gpu-35\lib\site-packages\tensorflow\python\__init__.py in <module>() 47import numpy as np 48---> 49from tensorflow.python import pywrap_tensorflow 50 51from tensorflow.python.tools import component_api_helper ~\Anaconda3\envs\tensorflow-gpu-35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py in <module>() 72for some common reasons and solutions. Include the entire stack trace 73 above this error message when asking for help.""" % traceback.format_exc() ---> 74raise ImportError(msg) 75 76# pylint: enable=wildcard-import,g-import-not-at-top,unused-import,line-too-longImportError: Traceback (most recent call last): File "C:\Users\yjlai\Anaconda3\envs\tensorflow-gpu-35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module> from tensorflow.python.pywrap_tensorflow_internal import * File "C:\Users\yjlai\Anaconda3\envs\tensorflow-gpu-35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module> _pywrap_tensorflow_internal = swig_import_helper() File "C:\Users\yjlai\Anaconda3\envs\tensorflow-gpu-35\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:\Users\yjlai\Anaconda3\envs\tensorflow-gpu-35\lib\imp.py", line 243, in load_module return load_dynamic(name, filename, file) File "C:\Users\yjlai\Anaconda3\envs\tensorflow-gpu-35\lib\imp.py", line 343, in load_dynamic return _load(spec) ImportError: DLL load failed: 找不到指定的模組。 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.
回答列表
-
2019/07/02 下午 04:56Jeffrey贊同數:0不贊同數:0留言數:0
看起來是Tensorflow GPU 版本未正確起動。請協助確認一下:
(1)Cuda 要先載入
(2)確認Jupiter Notebook 只安裝Tensorflow GPU 版本。
謝謝。
-
2019/07/02 下午 08:14林宣威贊同數:0不贊同數:0留言數:1
會不會是因為你的jupyter 不是使用你所安裝的虛擬環境,說明是創建一個新的虛擬環境,所以你安裝的tensorflow在虛擬環境中