'Why is Tensorflow not recognizing my GPU after conda install?

I am new to deep learning and I have been trying to install tensorflow-gpu version in my pc in vain for the last 2 days. I avoided installing CUDA and cuDNN drivers since several forums online don't recommend it due to numerous compatibility issues. Since I was already using the conda distribution of python before, I went for the conda install -c anaconda tensorflow-gpu as written in their official website here: https://anaconda.org/anaconda/tensorflow-gpu .

However even after installing the gpu version in a fresh virtual environment (to avoid potential conflicts with pip installed libraries in the base env), tensorflow doesn't seem to even recognize my GPU for some mysterious reason.

Some of the code snippets I ran(in anaconda prompt) to understand that it wasn't recognizing my GPU:-

1.

>>>from tensorflow.python.client import device_lib
        >>>print(device_lib.list_local_devices())
                    [name: "/device:CPU:0"
                device_type: "CPU"
                memory_limit: 268435456
                locality {
                }
                incarnation: 7692219132769779763
                ]

As you can see it completely ignores the GPU.

2.

>>>tf.debugging.set_log_device_placement(True)
    >>>a = tf.constant([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]])
2020-12-13 10:11:30.902956: I tensorflow/core/platform/cpu_feature_guard.cc:142] This 
TensorFlow 
binary is optimized with oneAPI Deep Neural Network Library (oneDNN)to use the following CPU 
instructions in performance-critical operations:  AVX AVX2
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
>>>b = tf.constant([[1.0, 2.0], [3.0, 4.0], [5.0, 6.0]])
>>>c = tf.matmul(a, b)
>>>print(c)
tf.Tensor(
[[22. 28.]
[49. 64.]], shape=(2, 2), dtype=float32)

Here, it was supposed to indicate that it ran with a GPU by showing Executing op MatMul in device /job:localhost/replica:0/task:0/device:GPU:0 (as written here: https://www.tensorflow.org/guide/gpu) but nothing like that is present. Also I am not sure what the message after the 2nd line means.

I have also searched for several solutions online including here but almost all of the issues are related to the first manual installation method which I haven't tried yet since everyone recommended this approach.

I don't use cmd anymore since the environment variables somehow got messed up after uninstalling tensorflow-cpu from the base env and on re-installing, it worked perfectly with anaconda prompt but not cmd. This is a separate issue (and widespread also) but I mentioned it in case that has a role to play here. I installed the gpu version in a fresh virtual environment to ensure a clean installation and as far as I understand path variables need to be set up only for manual installation of CUDA and cuDNN libraries.

The card which I use:-(which is CUDA enabled)

C:\WINDOWS\system32>wmic path win32_VideoController get name
Name
NVIDIA GeForce 940MX
Intel(R) HD Graphics 620

Tensorflow and python version I am using currently:-

>>> import tensorflow as tf
>>> tf.__version__
'2.3.0'

Python 3.8.5 (default, Sep  3 2020, 21:29:08) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.

System information: Windows 10 Home, 64-bit operating system, x64-based processor.

Any help would be really appreciated. Thanks in advance.



Solution 1:[1]

August 2021 Conda install may be working now, as according to @ComputerScientist in the comments below, conda install tensorflow-gpu==2.4.1 will give cudatoolkit-10.1.243 and cudnn-7.6.5

The following was written in Jan 2021 and is out of date

Currently conda install tensorflow-gpu installs tensorflow v2.3.0 and does NOT install the conda cudnn or cudatoolkit packages. Installing them manually (e.g. with conda install cudatoolkit=10.1) does not seem to fix the problem either.

A solution is to install an earlier version of tensorflow, which does install cudnn and cudatoolkit, then upgrade with pip

conda install tensorflow-gpu=2.1
pip install tensorflow-gpu==2.3.1

(2.4.0 uses cuda 11.0 and cudnn 8.0, however cudnn 8.0 is not in anaconda as of 16/12/2020)

Edit: please also see @GZ0's answer, which links to a github discussion with a one-line solution

Solution 2:[2]

The tensorflow build automatically selected by Anaconda on Windows 10 during the installation of tensorflow-gpu 2.3 seems to be faulty. Please find a workaround here (consider upvoting the GitHub answer if you have a GitHub account).

Windows only: Python 3.7: conda install tensorflow-gpu=2.3 tensorflow=2.3=mkl_py37h936c3e2_0

Python 3.8: conda install tensorflow-gpu=2.3 tensorflow=2.3=mkl_py38h1fcfbd6_0

Solution 3:[3]

@geometrikal solution almost worked for me. But in between installing tensorflow-gpu with conda and installing tensorflow 2.3 with pip, I needed to uninstall the tensorflow parts of the package tensorflow-gpu to avoid conistency warnings by pip. Conda would have uninstalled the whole package. I know Conda does not recommend mixing pip with conda but this is the solution worked that worked and I am tired of spending another day with this issue.

conda create -n tfgpu python=3.7
conda activate tfgpu
conda install tensorflow-gpu=2.1

pip uninstall tensorflow
pip uninstall tensorflow-estimator
pip uninstall tensorboard 
pip uninstall tensorboard-plugin-wit
pip install tensorflow==2.3
pip check

Solution 4:[4]

I also have been unable (yet) to get TF 2.3.0 to recognize my Nvidia Quadro Pro 620 GPU.

Note: I have 2 other 'environments' on this PC (windows Pro) All installed via Anaconda:

  1. Python 3.7.8 TF 2.0.0... recognizes (and uses) the Nvidia GPU
  2. Python 3.6.9 TF 2.1.0... recognizes (and uses) the Nvidia GPU
  3. Python 3.8.6 TF 2.3.0... does NOT see the GPU

My Machine has Cuda 11.1; cuDNN 8.0.5

My next thought is to consider downgrading Python from 3.8.6 to 3.7.8 in the 3rd configuration where TF = 2.3.0

Steve

Solution 5:[5]

You will need to install cuDNN and the CUDA toolkit to use your GPU.

First check for the compatible version here.

cuDNN can be found here (requires free account).

CUDA toolkit can be found here.

Again, check for a compatible version BEFORE installing. Newer versions are not backwards compatible.

Solution 6:[6]

I see that your GPU has compute capability 5.0 which is OK, TensorFlow should like it. Thus I assume something went wrong during the environment setup. Please try creating a new environment using:

conda create --name tf_gpu tensorflow-gpu 

Then install all other packages you want in tf_gpu and try again.

P.S: it is really important that in the environment you have only one TensorFlow package (the gpu one). If you have more than one, there is no guarantee that

import tensorflow as tf

will import the one you want ...

Solution 7:[7]

Using conda to install TensorFlow is always a better way to manage the multi versions of TensorFlow itself as well as CUDA and CUDNN. I recently create a new conda environment and prepare to install the newest TensorFlow too. I also encountered the issue you mentioned. I checked the dependency list from conda install tensorflow-gpu and found that the cudatoolkit and cudnn packages are missing. As the latest version of tensorflow-gpu at Anaconda is 2.3, I think the problem was already pointed out by @GZ0's answer at the GitHub issue.

Here I list the output below:

Using conda install tensorflow=2.3:

PS > conda install tensorflow-gpu=2.3
## Package Plan ##

  environment location: C:\Anaconda3\envs\test_cuda_38

  added / updated specs:
    - tensorflow-gpu=2.3


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    absl-py-0.12.0             |   py38haa95532_0         176 KB
    aiohttp-3.7.4              |   py38h2bbff1b_1         513 KB
    astunparse-1.6.3           |             py_0          17 KB
    async-timeout-3.0.1        |   py38haa95532_0          14 KB
    blas-1.0                   |              mkl           6 KB
    blinker-1.4                |   py38haa95532_0          23 KB
    brotlipy-0.7.0             |py38h2bbff1b_1003         412 KB
    cachetools-4.2.1           |     pyhd3eb1b0_0          13 KB
    cffi-1.14.5                |   py38hcd4344a_0         224 KB
    chardet-3.0.4              |py38haa95532_1003         194 KB
    click-7.1.2                |     pyhd3eb1b0_0          64 KB
    coverage-5.5               |   py38h2bbff1b_2         272 KB
    cryptography-3.4.7         |   py38h71e12ea_0         643 KB
    cython-0.29.23             |   py38hd77b12b_0         1.7 MB
    gast-0.4.0                 |             py_0          15 KB
    google-auth-1.29.0         |     pyhd3eb1b0_0          76 KB
    google-auth-oauthlib-0.4.4 |     pyhd3eb1b0_0          18 KB
    google-pasta-0.2.0         |             py_0          46 KB
    grpcio-1.36.1              |   py38hc60d5dd_1         1.7 MB
    h5py-2.10.0                |   py38h5e291fa_0         841 KB
    hdf5-1.10.4                |       h7ebc959_0         7.9 MB
    icc_rt-2019.0.0            |       h0cc432a_1         6.0 MB
    idna-2.10                  |     pyhd3eb1b0_0          52 KB
    importlib-metadata-3.10.0  |   py38haa95532_0          34 KB
    intel-openmp-2021.2.0      |     haa95532_616         1.8 MB
    keras-applications-1.0.8   |             py_1          29 KB
    keras-preprocessing-1.1.2  |     pyhd3eb1b0_0          35 KB
    libprotobuf-3.14.0         |       h23ce68f_0         1.9 MB
    markdown-3.3.4             |   py38haa95532_0         144 KB
    mkl-2021.2.0               |     haa95532_296       115.5 MB
    mkl-service-2.3.0          |   py38h2bbff1b_1          49 KB
    mkl_fft-1.3.0              |   py38h277e83a_2         137 KB
    mkl_random-1.2.1           |   py38hf11a4ad_2         223 KB
    multidict-5.1.0            |   py38h2bbff1b_2          61 KB
    numpy-1.20.1               |   py38h34a8a5c_0          23 KB
    numpy-base-1.20.1          |   py38haf7ebc8_0         4.2 MB
    oauthlib-3.1.0             |             py_0          91 KB
    opt_einsum-3.1.0           |             py_0          54 KB
    protobuf-3.14.0            |   py38hd77b12b_1         242 KB
    pyasn1-0.4.8               |             py_0          57 KB
    pyasn1-modules-0.2.8       |             py_0          72 KB
    pycparser-2.20             |             py_2          94 KB
    pyjwt-1.7.1                |           py38_0          48 KB
    pyopenssl-20.0.1           |     pyhd3eb1b0_1          49 KB
    pyreadline-2.1             |           py38_1         145 KB
    pysocks-1.7.1              |   py38haa95532_0          31 KB
    requests-2.25.1            |     pyhd3eb1b0_0          52 KB
    requests-oauthlib-1.3.0    |             py_0          23 KB
    rsa-4.7.2                  |     pyhd3eb1b0_1          28 KB
    scipy-1.6.2                |   py38h66253e8_1        13.0 MB
    tensorboard-plugin-wit-1.6.0|             py_0         630 KB
    tensorflow-2.3.0           |mkl_py38h8557ec7_0           6 KB
    tensorflow-base-2.3.0      |eigen_py38h75a453f_0        49.5 MB
    tensorflow-estimator-2.3.0 |     pyheb71bc4_0         271 KB
    termcolor-1.1.0            |   py38haa95532_1           9 KB
    typing-extensions-3.7.4.3  |       hd3eb1b0_0          12 KB
    typing_extensions-3.7.4.3  |     pyh06a4308_0          28 KB
    urllib3-1.26.4             |     pyhd3eb1b0_0         105 KB
    werkzeug-1.0.1             |     pyhd3eb1b0_0         239 KB
    win_inet_pton-1.1.0        |   py38haa95532_0          35 KB
    wrapt-1.12.1               |   py38he774522_1          49 KB
    yarl-1.6.3                 |   py38h2bbff1b_0         153 KB
    ------------------------------------------------------------
                                           Total:       210.0 MB

Using conda install tensorflow=2.1:

PS > conda install tensorflow-gpu=2.1
## Package Plan ##

  environment location: C:\Anaconda3\envs\test_cuda

  added / updated specs:
    - tensorflow-gpu=2.1


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    _tflow_select-2.1.0        |              gpu           3 KB
    absl-py-0.12.0             |   py37haa95532_0         175 KB
    aiohttp-3.7.4              |   py37h2bbff1b_1         507 KB
    astor-0.8.1                |   py37haa95532_0          47 KB
    async-timeout-3.0.1        |   py37haa95532_0          14 KB
    blas-1.0                   |              mkl           6 KB
    blinker-1.4                |   py37haa95532_0          23 KB
    brotlipy-0.7.0             |py37h2bbff1b_1003         337 KB
    cachetools-4.2.1           |     pyhd3eb1b0_0          13 KB
    cffi-1.14.5                |   py37hcd4344a_0         220 KB
    chardet-3.0.4              |py37haa95532_1003         192 KB
    click-7.1.2                |     pyhd3eb1b0_0          64 KB
    coverage-5.5               |   py37h2bbff1b_2         273 KB
    cryptography-3.4.7         |   py37h71e12ea_0         641 KB
    cudatoolkit-10.1.243       |       h74a9793_0       300.3 MB
    cudnn-7.6.5                |       cuda10.1_0       179.1 MB
    cython-0.29.23             |   py37hd77b12b_0         1.7 MB
    gast-0.2.2                 |           py37_0         155 KB
    google-auth-1.29.0         |     pyhd3eb1b0_0          76 KB
    google-auth-oauthlib-0.4.4 |     pyhd3eb1b0_0          18 KB
    google-pasta-0.2.0         |             py_0          46 KB
    grpcio-1.36.1              |   py37hc60d5dd_1         1.7 MB
    h5py-2.10.0                |   py37h5e291fa_0         808 KB
    hdf5-1.10.4                |       h7ebc959_0         7.9 MB
    icc_rt-2019.0.0            |       h0cc432a_1         6.0 MB
    idna-2.10                  |     pyhd3eb1b0_0          52 KB
    importlib-metadata-3.10.0  |   py37haa95532_0          34 KB
    intel-openmp-2021.2.0      |     haa95532_616         1.8 MB
    keras-applications-1.0.8   |             py_1          29 KB
    keras-preprocessing-1.1.2  |     pyhd3eb1b0_0          35 KB
    libprotobuf-3.14.0         |       h23ce68f_0         1.9 MB
    markdown-3.3.4             |   py37haa95532_0         144 KB
    mkl-2021.2.0               |     haa95532_296       115.5 MB
    mkl-service-2.3.0          |   py37h2bbff1b_1          48 KB
    mkl_fft-1.3.0              |   py37h277e83a_2         133 KB
    mkl_random-1.2.1           |   py37hf11a4ad_2         214 KB
    multidict-5.1.0            |   py37h2bbff1b_2          85 KB
    numpy-1.20.1               |   py37h34a8a5c_0          23 KB
    numpy-base-1.20.1          |   py37haf7ebc8_0         4.1 MB
    oauthlib-3.1.0             |             py_0          91 KB
    opt_einsum-3.1.0           |             py_0          54 KB
    protobuf-3.14.0            |   py37hd77b12b_1         240 KB
    pyasn1-0.4.8               |             py_0          57 KB
    pyasn1-modules-0.2.8       |             py_0          72 KB
    pycparser-2.20             |             py_2          94 KB
    pyjwt-1.7.1                |           py37_0          49 KB
    pyopenssl-20.0.1           |     pyhd3eb1b0_1          49 KB
    pyreadline-2.1             |           py37_1         143 KB
    pysocks-1.7.1              |           py37_1          28 KB
    requests-2.25.1            |     pyhd3eb1b0_0          52 KB
    requests-oauthlib-1.3.0    |             py_0          23 KB
    rsa-4.7.2                  |     pyhd3eb1b0_1          28 KB
    scipy-1.6.2                |   py37h66253e8_1        12.8 MB
    six-1.15.0                 |   py37haa95532_0          51 KB
    tensorboard-plugin-wit-1.6.0|             py_0         630 KB
    tensorflow-2.1.0           |gpu_py37h7db9008_0           4 KB
    tensorflow-base-2.1.0      |gpu_py37h55f5790_0       105.3 MB
    tensorflow-estimator-2.1.0 |     pyhd54b08b_0         251 KB
    tensorflow-gpu-2.1.0       |       h0d30ee6_0           3 KB
    termcolor-1.1.0            |   py37haa95532_1           9 KB
    typing-extensions-3.7.4.3  |       hd3eb1b0_0          12 KB
    typing_extensions-3.7.4.3  |     pyh06a4308_0          28 KB
    urllib3-1.26.4             |     pyhd3eb1b0_0         105 KB
    werkzeug-0.16.1            |             py_0         258 KB
    win_inet_pton-1.1.0        |   py37haa95532_0          35 KB
    wrapt-1.12.1               |   py37he774522_1          49 KB
    yarl-1.6.3                 |   py37h2bbff1b_0         151 KB
    ------------------------------------------------------------
                                           Total:       745.0 MB

Therefore, you may install the latest version (v2.3) of tensorflow-gpu from Anaconda on Windows platform using the advises from @GZ0 and @geometrikal, or just using conda install tensorflow-gpu=2.1 to get the newest and right environment.

Notice that tensorflow-gpu v2.1 only support Python between 3.5-3.7.

Solution 8:[8]

As of August 2021, with TensorFlow 2.4.1, I believe it seems to install CUDA and CuDNN in a conda environment. Here's what I did to create a fresh conda env on an Ubuntu 18.04 machine:

conda create --name tftest python=3.7 -y  &&  conda activate tftest
conda install ipython tensorflow-gpu==2.4.1 -y

The command above will list the following packages to be installed. For our purposes, note how cudatoolkit and cudnn are listed.

The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    _tflow_select-2.1.0        |              gpu           2 KB
    absl-py-0.13.0             |   py37h06a4308_0         173 KB
    aiohttp-3.7.4              |   py37h27cfd23_1         536 KB
    astor-0.8.1                |   py37h06a4308_0          47 KB
    astunparse-1.6.3           |             py_0          17 KB
    async-timeout-3.0.1        |   py37h06a4308_0          13 KB
    attrs-21.2.0               |     pyhd3eb1b0_0          46 KB
    backcall-0.2.0             |     pyhd3eb1b0_0          13 KB
    blas-1.0                   |              mkl           6 KB
    blinker-1.4                |   py37h06a4308_0          23 KB
    brotlipy-0.7.0             |py37h27cfd23_1003         320 KB
    c-ares-1.17.1              |       h27cfd23_0         108 KB
    cachetools-4.2.2           |     pyhd3eb1b0_0          13 KB
    cffi-1.14.6                |   py37h400218f_0         223 KB
    chardet-3.0.4              |py37h06a4308_1003         175 KB
    charset-normalizer-2.0.4   |     pyhd3eb1b0_0          35 KB
    click-8.0.1                |     pyhd3eb1b0_0          79 KB
    coverage-5.5               |   py37h27cfd23_2         254 KB
    cryptography-3.4.7         |   py37hd23ed53_0         904 KB
    cudatoolkit-10.1.243       |       h6bb024c_0       347.4 MB
    cudnn-7.6.5                |       cuda10.1_0       179.9 MB
    cupti-10.1.168             |                0         1.4 MB
    cython-0.29.24             |   py37h295c915_0         1.9 MB
    decorator-5.0.9            |     pyhd3eb1b0_0          12 KB
    gast-0.4.0                 |     pyhd3eb1b0_0          13 KB
    google-auth-1.33.0         |     pyhd3eb1b0_0          80 KB
    google-auth-oauthlib-0.4.4 |     pyhd3eb1b0_0          18 KB
    google-pasta-0.2.0         |             py_0          46 KB
    grpcio-1.36.1              |   py37h2157cd5_1         1.9 MB
    h5py-2.10.0                |   py37hd6299e0_1         902 KB
    hdf5-1.10.6                |       hb1b8bf9_0         3.7 MB
    idna-3.2                   |     pyhd3eb1b0_0          48 KB
    importlib-metadata-3.10.0  |   py37h06a4308_0          33 KB
    intel-openmp-2021.3.0      |    h06a4308_3350         1.4 MB
    ipython-7.26.0             |   py37hb070fc8_0        1005 KB
    ipython_genutils-0.2.0     |     pyhd3eb1b0_1          27 KB
    jedi-0.18.0                |   py37h06a4308_1         911 KB
    keras-preprocessing-1.1.2  |     pyhd3eb1b0_0          35 KB
    libgfortran-ng-7.5.0       |      ha8ba4b0_17          22 KB
    libgfortran4-7.5.0         |      ha8ba4b0_17         995 KB
    libprotobuf-3.17.2         |       h4ff587b_1         2.0 MB
    markdown-3.3.4             |   py37h06a4308_0         127 KB
    matplotlib-inline-0.1.2    |     pyhd3eb1b0_2          12 KB
    mkl-2021.3.0               |     h06a4308_520       141.2 MB
    mkl-service-2.4.0          |   py37h7f8727e_0          56 KB
    mkl_fft-1.3.0              |   py37h42c9631_2         170 KB
    mkl_random-1.2.2           |   py37h51133e4_0         287 KB
    multidict-5.1.0            |   py37h27cfd23_2          66 KB
    numpy-1.20.3               |   py37hf144106_0          23 KB
    numpy-base-1.20.3          |   py37h74d4b33_0         4.5 MB
    oauthlib-3.1.1             |     pyhd3eb1b0_0          90 KB
    opt_einsum-3.3.0           |     pyhd3eb1b0_1          57 KB
    parso-0.8.2                |     pyhd3eb1b0_0          69 KB
    pexpect-4.8.0              |     pyhd3eb1b0_3          53 KB
    pickleshare-0.7.5          |  pyhd3eb1b0_1003          13 KB
    prompt-toolkit-3.0.17      |     pyh06a4308_0         256 KB
    protobuf-3.17.2            |   py37h295c915_0         319 KB
    ptyprocess-0.7.0           |     pyhd3eb1b0_2          17 KB
    pyasn1-0.4.8               |             py_0          57 KB
    pyasn1-modules-0.2.8       |             py_0          72 KB
    pygments-2.10.0            |     pyhd3eb1b0_0         725 KB
    pyjwt-2.1.0                |   py37h06a4308_0          32 KB
    pyopenssl-20.0.1           |     pyhd3eb1b0_1          49 KB
    pysocks-1.7.1              |           py37_1          27 KB
    python-flatbuffers-1.12    |     pyhd3eb1b0_0          24 KB
    requests-2.26.0            |     pyhd3eb1b0_0          59 KB
    requests-oauthlib-1.3.0    |             py_0          23 KB
    rsa-4.7.2                  |     pyhd3eb1b0_1          28 KB
    scipy-1.6.2                |   py37had2a1c9_1        15.5 MB
    six-1.16.0                 |     pyhd3eb1b0_0          18 KB
    tensorboard-2.4.0          |     pyhc547734_0         8.8 MB
    tensorboard-plugin-wit-1.6.0|             py_0         630 KB
    tensorflow-2.4.1           |gpu_py37ha2e99fa_0           4 KB
    tensorflow-base-2.4.1      |gpu_py37h29c2da4_0       195.2 MB
    tensorflow-estimator-2.5.0 |     pyh7b7c402_0         267 KB
    tensorflow-gpu-2.4.1       |       h30adc30_0           3 KB
    termcolor-1.1.0            |   py37h06a4308_1           9 KB
    traitlets-5.0.5            |     pyhd3eb1b0_0          81 KB
    typing-extensions-3.10.0.0 |       hd3eb1b0_0           8 KB
    typing_extensions-3.10.0.0 |     pyh06a4308_0          27 KB
    urllib3-1.26.6             |     pyhd3eb1b0_1         112 KB
    wcwidth-0.2.5              |             py_0          29 KB
    werkzeug-1.0.1             |     pyhd3eb1b0_0         239 KB
    wrapt-1.12.1               |   py37h7b6447c_1          49 KB
    yarl-1.6.3                 |   py37h27cfd23_0         133 KB
    zipp-3.5.0                 |     pyhd3eb1b0_0          13 KB
    ------------------------------------------------------------
                                           Total:       915.9 MB

Next, run ipython and try:

In [1]: import tensorflow as tf
2021-08-29 12:26:36.582384: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcudart.so.10.1

In [2]: tf.config.list_physical_devices('GPU')
2021-08-29 12:26:48.676151: I tensorflow/compiler/jit/xla_cpu_device.cc:41] Not creating XLA devices, tf_xla_enable_xla_devices not set
2021-08-29 12:26:48.679894: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcuda.so.1
2021-08-29 12:26:48.975002: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1720] Found device 0 with properties: 
pciBusID: 0000:04:00.0 name: Tesla V100-PCIE-32GB computeCapability: 7.0
coreClock: 1.38GHz coreCount: 80 deviceMemorySize: 31.75GiB deviceMemoryBandwidth: 836.37GiB/s
2021-08-29 12:26:48.979341: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1720] Found device 1 with properties: 
pciBusID: 0000:08:00.0 name: Tesla V100-PCIE-32GB computeCapability: 7.0
coreClock: 1.38GHz coreCount: 80 deviceMemorySize: 31.75GiB deviceMemoryBandwidth: 836.37GiB/s
2021-08-29 12:26:48.981747: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1720] Found device 2 with properties: 
pciBusID: 0000:09:00.0 name: Tesla V100-PCIE-32GB computeCapability: 7.0
coreClock: 1.38GHz coreCount: 80 deviceMemorySize: 31.75GiB deviceMemoryBandwidth: 836.37GiB/s
2021-08-29 12:26:48.990002: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1720] Found device 3 with properties: 
pciBusID: 0000:85:00.0 name: Tesla V100-PCIE-32GB computeCapability: 7.0
coreClock: 1.38GHz coreCount: 80 deviceMemorySize: 31.75GiB deviceMemoryBandwidth: 836.37GiB/s
2021-08-29 12:26:48.992488: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1720] Found device 4 with properties: 
pciBusID: 0000:89:00.0 name: Tesla V100-PCIE-32GB computeCapability: 7.0
coreClock: 1.38GHz coreCount: 80 deviceMemorySize: 31.75GiB deviceMemoryBandwidth: 836.37GiB/s
2021-08-29 12:26:48.992523: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcudart.so.10.1
2021-08-29 12:26:49.312793: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcublas.so.10
2021-08-29 12:26:49.312907: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcublasLt.so.10
2021-08-29 12:26:49.388961: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcufft.so.10
2021-08-29 12:26:49.413946: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcurand.so.10
2021-08-29 12:26:49.535055: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcusolver.so.10
2021-08-29 12:26:49.563142: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcusparse.so.10
2021-08-29 12:26:50.009291: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcudnn.so.7
2021-08-29 12:26:50.051301: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1862] Adding visible gpu devices: 0, 1, 2, 3, 4
Out[2]: 
[PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU'),
 PhysicalDevice(name='/physical_device:GPU:1', device_type='GPU'),
 PhysicalDevice(name='/physical_device:GPU:2', device_type='GPU'),
 PhysicalDevice(name='/physical_device:GPU:3', device_type='GPU'),
 PhysicalDevice(name='/physical_device:GPU:4', device_type='GPU')]

In [3]: tf.test.is_built_with_cuda()
Out[3]: True

This machine has 5 GPUs, so the above output is correct.

What I'm not actually sure about is why CUDA 10.1 and CuDNN 7.6.5 are installed, since it seems like from Google's TF compatibility chart that 2.4.0 (and presumably 2.4.1?) work with CUDA 11.0 and CuDNN 8. If anyone has insights on that, feel free to chime in...

Solution 9:[9]

In my case (In April 2022):

 conda install tensorflow-gpu=2.3 tensorflow=2.3=mkl_py38h1fcfbd6_0 cudatoolkit cudnn keras matplotlib

Works perfectly!! it installed tensorflow-gpu=2.3 - cudatoolkit 10.1.243 and cudnn 7.6.5

Solution 10:[10]

Updated April 26, 2022, tensorflow 2.6.0 does the job, Python version 3.8.13

Recap - in Anaconda Jupyter, encountered the same "GPU no show" issue

'2.3.0'

Followed the procedure in this link, again "GPU no show".

Trial and error: workaround below does the job.

  1. Launch CMD window from Navigator (the same environment);
  2. conda install tensorflow=2.6.0 –-channel conda-forge -y;
  3. It will take some time (collecting package, resolving environment etc.);
  4. In this case, automatically update CUDA and cuDNN versions to 11.3 and 8.2, respectively.
  5. After it is done, exit Anaconda and restart the computer.
  6. Return to Jupyter, run the cell:

cell

and check result:

2.6.0

[PhysicalDevice(name='/physical_device:CPU:0', device_type='CPU'), PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]

Solution 11:[11]

Following Steps worked for me:

Do the same as in the video. https://www.youtube.com/watch?v=r31jnE7pR-g

Also install tensorflow estimator which is missing in the video. In picture you can see my environment which is working for me.

my environment

Maybe you have to change the versions to the same ones. Now go in Visual Code and run your code with the anaconda environment you created before. See picture below.

select your environment

In my case it it tf_env, what i created and named.

Try to run your code. If Visual Code says something is missing try to install it with the anaconda terminal. Click the "play"-Button to start the terminal.

play Button terminal

Also close and open Visual Code when you do changes, sometimes anaconda too. Now try this code below.

> print("Num GPU: ", len(tf.config.list_physical_devices("GPU")))
> 
> print(tf.test.is_gpu_available()) print(tf.test.is_built_with_cuda())



> OUTPUT 
> Num GPU:  1 
> WARNING:tensorflow:From <ipython-input-2-8748de971110>:3:
> is_gpu_available (from tensorflow.python.framework.test_util) is
> deprecated and will be removed in a future version. Instructions for
> updating: Use `tf.config.list_physical_devices('GPU')` instead. 
> True
> True

If your output is the same, everything went fine. Now when you train a model you should see your gpu running in your task manager.

Hopefully it helps you guys :)