【问题标题】:Tensorflow command tf.test.is_gpu_available() returns FalseTensorFlow 命令 tf.test.is_gpu_available() 返回 False
【发布时间】:2019-04-04 17:16:49
【问题描述】:

让 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

pip 列表部分返回:

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 我缺少什么? 是否有某种配置文件需要更新?

【问题讨论】:

    标签: python-3.x tensorflow


    【解决方案1】:

    我遇到了类似的问题,我的解决方案是根据下表将 CUDA 版本与 Tensorflow 版本相匹配。 (即 Tensorflow 1.14 需要 cuda 10.0)

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

    【讨论】:

      猜你喜欢
      • 2019-10-31
      • 1970-01-01
      • 2012-09-04
      • 2020-08-04
      • 2011-07-11
      • 2017-10-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多