Skip to content
ubuntu setup pytorch env
2025年3月13日 root

clear cuda old driver

shell
sudo apt-get purge nvidia-*
sudo apt-get purge cuda*
sudo apt autoremove

install cuda

go to: https://developer.nvidia.com/cuda-toolkit-archive choose your version, such as install 11.7:

shell
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.0-1_all.deb
sudo dpkg -i cuda-keyring*.deb
sudo apt-get update
sudo apt-get -y install cuda

show cuda version

shell
nvcc --version

show cuda status

shell
nvidia-smi -l 1

install cunn

go to: https://developer.nvidia.com/rdp/cudnn-download choose cudnn version which mathed cuda version, such as 11.x:

shell
wget https://developer.nvidia.com/downloads/c118-cudnn-local-repo-ubuntu2204-8708410-1amd64deb
sudo cp /var/cudnn-local-repo-*/cudnn-local-*-keyring.gpg /usr/share/keyrings/
sudo apt-get install libcudnn8 libcudnn8-dev libcudnn8-samples

install pytoch

go to: https://pytorch.org/get-started/locally/ choose pytorch version which mathed cuda version, such as 1.13:

shell
wget https://download.pytorch.org/libtorch/cu117/libtorch-cxx11-abi-shared-with-deps-1.13.0%2Bcu117.zip

reboot

shell
sudo reboot

Last updated: