Cuda version problem, torch.cuda.is_available() returns false

Hello,

I don’t understand how to make cuda work on my conda environment. I want to use it with pytorch on python but everytime I run torch.cuda.is_available() , it returns false. So I checked online, and maybe this is due to my cuda version.

I have a RTX A1000 and nvidia-smi returns:

However it seems that cuda 12.0 is too much for my driver version and I should install cuda version 10.2. So that’s what I did by running: conda install pytorch cudatoolkit=10.2 -c pytorch

Now if I do conda list:

# Name                    Version                   Build  Channel
aiofiles                  22.1.0          py311haa95532_0
aiosqlite                 0.18.0          py311haa95532_0
anyio                     3.5.0           py311haa95532_0
argon2-cffi               21.3.0             pyhd3eb1b0_0
argon2-cffi-bindings      21.2.0          py311h2bbff1b_0
asttokens                 2.0.5              pyhd3eb1b0_0
attrs                     22.1.0          py311haa95532_0
babel                     2.11.0          py311haa95532_0
backcall                  0.2.0              pyhd3eb1b0_0
beautifulsoup4            4.12.2          py311haa95532_0
blas                      1.0                         mkl
bleach                    4.1.0              pyhd3eb1b0_0
brotlipy                  0.7.0           py311h2bbff1b_1002
bzip2                     1.0.8                he774522_0
ca-certificates           2023.05.30           haa95532_0
certifi                   2023.5.7        py311haa95532_0
cffi                      1.15.1          py311h2bbff1b_3
charset-normalizer        2.0.4              pyhd3eb1b0_0
colorama                  0.4.6           py311haa95532_0
comm                      0.1.2           py311haa95532_0
cryptography              39.0.1          py311h21b164f_0
cudatoolkit               10.2.89              h74a9793_1
debugpy                   1.5.1           py311hd77b12b_0
decorator                 5.1.1              pyhd3eb1b0_0
defusedxml                0.7.1              pyhd3eb1b0_0
entrypoints               0.4             py311haa95532_0
executing                 0.8.3              pyhd3eb1b0_0
filelock                  3.9.0           py311haa95532_0
giflib                    5.2.1                h8cc25b3_3
glib                      2.69.1               h5dc1a3c_2
gst-plugins-base          1.18.5               h9e645db_0
gstreamer                 1.18.5               hd78058f_0
icu                       58.2                 ha925a31_3
idna                      3.4             py311haa95532_0
intel-openmp              2023.1.0         h59b6b97_46319
ipykernel                 6.19.2          py311h86cfffd_0
ipython                   8.12.0          py311haa95532_0
ipython_genutils          0.2.0              pyhd3eb1b0_1
ipywidgets                8.0.4           py311haa95532_0
jedi                      0.18.1          py311haa95532_1
jinja2                    3.1.2           py311haa95532_0
jpeg                      9e                   h2bbff1b_1
json5                     0.9.6              pyhd3eb1b0_0
jsonschema                4.17.3          py311haa95532_0
jupyter                   1.0.0           py311haa95532_8
jupyter_client            8.1.0           py311haa95532_0
jupyter_console           6.6.3           py311haa95532_0
jupyter_core              5.3.0           py311haa95532_0
jupyter_events            0.6.3           py311haa95532_0
jupyter_server            2.5.0           py311haa95532_0
jupyter_server_fileid     0.9.0           py311haa95532_0
jupyter_server_terminals  0.4.4           py311haa95532_1
jupyter_server_ydoc       0.8.0           py311haa95532_1
jupyter_ydoc              0.2.4           py311haa95532_0
jupyterlab                3.6.3           py311haa95532_0
jupyterlab_pygments       0.1.2                      py_0
jupyterlab_server         2.22.0          py311haa95532_0
jupyterlab_widgets        3.0.5           py311haa95532_0
krb5                      1.19.4               h5b6d351_0
lerc                      3.0                  hd77b12b_0
libclang                  14.0.6          default_hb5a9fac_1
libclang13                14.0.6          default_h8e68704_1
libdeflate                1.17                 h2bbff1b_0
libffi                    3.4.4                hd77b12b_0
libiconv                  1.16                 h2bbff1b_2
libogg                    1.3.5                h2bbff1b_1
libpng                    1.6.39               h8cc25b3_0
libsodium                 1.0.18               h62dcd97_0
libtiff                   4.5.0                h6c2663c_2
libuv                     1.44.2               h2bbff1b_0
libvorbis                 1.3.7                he774522_0
libwebp                   1.2.4                hbc33d0d_1
libwebp-base              1.2.4                h2bbff1b_1
libxml2                   2.10.3               h0ad7f3c_0
libxslt                   1.1.37               h2bbff1b_0
lxml                      4.9.2           py311h2bbff1b_0
lz4-c                     1.9.4                h2bbff1b_0
markupsafe                2.1.1           py311h2bbff1b_0
matplotlib-inline         0.1.6           py311haa95532_0
mistune                   0.8.4           py311h2bbff1b_1000
mkl                       2023.1.0         h8bd8f75_46356
mpmath                    1.2.1           py311haa95532_0
nbclassic                 0.5.5           py311haa95532_0
nbclient                  0.5.13          py311haa95532_0
nbconvert                 6.5.4           py311haa95532_0
nbformat                  5.7.0           py311haa95532_0
nest-asyncio              1.5.6           py311haa95532_0
networkx                  2.8.4           py311haa95532_1
notebook                  6.5.4           py311haa95532_0
notebook-shim             0.2.2           py311haa95532_0
openssl                   1.1.1u               h2bbff1b_0
packaging                 23.0            py311haa95532_0
pandocfilters             1.5.0              pyhd3eb1b0_0
parso                     0.8.3              pyhd3eb1b0_0
pcre                      8.45                 hd77b12b_0
pickleshare               0.7.5           pyhd3eb1b0_1003
pip                       23.1.2          py311haa95532_0
platformdirs              2.5.2           py311haa95532_0
ply                       3.11            py311haa95532_0
prometheus_client         0.14.1          py311haa95532_0
prompt-toolkit            3.0.36          py311haa95532_0
prompt_toolkit            3.0.36               hd3eb1b0_0
psutil                    5.9.0           py311h2bbff1b_0
pure_eval                 0.2.2              pyhd3eb1b0_0
pycparser                 2.21               pyhd3eb1b0_0
pygments                  2.15.1          py311haa95532_1
pyopenssl                 23.0.0          py311haa95532_0
pyqt                      5.15.7          py311hd77b12b_0
pyqt5-sip                 12.11.0         py311hd77b12b_0
pyrsistent                0.18.0          py311h2bbff1b_0
pysocks                   1.7.1           py311haa95532_0
python                    3.11.4               h966fe2a_0
python-dateutil           2.8.2              pyhd3eb1b0_0
python-fastjsonschema     2.16.2          py311haa95532_0
python-json-logger        2.0.7           py311haa95532_0
pytorch                   2.0.1              py3.11_cpu_0    pytorch
pytorch-mutex             1.0                         cpu    pytorch
pytz                      2022.7          py311haa95532_0
pywin32                   305             py311h2bbff1b_0
pywinpty                  2.0.10          py311h5da7b33_0
pyyaml                    6.0             py311h2bbff1b_1
pyzmq                     25.1.0          py311hd77b12b_0
qt-main                   5.15.2               he8e5bd7_8
qt-webengine              5.15.9               hb9a9bb5_5
qtconsole                 5.4.2           py311haa95532_0
qtpy                      2.2.0           py311haa95532_0
qtwebkit                  5.212                h2bbfb41_5
requests                  2.29.0          py311haa95532_0
rfc3339-validator         0.1.4           py311haa95532_0
rfc3986-validator         0.1.1           py311haa95532_0
send2trash                1.8.0              pyhd3eb1b0_1
setuptools                67.8.0          py311haa95532_0
sip                       6.6.2           py311hd77b12b_0
six                       1.16.0             pyhd3eb1b0_1
sniffio                   1.2.0           py311haa95532_1
soupsieve                 2.4             py311haa95532_0
sqlite                    3.41.2               h2bbff1b_0
stack_data                0.2.0              pyhd3eb1b0_0
sympy                     1.11.1          py311haa95532_0
tbb                       2021.8.0             h59b6b97_0
terminado                 0.17.1          py311haa95532_0
tinycss2                  1.2.1           py311haa95532_0
tk                        8.6.12               h2bbff1b_0
toml                      0.10.2             pyhd3eb1b0_0
tornado                   6.2             py311h2bbff1b_0
traitlets                 5.7.1           py311haa95532_0
typing-extensions         4.6.3           py311haa95532_0
typing_extensions         4.6.3           py311haa95532_0
tzdata                    2023c                h04d1e81_0
urllib3                   1.26.16         py311haa95532_0
vc                        14.2                 h21ff451_1
vs2015_runtime            14.27.29016          h5e58377_2
wcwidth                   0.2.5              pyhd3eb1b0_0
webencodings              0.5.1           py311haa95532_1
websocket-client          0.58.0          py311haa95532_4
wheel                     0.38.4          py311haa95532_0
widgetsnbextension        4.0.5           py311haa95532_0
win_inet_pton             1.1.0           py311haa95532_0
winpty                    0.4.3                         4
xz                        5.4.2                h8cc25b3_0
y-py                      0.5.9           py311hb6bf4ef_0
yaml                      0.2.5                he774522_0
ypy-websocket             0.8.2           py311haa95532_0
zeromq                    4.3.4                hd77b12b_0
zlib                      1.2.13               h8cc25b3_0
zstd                      1.5.5                hd43e919_0

But still torch.cuda.is_available() returns False
and torch.backends.cudnn.enabled returns True
torch.cuda.version returns None

I don’t understand what is the problem here if someone could help me. Is it really the cudatoolkit version ?

when you install from conda you need something like pytorch-cuda=<version>, check with the instructions here: Start Locally | PyTorch

Your Ampere GPU needs CUDA 11.x so you should install a PyTorch binary with CUDA 11.7 or 11.8 for the latest torch==2.0.1 release or with CUDA 11.8 or 12.1 for a nightly release as @nairbv also mentioned.

This package name indicates that you’ve installed a CPU-only PyTorch binary, which explains the error.

Thanks this helped a lot !

I had to uninstall everything and then re install with the command

conda install pytorch torchvision torchaudio pytorch-cuda=11.8 -c pytorch -c nvidia