我剛在新筆記本上安裝了tensorflow。在Spyder中導入張量流時出錯
(蟒蛇4.3.24,Python的3.6.1,TensorFlow:1.2.1,GPU:NVIDIA 1060 6GB)目前
四個問題。
{1} 「未能加載天然TensorFlow運行時」 錯誤在Spyder的
File "D:/Programs/Codes-Python/OpenCVtest.py", line 13, in <module>
import tensorflow as tf
File "D:\Programs\Anaconda\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
from tensorflow.python import *
File "D:\Programs\Anaconda\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "D:\Programs\Anaconda\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 52, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "D:\Programs\Anaconda\lib\site-
packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in
swig_import_helper
return importlib.import_module(mname)
File "D:\Programs\Anaconda\lib\importlib\__init__.py", line 126, in
import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 978, in _gcd_import
File "<frozen importlib._bootstrap>", line 961, in _find_and_load
File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 648, in _load_unlocked
File "<frozen importlib._bootstrap>", line 560, in module_from_spec
File "<frozen importlib._bootstrap_external>", line 922, in create_module
File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
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 "D:\Programs\Anaconda\lib\site-
packages\tensorflow\python\pywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "D:\Programs\Anaconda\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 21, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "D:\Programs\Anaconda\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
return importlib.import_module('_pywrap_tensorflow_internal')
File "D:\Programs\Anaconda\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named '_pywrap_tensorflow_internal'
Failed to load the native TensorFlow runtime.
{2} ...但tensorflow負載而不會從命令提示符(多)問題
令人困惑的是,當我通過anaconda提示加載tensorflow - >激活tensorflow - > python - >導入tensorflow時:導入tensorflow時沒有錯誤。
怎麼回事?如果tensorflow庫只安裝了某些環境中Spyder的錯誤消息應該是「無模塊命名TensorFlow」 ......
{3}有些不符運行的例子
當現在,當我運行anaconda提示中的測試代碼:
>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
我得到以下「錯誤」?
2017-08-14 23:39:37.137745: W c:\tf_jenkins\home\workspace\release-win\m\windows\py\36\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE instructions, but these are available on your machine and could speed up CPU computations.
2017-08-14 23:39:37.137929: W c:\tf_jenkins\home\workspace\release-win\m\windows\py\36\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE2 instructions, but these are available on your machine and could speed up CPU computations.
2017-08-14 23:39:37.139157: W c:\tf_jenkins\home\workspace\release-win\m\windows\py\36\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE3 instructions, but these are available on your machine and could speed up CPU computations.
2017-08-14 23:39:37.139677: W c:\tf_jenkins\home\workspace\release-win\m\windows\py\36\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
2017-08-14 23:39:37.140599: W c:\tf_jenkins\home\workspace\release-win\m\windows\py\36\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
2017-08-14 23:39:37.141239: W c:\tf_jenkins\home\workspace\release-win\m\windows\py\36\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
2017-08-14 23:39:37.141915: W c:\tf_jenkins\home\workspace\release-win\m\windows\py\36\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.
2017-08-14 23:39:37.142529: W c:\tf_jenkins\home\workspace\release-win\m\windows\py\36\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations.
但我仍然可以運行測試「打印(sess.run(你好))」的最後一部分,得到以下結果。
>>> print(sess.run(hello))
b'Hello, TensorFlow!'
在你面前的'b'不應該在那裏,但是當我運行代碼時總是存在。爲什麼?
{4}沒有已知的設備錯誤 - GPU無法識別? 最後,當我檢查正在使用的設備時,tensorflow似乎無法識別GPU。爲什麼?我嘗試卸載,重新安裝tensorflow和tensorflow-GPU分開無濟於事。
>>> sess = tf.Session(config = tf.ConfigProto(log_device_placement=True))
Device mapping: no known devices.
2017-08-14 23:50:42.624086: I c:\tf_jenkins\home\workspace\release-win\m\windows\py\36\tensorflow\core\common_runtime\direct_session.cc:265] Device mapping:
任何幫助將不勝感激。 謝謝, CN
謝謝,羅賓。 CUDA 8.0(和cuDNN)已經安裝,儘管現在我不確定它是否被正確安裝。 NVIDIA的示例程序不再用於驗證安裝。 – CockneyNinja