Install pytorch with CUDA 11


I am trying to install pytorch via anaconda in Ubuntu 20.04 with CUDA 11.

However, I didn’t find the installation option for CUDA 11 on the “Get started” webpage.

Does that mean I have to go back to CUDA 10.2?



I am also facing the same dilemma. Let me know, if, you figured out a workaround solution.

1 Like

me too.
If not yet available, when planning to support CUDA 11?

The binaries are not built yet and you would have to install PyTorch from source at the moment.

CC @Santhosh_Kumar1, @bear_sun


I successfully build PyTorch from source with CUDA 11. However, I still got:

➜  pytorch python
Python 3.8.2 (default, Jul 16 2020, 14:00:26) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> torch.cuda
<module 'torch.cuda' from '/home/jiapei/.local/lib/python3.8/site-packages/torch/cuda/'>
>>> torch.cuda.is_available()
>>> print(torch.version.cuda)
>>> torch.backends.cudnn.enabled

Clearly, the output of torch.cuda.is_available() returned False, which is incorrect.

Any further suggestions?

Your driver might be too old, as CUDA11 needs >= 450.36.06.

1 Like


⋊> ~ nvidia-smi                                                                                                                                                                                       09:56:01
Wed Aug 19 09:56:04 2020       
| NVIDIA-SMI 450.57       Driver Version: 450.57       CUDA Version: 11.0     |
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|   0  GeForce GTX 105...  Off  | 00000000:01:00.0 Off |                  N/A |
| N/A   37C    P8    N/A /  N/A |   1439MiB /  4042MiB |     17%      Default |
|                               |                      |                  N/A |

Could you post the install log, so that we can have a look, if CUDA was successfully detected?

Hi, @ptrblck

In fact, even now, I’m NOT sure how to install PyTorch correctly. For me, I’ve got to build twice, one using cmake, the other python build etc.

Under ./build/CMakeFiles, there are 2 .log files:

Any suggestions?

Unfortunately, I cannot access the files. The install log would be still helpful.
The build instructions can be found here.

I tried running this command conda install pytorch==1.6.0 cudatoolkit=11.0 -c pytorch with python v3.7.10, Nvidia-driver 450.119.03 and CUDA version 11.0.

But the problem is torch.cuda.is_available() is returning False and torch.cuda.version is returning None.

It showed me the following logs:

added / updated specs:                                                                                                                                      
    - cudatoolkit=11.0                                                                                                                                        
    - pytorch==1.6.0                                                                                                                                          
The following packages will be downloaded:                                                                                                                    
    package                    |            build                                                                                                             
    cudatoolkit-11.0.3         |       h15472ef_8       951.9 MB  conda-forge                                                                                 
                                           Total:       951.9 MB                                                                                              
The following NEW packages will be INSTALLED:                                                                                                                 
  cffi               conda-forge/linux-64::cffi-1.14.5-py37hc58025e_0                                                                                         
  cudatoolkit        conda-forge/linux-64::cudatoolkit-11.0.3-h15472ef_8
  future             conda-forge/linux-64::future-0.18.2-py37h89c1867_3
  libblas            conda-forge/linux-64::libblas-3.9.0-8_mkl
  libcblas           conda-forge/linux-64::libcblas-3.9.0-8_mkl
  liblapack          conda-forge/linux-64::liblapack-3.9.0-8_mkl
  llvm-openmp        conda-forge/linux-64::llvm-openmp-11.1.0-h4bd325d_1
  mkl                conda-forge/linux-64::mkl-2020.4-h726a3e6_304
  ninja              conda-forge/linux-64::ninja-1.10.2-h4bd325d_0
  numpy              conda-forge/linux-64::numpy-1.21.0-py37h038b26d_0
  pycparser          conda-forge/noarch::pycparser-2.20-pyh9f0ad1d_2
  pytorch            conda-forge/linux-64::pytorch-1.6.0-cpu_py37hf1c21f6_1
  typing_extensions  conda-forge/noarch::typing_extensions-

The following packages will be DOWNGRADED:

  _openmp_mutex                                   4.5-1_gnu --> 4.5-1_llvm

Proceed ([y]/n)? y

Any suggestions?

1 Like

You are installing the CPU version as shown in the logs, since 1.6.0 didn’t ship with cudatoolkit=11.0.


Yeah, I had to install pytorch 1.7.0 which worked fine.

Command I used:

conda install pytorch==1.7.0 cudatoolkit=11.0 -c pytorch

I meet the same problem ,just using mmdetection, the terminal shows : The detected CUDA version (11.0) mismatches the version that was used to compile
PyTorch (10.2). Please make sure to use the same CUDA versions.

To build custom CUDA extensions your local CUDA toolkit will be used and should match the used CUDA runtime shipped in the pip wheels / conda binaries. Install the CUDA11 wheels and it should work.

Thank you! I just want to learn the relation of the cuda,pytorch,cudann,cudatoolkit,where can I see that?

You can print the different versions using print( and would see the used CUDA runtime, cuDNN etc.

Although the original question is on Ubuntu, I had this problem on windows 11.


Tue May 24 21:51:38 2022       
| NVIDIA-SMI 516.01       Driver Version: 516.01       CUDA Version: 11.7     |     
| GPU  Name            TCC/WDDM | Bus-Id        Disp.A | Volatile Uncorr. ECC |     
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |     
|                               |                      |               MIG M. |     
|   0  NVIDIA GeForce ... WDDM  | 00000000:01:00.0 Off |                  N/A |
| N/A   33C    P5    17W /  N/A |      0MiB /  6144MiB |      0%      Default |     
|                               |                      |                  N/A |     

| Processes:                                                                  |     
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |     
|        ID   ID                                                   Usage      |     
|  No running processes found                                                 |

nvcc --version

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2022 NVIDIA Corporation
Built on Tue_May__3_19:00:59_Pacific_Daylight_Time_2022
Cuda compilation tools, release 11.7, V11.7.64
Build cuda_11.7.r11.7/compiler.31294372_0

Here is how I solved the problem:

  • I updated Anaconda : I switched to the latest version, and rebooted my computer after the installation.
  • I chose the last version of pytorch here
conda create -n global_env
conda activate global_env
conda install pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch
import torch
print(torch.cuda.is_available(), torch.version.cuda, torch.backends.cudnn.enabled)

True 11.3 True