Torch not compiled with CUDA enabled - reinstalling pytorch is not working

My code which I'm trying to run gives me an error: AssertionError: Torch not compiled with CUDA enabled.

I was trying to search for an solution to this problem and I found a lot of solutions saying the same. Just use code:

conda install pytorch torchvision cudatoolkit=10.2 -c pytorch

And then it should work, since previously pytorch was installed without CUDA enabled.

However, my code still returns me exactly same error and I don't know why. I've also tried to change cudatoolkit=10.2 to cudatoolkit=10.1 but result is identical.

For more specific info I upload some specifics obtained with nvidia-smi command:

enter image description here

Additionally I'm uploading list of my packages produced by conda list

# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                        main
_openmp_mutex             4.5                       1_gnu
_pytorch_select           0.1                       cpu_0
absl-py                   0.15.0             pyhd8ed1ab_0    conda-forge
aiohttp                   3.7.4.post0      py39h3811e60_0    conda-forge
async-timeout             3.0.1                   py_1000    conda-forge
attrs                     21.2.0             pyhd8ed1ab_0    conda-forge
blas                      1.0                         mkl
blinker                   1.4                        py_1    conda-forge
brotlipy                  0.7.0           py39h3811e60_1001    conda-forge
bzip2                     1.0.8                h7b6447c_0
c-ares                    1.17.1               h27cfd23_0
ca-certificates           2021.9.30            h06a4308_1
cachetools                4.2.4              pyhd8ed1ab_0    conda-forge
certifi                   2021.10.8        py39h06a4308_0
cffi                      1.14.6           py39h400218f_0
chardet                   4.0.0            py39hf3d152e_1    conda-forge
charset-normalizer        2.0.0              pyhd8ed1ab_0    conda-forge
click                     8.0.3            py39hf3d152e_0    conda-forge
colorama                  0.4.4              pyh9f0ad1d_0    conda-forge
cpuonly                   2.0                           0    pytorch
cryptography              35.0.0           py39hbca0aa6_0    conda-forge
cudatoolkit               10.2.89              hfd86e86_1
dataclasses               0.8                pyhc8e2a94_3    conda-forge
ffmpeg                    4.3                  hf484d3e_0    pytorch
freetype                  2.10.4               h5ab3b9f_0
fsspec                    2021.10.1          pyhd8ed1ab_0    conda-forge
future                    0.18.2           py39hf3d152e_3    conda-forge
giflib                    5.2.1                h7b6447c_0
gmp                       6.2.1                h2531618_2
gnutls                    3.6.15               he1e5248_0
google-auth               1.35.0             pyh6c4a22f_0    conda-forge
google-auth-oauthlib      0.4.6              pyhd8ed1ab_0    conda-forge
grpcio                    1.37.1           py39hff7568b_0    conda-forge
idna                      3.1                pyhd3deb0d_0    conda-forge
importlib-metadata        4.8.1            py39hf3d152e_0    conda-forge
intel-openmp              2019.4                      243
jpeg                      9d                   h7f8727e_0
lame                      3.100                h7b6447c_0
lcms2                     2.12                 h3be6417_0
ld_impl_linux-64          2.35.1               h7274673_9
libffi                    3.3                  he6710b0_2
libgcc-ng                 9.3.0               h5101ec6_17
libgfortran-ng            7.5.0               ha8ba4b0_17
libgfortran4              7.5.0               ha8ba4b0_17
libgomp                   9.3.0               h5101ec6_17
libiconv                  1.15                 h63c8f33_5
libidn2                   2.3.2                h7f8727e_0
libmklml                  2019.0.5                      0
libpng                    1.6.37               hbc83047_0
libprotobuf               3.15.8               h780b84a_0    conda-forge
libstdcxx-ng              9.3.0               hd4cf53a_17
libtasn1                  4.16.0               h27cfd23_0
libtiff                   4.2.0                h85742a9_0
libunistring              0.9.10               h27cfd23_0
libuv                     1.40.0               h7b6447c_0
libwebp                   1.2.0                h89dd481_0
libwebp-base              1.2.0                h27cfd23_0
lz4-c                     1.9.3                h295c915_1
markdown                  3.3.4              pyhd8ed1ab_0    conda-forge
mkl                       2020.2                      256
mkl-service               2.3.0            py39he8ac12f_0
mkl_fft                   1.3.0            py39h54f3939_0
mkl_random                1.0.2            py39h63df603_0
multidict                 5.1.0            py39h27cfd23_2
ncurses                   6.2                  he6710b0_1
nettle                    3.7.3                hbbd107a_1
ninja                     1.10.2               hff7bd54_1
numpy                     1.19.2           py39h89c1606_0
numpy-base                1.19.2           py39h2ae0177_0
oauthlib                  3.1.1              pyhd8ed1ab_0    conda-forge
olefile                   0.46               pyhd3eb1b0_0
openh264                  2.1.0                hd408876_0
openssl                   1.1.1l               h7f8727e_0
packaging                 21.0               pyhd8ed1ab_0    conda-forge
pillow                    8.4.0            py39h5aabda8_0
pip                       21.2.4           py39h06a4308_0
protobuf                  3.15.8           py39he80948d_0    conda-forge
pyasn1                    0.4.8                      py_0    conda-forge
pyasn1-modules            0.2.7                      py_0    conda-forge
pycparser                 2.20                       py_2
pydeprecate               0.3.1              pyhd8ed1ab_0    conda-forge
pyjwt                     2.3.0              pyhd8ed1ab_0    conda-forge
pyopenssl                 21.0.0             pyhd8ed1ab_0    conda-forge
pyparsing                 2.4.7              pyh9f0ad1d_0    conda-forge
pysocks                   1.7.1            py39hf3d152e_3    conda-forge
python                    3.9.7                h12debd9_1
python_abi                3.9                      2_cp39    conda-forge
pytorch                   1.10.0              py3.9_cpu_0    pytorch
pytorch-lightning         1.4.9              pyhd8ed1ab_0    conda-forge
pytorch-mutex             1.0                         cpu    pytorch
pyu2f                     0.1.5              pyhd8ed1ab_0    conda-forge
pyyaml                    5.4.1            py39h3811e60_0    conda-forge
readline                  8.1                  h27cfd23_0
requests                  2.26.0             pyhd8ed1ab_0    conda-forge
requests-oauthlib         1.3.0              pyh9f0ad1d_0    conda-forge
rsa                       4.7.2              pyh44b312d_0    conda-forge
scipy                     1.6.2            py39h91f5cce_0
setuptools                58.0.4           py39h06a4308_0
six                       1.16.0             pyhd3eb1b0_0
sqlite                    3.36.0               hc218d9a_0
tensorboard               2.6.0              pyhd8ed1ab_1    conda-forge
tensorboard-data-server   0.6.0            py39h3da14fd_0    conda-forge
tensorboard-plugin-wit    1.8.0              pyh44b312d_0    conda-forge
tk                        8.6.11               h1ccaba5_0
torchmetrics              0.5.1              pyhd8ed1ab_0    conda-forge
torchvision               0.11.1                 py39_cpu  [cpuonly]  pytorch
tqdm                      4.62.3             pyhd8ed1ab_0    conda-forge
typing-extensions         3.10.0.2             hd3eb1b0_0
typing_extensions         3.10.0.2           pyh06a4308_0
tzdata                    2021a                h5d7bf9c_0
urllib3                   1.26.7             pyhd8ed1ab_0    conda-forge
werkzeug                  2.0.1              pyhd8ed1ab_0    conda-forge
wheel                     0.37.0             pyhd3eb1b0_1
xz                        5.2.5                h7b6447c_0
yaml                      0.2.5                h516909a_0    conda-forge
yarl                      1.6.3            py39h3811e60_2    conda-forge
zipp                      3.6.0              pyhd8ed1ab_0    conda-forge
zlib                      1.2.11               h7b6447c_3
zstd                      1.4.9                haebb681_0

Could you please help me with resolving the issue?


Solution 1:

Seems you have the wrong combination of PyTorch, CUDA, and Python version, you have installed PyTorch py3.9_cpu_0 which indicates that it is CPU version, not GPU. What I see is that you ask or have installed for PyTorch 1.10.0 which so far I know the Py3.9 built with CUDA 11 support only. See list of available (compiled) versions for CUDA 10.2 and CUDA 11.3.