Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tensorflow command tf.test.is_gpu_available() returns False


What am I missing to get tf.test.is_gpu_available() to return True? Is there some kind of configuration file that needs updating?


I am using Python 3.7.{1,2}

after: pip install --user tensorflow-gpu==2.0.0-alpha0 (before: pip install --user tensorflow==2.0.0-alpha0)

partial pip list:

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

execute: import tensorflow as tf

returns: DLL model not found with stack traceback as:

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.

During handling of the above exception, another exception occurred:

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.

then after: pip install --user tensorflow==2.0.0-alpha0

pip list partial return:

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

execute: print(tf.test.is_gpu_available())

returns:

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

My PATH environment variable is:

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\

Where c:\tools\cuda\bin containes cuDNN.DLL


What am I missing to get tf.test.is_gpu_available() to return True? Is there some kind of configuration file that needs updating?

like image 948
Stephen Avatar asked Apr 04 '19 17:04

Stephen


People also ask

How do I check my GPU in Python?

Check GPU Availability The easiest way to check if you have access to GPUs is to call torch. cuda. is_available(). If it returns True, it means the system has the Nvidia driver correctly installed.

Does TensorFlow automatically use GPU?

TensorFlow GPU OperationsBy default, if a GPU is available, TensorFlow will use it for all operations. You can control which GPU TensorFlow will use for a given operation, or instruct TensorFlow to use a CPU, even if a GPU is available.


1 Answers

I faced a similar issue and the resolution for me was to match CUDA version with Tensorflow version as per the below table. (i.e Tensorflow 1.14 needed cuda 10.0)

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

like image 88
Notauser Avatar answered Dec 15 '22 20:12

Notauser