Tensorflow命令tf.test.is_gpu_available()返回False

时间:2019-04-04 17:16:50

标签: python-3.x tensorflow


我缺少让tf.test.is_gpu_available()返回True的东西吗? 是否有需要更新的配置文件?


我正在使用Python 3.7。{1,2}

之后:pip install --user tensorflow-gpu==2.0.0-alpha0 (之前:pip install --user tensorflow==2.0.0-alpha0

部分点子列表:

tabulate                 0.8.3
tb-nightly               1.14.0a20190301
tensorboard              1.13.1
tensorflow-datasets      1.0.1
tensorflow-estimator     1.13.0
tensorflow-gpu           2.0.0a0
tensorflow-metadata      0.13.0
termcolor                1.1.0
terminado                0.8.1
terminaltables           3.1.0
testpath                 0.4.2
tf-estimator-nightly     1.14.0.dev2019030115
tqdm                     4.31.1
traitlets                4.3.2
urllib3                  1.24.1
virtualenv               16.0.0

执行:import tensorflow as tf

返回:找不到带有堆栈回溯的DLL模型:

C:\Users\steph\PycharmProjects\Image1\TF2>python
Python 3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018, 23:09:28) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
Traceback (most recent call last):
  File "C:\Users\steph\AppData\Roaming\Python\Python37\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "C:\Users\steph\AppData\Roaming\Python\Python37\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "C:\Users\steph\AppData\Roaming\Python\Python37\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:\Program Files\Python37\lib\imp.py", line 242, in load_module
    return load_dynamic(name, filename, file)
  File "C:\Program Files\Python37\lib\imp.py", line 342, in load_dynamic
    return _load(spec)
ImportError: DLL load failed: The specified module could not be found.

在处理上述异常期间,发生了另一个异常:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\steph\AppData\Roaming\Python\Python37\site-packages\tensorflow\__init__.py", line 27, in <module>
    from tensorflow._api.v2 import audio
  File "C:\Users\steph\AppData\Roaming\Python\Python37\site-packages\tensorflow\_api\v2\audio\__init__.py", line 8, in <module>
    from tensorflow.python.ops.gen_audio_ops import decode_wav
  File "C:\Users\steph\AppData\Roaming\Python\Python37\site-packages\tensorflow\python\__init__.py", line 49, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "C:\Users\steph\AppData\Roaming\Python\Python37\site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "C:\Users\steph\AppData\Roaming\Python\Python37\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "C:\Users\steph\AppData\Roaming\Python\Python37\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "C:\Users\steph\AppData\Roaming\Python\Python37\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:\Program Files\Python37\lib\imp.py", line 242, in load_module
    return load_dynamic(name, filename, file)
  File "C:\Program Files\Python37\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.

之后:pip install --user tensorflow==2.0.0-alpha0

点列表的部分回报:

tabulate                 0.8.3
tb-nightly               1.14.0a20190301
tensorboard              1.13.1
tensorflow               2.0.0a0
tensorflow-datasets      1.0.1
tensorflow-estimator     1.13.0
tensorflow-gpu           2.0.0a0
tensorflow-metadata      0.13.0
termcolor                1.1.0
terminado                0.8.1
terminaltables           3.1.0
testpath                 0.4.2
tf-estimator-nightly     1.14.0.dev2019030115

执行:print(tf.test.is_gpu_available())

返回:

C:\Users\steph\PycharmProjects\Image1\TF2>python
Python 3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018, 23:09:28) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> print(tf.test.is_gpu_available())
2019-04-04 12:04:46.612501: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
False

我的PATH环境变量是:

C:\Users\steph\PycharmProjects\Image1\TF2>path
PATH=C:\tools\cuda\lib\x64;C:\tools\cuda\bin;C:\Users\steph\AppData\Roaming\Python\Python37\Scripts;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\include;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\extras\CUPTI\lib64;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\lib\x64;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\bin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\libnvvp;C:\Program Files\Python37\Scripts\;C:\Program Files\Python37\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\MATLAB\R2019a\bin;C:\Program Files\MATLAB\R2018b\bin;C:\Program Files\MATLAB\R2018a\bin;C:\Program Files\MATLAB\R2014a\bin;C:\Program Files\dotnet\;C:\Program Files\MATLAB\MATLAB Runtime\v901\runtime\win64;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files\NVIDIA Corporation\Nsight Compute 2019.1\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Users\steph\AppData\Local\Microsoft\WindowsApps;;C:\Program Files\JetBrains\PyCharm Community Edition 2018.3.5\bin;;C:\Users\steph\AppData\Local\Programs\Microsoft VS Code\bin;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\

c:\tools\cuda\bin包含cuDNN.DLL的地方


我缺少让tf.test.is_gpu_available()返回True的东西吗? 是否有需要更新的配置文件?

1 个答案:

答案 0 :(得分:0)

我遇到了类似的问题,对我来说,解决方案是按照下表将CUDA版本与Tensorflow版本进行匹配。 (即Tensorflow 1.14需要cuda 10.0)

https://www.tensorflow.org/install/source#linux