1

I can't run my code using GPU.

import tensorflow as tf
#tf.disable_v2_behavior()

print("Num GPUs Available: ", len(tf.config.experimental.list_physical_devices('GPU')))

It prints

Num GPUs Available:  0

from tensorflow.python.client import device_lib
print(device_lib.list_local_devices())

I got result:

    [name: "/device:CPU:0"
device_type: "CPU"
memory_limit: 268435456
locality {
}
incarnation: 17720202429719738985
]

I also checked for nvidia-smi Following are the results: [![enter image description here][1]][1]

What I have already done?

  1. I tried to run in tf-gpu environment
  2. Install CUDATOOL KIT
  3. Remove Tensorflow and install Keras-gpu ( also tried installing Tensorflow-gpu)

My Conda list (tf-gpu enviroment):

#
# Name                    Version                   Build  Channel
_tflow_select             2.3.0                       gpu
absl-py                   0.10.0                   py38_0    anaconda
aiohttp                   3.6.3            py38he774522_0    anaconda
argon2-cffi               20.1.0                   pypi_0    pypi
astunparse                1.6.3                      py_0    anaconda
async-generator           1.10                     pypi_0    pypi
async-timeout             3.0.1                    py38_0    anaconda
attrs                     20.2.0                     py_0    anaconda
backcall                  0.2.0              pyhd3eb1b0_0
blas                      1.0                         mkl    anaconda
bleach                    3.3.0                    pypi_0    pypi
blinker                   1.4                      py38_0    anaconda
brotlipy                  0.7.0           py38he774522_1000    anaconda
ca-certificates           2021.1.19            haa95532_0
cachetools                4.1.1                      py_0    anaconda
certifi                   2020.12.5        py38haa95532_0
cffi                      1.14.3           py38h7a1dbc1_0    anaconda
chardet                   3.0.4                 py38_1003    anaconda
click                     7.1.2                      py_0    anaconda
colorama                  0.4.4              pyhd3eb1b0_0
cryptography              3.1.1            py38h7a1dbc1_0    anaconda
cudatoolkit               10.2.89              h74a9793_1
cudnn                     7.6.5                cuda10.2_0
cycler                    0.10.0                   pypi_0    pypi
decorator                 4.4.2              pyhd3eb1b0_0
defusedxml                0.6.0                    pypi_0    pypi
entrypoints               0.3                      pypi_0    pypi
gast                      0.4.0                      py_0    anaconda
google-auth               1.22.1                     py_0    anaconda
google-auth-oauthlib      0.4.1                      py_2    anaconda
google-pasta              0.2.0                      py_0    anaconda
grpcio                    1.31.0           py38he7da953_0    anaconda
h5py                      2.10.0           py38h5e291fa_0    anaconda
hdf5                      1.10.4               h7ebc959_0    anaconda
icc_rt                    2019.0.0             h0cc432a_1    anaconda
idna                      2.10                       py_0    anaconda
importlib-metadata        2.0.0                      py_1    anaconda
intel-openmp              2020.2                      254    anaconda
ipykernel                 5.4.3                    pypi_0    pypi
ipython                   7.20.0           py38hd4e2768_1
ipython_genutils          0.2.0              pyhd3eb1b0_1
ipywidgets                7.6.3                    pypi_0    pypi
jedi                      0.18.0                   pypi_0    pypi
jinja2                    2.11.3                   pypi_0    pypi
jsonschema                3.2.0                    pypi_0    pypi
jupyter                   1.0.0                    pypi_0    pypi
jupyter-client            6.1.11                   pypi_0    pypi
jupyter-console           6.2.0                    pypi_0    pypi
jupyter_client            6.1.7                      py_0
jupyter_core              4.7.1            py38haa95532_0
jupyterlab-pygments       0.1.2                    pypi_0    pypi
jupyterlab-widgets        1.0.0                    pypi_0    pypi
keras-applications        1.0.8                      py_1    anaconda
keras-base                2.4.3                      py_0    anaconda
keras-gpu                 2.4.3                         0    anaconda
keras-preprocessing       1.1.0                      py_1    anaconda
kiwisolver                1.3.1                    pypi_0    pypi
lab                       6.2                      pypi_0    pypi
libprotobuf               3.13.0.1             h200bbdf_0    anaconda
libsodium                 1.0.18               h62dcd97_0
logzero                   1.6.3                    pypi_0    pypi
markdown                  3.3.2                    py38_0    anaconda
markupsafe                1.1.1                    pypi_0    pypi
matplotlib                3.3.4                    pypi_0    pypi
mistune                   0.8.4                    pypi_0    pypi
mkl                       2020.2                      256    anaconda
mkl-service               2.3.0            py38h196d8e1_0
mkl_fft                   1.2.0            py38h45dec08_0
mkl_random                1.1.1            py38h47e9c7a_0    anaconda
multidict                 4.7.6            py38he774522_1    anaconda
nbclient                  0.5.1                    pypi_0    pypi
nbconvert                 6.0.7                    pypi_0    pypi
nbformat                  5.1.2                    pypi_0    pypi
nest-asyncio              1.5.1                    pypi_0    pypi
notebook                  6.2.0                    pypi_0    pypi
numpy                     1.19.2           py38hadc3359_0
numpy-base                1.19.2           py38ha3acd2a_0
oauthlib                  3.1.0                      py_0    anaconda
openssl                   1.1.1i               h2bbff1b_0
opt_einsum                3.1.0                      py_0    anaconda
packaging                 20.9                     pypi_0    pypi
pandocfilters             1.4.3                    pypi_0    pypi
parso                     0.8.1              pyhd3eb1b0_0
pickleshare               0.7.5           pyhd3eb1b0_1003
pillow                    8.1.0                    pypi_0    pypi
pip                       20.3.3           py38haa95532_0
prometheus-client         0.9.0                    pypi_0    pypi
prompt-toolkit            3.0.14                   pypi_0    pypi
protobuf                  3.13.0.1         py38ha925a31_1    anaconda
pyasn1                    0.4.8                      py_0    anaconda
pyasn1-modules            0.2.8                      py_0    anaconda
pycparser                 2.20                       py_2    anaconda
pygments                  2.7.4              pyhd3eb1b0_0
pyjwt                     1.7.1                    py38_0    anaconda
pyopenssl                 19.1.0                     py_1    anaconda
pyparsing                 2.4.7                    pypi_0    pypi
pyreadline                2.1                      py38_1    anaconda
pyrsistent                0.17.3                   pypi_0    pypi
pysocks                   1.7.1                    py38_0    anaconda
python                    3.8.5                h5fd99cc_1
python-dateutil           2.8.1              pyhd3eb1b0_0
pywin32                   300                      pypi_0    pypi
pywinpty                  0.5.7                    pypi_0    pypi
pyyaml                    5.3.1            py38he774522_0    anaconda
pyzmq                     22.0.2                   pypi_0    pypi
qtconsole                 5.0.2                    pypi_0    pypi
qtpy                      1.9.0                    pypi_0    pypi
requests                  2.24.0                     py_0    anaconda
requests-oauthlib         1.3.0                      py_0    anaconda
rsa                       4.6                        py_0    anaconda
scipy                     1.6.0            py38h14eb087_0
send2trash                1.5.0                    pypi_0    pypi
setuptools                52.0.0           py38haa95532_0
simplejson                3.17.2                   pypi_0    pypi
six                       1.15.0           py38haa95532_0
sqlite                    3.33.0               h2a8f88b_0
tensorboard               2.3.0              pyh4dce500_0
tensorboard-plugin-wit    1.6.0                      py_0    anaconda
tensorflow                2.3.0           mkl_py38h8557ec7_0
tensorflow-base           2.3.0           eigen_py38h75a453f_0
tensorflow-estimator      2.3.0              pyheb71bc4_0    anaconda
tensorflow-gpu            2.3.0                he13fc11_0
termcolor                 1.1.0                    py38_1    anaconda
terminado                 0.9.2                    pypi_0    pypi
testpath                  0.4.4                    pypi_0    pypi
tornado                   6.1              py38h2bbff1b_0
traitlets                 5.0.5              pyhd3eb1b0_0
txt2tags                  3.7                      pypi_0    pypi
urllib3                   1.25.11                    py_0    anaconda
vc                        14.2                 h21ff451_1
vs2015_runtime            14.27.29016          h5e58377_2
wcwidth                   0.2.5                      py_0
webencodings              0.5.1                    pypi_0    pypi
werkzeug                  1.0.1                      py_0    anaconda
wheel                     0.36.2             pyhd3eb1b0_0
widgetsnbextension        3.5.1                    pypi_0    pypi
win_inet_pton             1.1.0                    py38_0    anaconda
wincertstore              0.2                      py38_0
wrapt                     1.12.1           py38he774522_1    anaconda
yaml                      0.1.7            vc14h4cb57cf_1  [vc14]  anaconda
yarl                      1.6.2            py38he774522_0    anaconda
zeromq                    4.3.3                ha925a31_3
zipp                      3.3.1                      py_0    anaconda
zlib                      1.2.11               h62dcd97_4

Edit: I can run the code on GPU on COLAB, but when I connect Colab to my localhost and try to detect GPU it gives the flowing output:

Num GPUs Available:  0
not available

[name: "/device:CPU:0"
device_type: "CPU"
memory_limit: 268435456
locality {
}
incarnation: 17545230405736238271
, name: "/device:XLA_CPU:0"
device_type: "XLA_CPU"
memory_limit: 17179869184
locality {
}
incarnation: 11765174725774020195
physical_device_desc: "device: XLA_CPU device"
, name: "/device:XLA_GPU:0"
device_type: "XLA_GPU"
memory_limit: 17179869184
locality {
}
incarnation: 1916258125448229970
physical_device_desc: "device: XLA_GPU device"
]

Can anyone guide me on what I am doing wrong? Thanks

2 Answers2

0

So Problem solved by creating a new environment and installing all modules again.

So for those who are having the same issue use the following steps and see if it works for you.

  1. Check this page for compatibility ( as mentioned in the comments above by Nima S)

[Check Compatibility][1]

2)Create a new environment or update or downgrade versions in the same environment.

conda install python=3.7.0


conda install pytorch==1.6.0 torchvision==0.7.0 cudatoolkit=10.1 -c pytorch

and then try again hopefully it will solve the problem.

If you have a better solution please do post your answers. [1]: https://www.tensorflow.org/install/source#gpu

0

Actually, it's the pywin32 module.

I was able to reproduce the same issue pre and post installation of pywin32, which is needed to launch jupyter notebooks with recognizable kernels or jupyterlab.

Unfortunately I don't know the workaround on pywin32 other than not installing it...