Hi Jessie Li,
don’t worry, we’ll figure it out step by step. first off, thanks for throwing this question out there ubuntu 22.04 is a solid choice, but yeah, the driver setup can get messy if things don’t line up just right.
ok, let’s start fresh. u gotta make sure u have the right nvidia drivers installed. open up a terminal and run sudo apt update
to get everything up to date. then, check if u have any old drivers hanging around with sudo apt purge nvidia*
this cleans up any leftovers that might cause trouble.
next, u want add the official nvidia repo to ur system. run sudo add-apt-repository ppa:graphics-drivers/ppa
and hit enter. then sudo apt update
again. now, u can install the latest drivers with sudo apt install nvidia-driver-535
(or whatever version is current—check nvidia’s site for the latest stable one nvidia driver docs). reboot after this with sudo reboot
, and when u come back, run nvidia-smi
to see if the drivers are working. if u see a table with gpu info, u’re golden ;)
now for cuda. u can grab it straight from nvidia’s site cuda toolkit docs. download the runfile for ubuntu 22.04 and run it with sudo sh cuda_*.run
. make sure u don’t install the bundled drivers just the toolkit and maybe the samples if u want them. after it’s done, add cuda to ur path by editing ~/.bashrc
and adding export PATH=/usr/local/cuda/bin:$PATH
and export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
. then run source ~/.bashrc
to apply it. check if cuda works with nvcc --version
it should spit out the version number.
finally, pytorch. this part’s easier )) head over to pytorch’s official site and grab the command for linux with cuda support. usually, it’s something like pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
. make sure the cuda version matches what u installed earlier. after that, fire up python and try import torch
followed by torch.cuda.is_available()
. if it says True
, congrats u did it )))
if anything fails along the way, check the error messages carefully.
LMK if some my advise is help.
Alex
and "yes" if you would follow me at Q&A - personaly thx.
P.S. If my answer help to you, please Accept my answer
PPS That is my Answer and not a Comment
https://ctrlaltdel.blog/