How to Install PyTorch on Ubuntu 22.04 with Nvidia Graphics Card
PyTorch is an open-source machine learning library based on the Torch library. It is widely used for building deep learning models and is supported by a large community of developers. If you are using Ubuntu 22.04 with an Nvidia graphics card and want to install PyTorch, follow the steps below.
Step 1: Install Nvidia Graphics Drivers
The first step is to install the Nvidia graphics drivers on your system. Open a terminal and run the following command:
sudo apt install nvidia-driver-470
Replace “470” with the version of the Nvidia driver you want to install. Once the installation is complete, reboot your system to apply the changes.
Step 2: Install CUDA Toolkit
PyTorch requires CUDA support for GPU-accelerated computations. Install the CUDA toolkit using the following command:
sudo apt install nvidia-cuda-toolkit
After installing the CUDA toolkit, verify the installation by running the following command:
nvidia-smi
You should see information about your Nvidia graphics card, indicating that the CUDA toolkit is installed and working correctly.
Step 3: Install PyTorch
Now that the Nvidia graphics drivers and CUDA toolkit are installed, you can proceed to install PyTorch. The recommended way to install PyTorch is using the pip package manager. Run the following command to install PyTorch with GPU support:
pip install torch torchvision torchaudio
This command will install the latest version of PyTorch with support for CUDA-enabled GPUs. You can now start using PyTorch to build and train deep learning models on your Ubuntu 22.04 system with Nvidia graphics card.
Conclusion
In this article, we covered the steps to install PyTorch on Ubuntu 22.04 with an Nvidia graphics card. By following these steps, you can set up your system for deep learning tasks using PyTorch with GPU acceleration. Make sure to regularly update your Nvidia drivers and PyTorch installation to access the latest features and performance improvements.
stuck on sudo sh cuda_12.3.0_545.23.06_linux.run after entering the command, the next screen shows up but is broken.
mine is still showing false on checking the availability, what should i do pls help
thank you very much!!!
Thank youuu
thank you so much man.this is perfect
thanks man, toda raba. You saved me hours. It worked perfectly!:)
is there no CUDA support for Gtx 1650ti Notebook Version?
how to install the specific version of pytorch gpu and torchvision from pip in the terminal too? thank you.
very good and short guide, no fluff or time-waste
Why the NVIDIA driver is so brittle with Ubuntu? My NVIDIA+CUDA environment can't work again ! This kind of stuff is really really dirty and annoying for me.
Best one yet!