In this post, I’m gonna describe the steps I used to make Pytorch use GPU on my laptop (It takes me about half a day to find the steps).
Generally, you should check compatibility of several things:
Check Cuda and Nvidia GPU drivers compatibility at:
https://docs.nvidia.com/deploy/cuda-compatibility/index.html
Here is the important table:
CUDA Toolkit | Linux x86_64 Driver Version |
CUDA 11.1 (11.1.0) | >= 450.80.02 |
CUDA 11.0 (11.0.3) | >= 450.36.06 |
CUDA 10.2 (10.2.89) | >= 440.33 |
CUDA 10.1 (10.1.105) | >= 418.39 |
CUDA 10.0 (10.0.130) | >= 410.48 |
CUDA 9.2 (9.2.88) | >= 396.26 |
CUDA 9.1 (9.1.85) | >= 390.46 |
CUDA 9.0 (9.0.76) | >= 384.81 |
CUDA 8.0 (8.0.61 GA2) | >= 375.26 |
CUDA 8.0 (8.0.44) | >= 367.48 |
CUDA 7.5 (7.5.16) | >= 352.31 |
CUDA 7.0 (7.0.28) | >= 346.46 |
Check Pytorch compatibility at:
https://pytorch.org/get-started/previous-versions/
Based on my system configuration I decide to install the following versions:
Cuda: 10.1
GPU Driver: 418.56
Pytorch: 1.6.0 / Torchvision: 0.7.0
Install appropriate version of your GPU using one of the following options:
sudo apt install nvidia-418
nvidia-smi
. It must show something like the following:Download and install the proper Cuda Tool kit version from https://developer.nvidia.com/cuda-toolkit-archive and then reboot. Specifically I download Cuda 10.1 toolkit from https://developer.nvidia.com/cuda-10.1-download-archive-base?target_os=Linux&target_arch=x86_64&target_distro=Ubuntu&target_version=1604&target_type=runfilelocal
and install the .run file by:
sudo sh cuda_10.1.105_418.39_linux.run
Install the appropriate Pytorch version from:
https://pytorch.org/get-started/previous-versions/
I have installed using the following command:
pip install torch==1.6.0+cu101 torchvision==0.7.0+cu101 -f https://download.pytorch.org/whl/torch_stable.html
Enjoy GPU Power!