This guide installs an NVIDIA GeForce RTX 3060 on Ubuntu for machine-learning work and verifies that Python frameworks can use it. The original step list is kept below; the added sections explain how the driver, CUDA and frameworks fit together and how to troubleshoot a failed install.
Before installing the NVIDIA drivers, update your system and install the necessary packages.
sudo apt update
sudo apt upgrade
Install required build tools and headers:
sudo apt install build-essential linux-headers-$(uname -r)
Add the official NVIDIA PPA to get the latest drivers:
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt update
Find the recommended driver for your GPU using the following command:
ubuntu-drivers devices
The output will suggest the best driver for your system. For example, it may recommend nvidia-driver-560.
Replace nvidia-driver-xxx with the recommended driver, such as nvidia-driver-560:
sudo apt install nvidia-driver-560
Reboot your machine to apply the changes:
sudo reboot
If you plan to use CUDA for GPU computing, you can install it using the following command:
sudo apt install nvidia-cuda-toolkit
After rebooting, you can check if the driver is installed and working properly by running:
alias nv1='nvtop'
alias nv2='nvidia-smi'
This will display details about your installed GPU and the driver version.
Insecure origins treated as secure: http://192.168.1.190:8080/
chrome://flags/
The RTX 3060 is an Ampere-generation consumer GPU; the common desktop model has 12 GB of GDDR6 memory, which is generous for its class and makes it a popular entry card for local fine-tuning of small models, Stable Diffusion, and running quantised language models. Using it from Python needs a layered stack. At the bottom is the proprietary NVIDIA kernel driver, which also installs libcuda and the nvidia-smi tool. Above it sits the CUDA runtime and math libraries (cuBLAS, cuDNN), and on top the framework. A key point that saves a lot of confusion: the driver is the only piece that must match the system. Frameworks installed with pip ship their own CUDA runtime, and they work as long as the driver is new enough for that runtime version. The nvidia-cuda-toolkit package in Step 3 is only needed to compile CUDA code yourself.
Work bottom-up and verify each layer before moving on. Install headers and build tools so the kernel module can be built through DKMS, install the recommended driver, and reboot. Then confirm nvidia-smi lists the GPU, its memory and the driver version; the "CUDA Version" it prints is the highest CUDA runtime the driver supports, not an installed toolkit. Only then create a virtual environment and install a CUDA-enabled framework build. Secure Boot can block the unsigned module; Ubuntu prompts to enrol a Machine Owner Key during installation, and that step must be completed at the next boot.
# driver layer
nvidia-smi --query-gpu=name,memory.total,driver_version --format=csv
lsmod | grep nvidia
# framework layer
python3 -m venv ~/venv-gpu && source ~/venv-gpu/bin/activate
pip install torch # default Linux wheel includes CUDA support
import torch
print("torch", torch.__version__, "built for CUDA", torch.version.cuda)
print("GPU available:", torch.cuda.is_available())
if torch.cuda.is_available():
print(torch.cuda.get_device_name(0))
free, total = torch.cuda.mem_get_info()
print(f"memory free {free/2**30:.1f} GiB of {total/2**30:.1f} GiB")
a = torch.randn(4096, 4096, device="cuda")
b = a @ a.T # runs a cuBLAS matmul on the GPU
torch.cuda.synchronize()
print("matmul ok:", b.shape)
If the last line prints, every layer works: driver, bundled CUDA runtime, cuBLAS and the framework. nvtop (aliased as nv1 above) shows live utilisation and memory while the matmul runs.
| Option | Pros | Cons |
|---|---|---|
| Ubuntu repository driver (ubuntu-drivers) | Signed, tested with the kernel, simplest | May lag the newest release |
| graphics-drivers PPA | Newer drivers | Less tested; occasional breakage on kernel upgrades |
| NVIDIA .run installer | Latest version | Bypasses the package manager; breaks on kernel updates |
| System CUDA toolkit | Needed for nvcc and custom kernels | Not required for pip-installed frameworks |
| Docker with NVIDIA Container Toolkit | Isolated CUDA versions per project | Extra layer; host still needs the driver |