error : Torch not compiled with CUDA enabled
Asked Answered
G

2

11

When I run "torch.rand(10).to("cuda")", I face "error : Torch not compiled with CUDA enabled"

GPU : Nvidia RTX 3080 Ti

$nvidia-smi

+-----------------------------------------------------------------------------+
| NVIDIA-SMI 525.85.05    Driver Version: 525.85.05    CUDA Version: 12.0     |
|-------------------------------+----------------------+----------------------+
$nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2017 NVIDIA Corporation
Built on Fri_Nov__3_21:07:56_CDT_2017
Cuda compilation tools, release 9.1, V9.1.85
$conda list

cudatoolkit   version  :  11.0.221

$conda info


active environment : sw
    active env location : /mnt/user2/.conda/envs/sw
            shell level : 1
       user config file : /mnt/user2/.condarc
 populated config files :
          conda version : 23.1.0
    conda-build version : not installed
         python version : 3.10.9.final.0
       virtual packages : __archspec=1=x86_64
                          __glibc=2.27=0
                          __linux=5.4.0=0
                          __unix=0=0
       base environment : /opt/conda  (read only)
      conda av data dir : /opt/conda/etc/conda
  conda av metadata url : None
           channel URLs : https://repo.anaconda.com/pkgs/main/linux-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/r/linux-64
                          https://repo.anaconda.com/pkgs/r/noarch
          package cache : /opt/conda/pkgs
                          /mnt/user2/.conda/pkgs
       envs directories : /mnt/user2/.conda/envs
                          /opt/conda/envs
               platform : linux-64
             user-agent : conda/23.1.0 requests/2.28.1 CPython/3.10.9 Linux/5.4.0-144-generic ubuntu/18.04.6 glibc/2.27
                UID:GID : 1002:1001
             netrc file : None
           offline mode : False

torch ver : 2.0.0

I download pytorch

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

I'm confused to identify cuda version. nvidia-smi says cuda is 12.0 but the sheet from conda list says cuda is 11.0.221 but nvcc-V says cuda 9.1.

If you need more information, please comments.


Searching google to solve the problem but didn't work.

Galata answered 16/3, 2023 at 5:37 Comment(1)
pytorch.org/get-started/locallyConcur
U
17

What helped me was to uninstall the torch using pip and install it again using the pip instead of conda.

pip uninstall torch
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
Utile answered 16/3, 2023 at 13:0 Comment(3)
I tried to uninstall torch and install torch but terminal says requirement already satisfied. And in the jupyter shell, doesn't import torch after pip install torch...Galata
plus, follow the choices on page: pytorch.org then copy the command line.Chronopher
ERROR: Could not find a version that satisfies the requirement torch (from versions: none)Anthemion
A
0

First, you need to check if you have any versions of CUDA installed. Go to your environment variables and check if you have any other versions installed. If you have more than one (for me, I had CUDA 11.2 and CUDA 12.1, and I deleted 11.2 because it is not compatible with torch), delete the version you don't need.

Then, run the following commands:

pip uninstall torch torchvision torchaudio

pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121
Alphosis answered 20/5 at 11:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.