Installing PyTorch on Ubuntu 22.04 with Nvidia GPU: A Step-by-Step Guide

Posted by

How to Install PyTorch on Ubuntu 22.04 with Nvidia Graphics Card

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.

0 0 votes
Article Rating
11 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
@kylanjohnsonmusic
10 months ago

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.

@user-sk6od1wb4r
10 months ago

mine is still showing false on checking the availability, what should i do pls help

@user-vj5zq5zw3f
10 months ago

thank you very much!!!

@drewthomasson949
10 months ago

Thank youuu

@user-xt6gj3bx3v
10 months ago

thank you so much man.this is perfect

@annashchukina3768
10 months ago

thanks man, toda raba. You saved me hours. It worked perfectly!:)

@topicNet
10 months ago

is there no CUDA support for Gtx 1650ti Notebook Version?

@aykutsirma
10 months ago

how to install the specific version of pytorch gpu and torchvision from pip in the terminal too? thank you.

@user-yn5po3oe5j
10 months ago

very good and short guide, no fluff or time-waste

@zhongzhongclock
10 months ago

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.

@HyperJasonFlorr
10 months ago

Best one yet!