CUDA Development Introduction

Warning! This page is still under construction!

Step 1. Get ready for bullshittery

It is normal for nvidia drivers to break Your system, or even not install at all. Have hammer by Your side, in case You would need to kill Your machine quickly.

Disable Nouveau

As per How to disable Nouveau kernel driver

echo "blacklist nouveau" > /etc/modprobe.d/blacklist-nouveau.conf
echo "options nouveau modeset=0" >> /etc/modprobe.d/blacklist-nouveau.conf

update-initramfs -u

reboot
    

Make sure Ubuntu sees GPU and install driver

# Check PCI devices
lspci

# Check drivers for Your GPU
sudo ubuntu-drivers devices

# Install newest driver for Your GPU
sudo apt install nvidia-driver-470-server

# Reboot to load new kernel
reboot

# Check if driver works
nvidia-smi
    

Installing CUDA Toolkit

# Install CUDA Toolkit
sudo apt install nvidia-cuda-toolkit

# Check if nvcc works
nvcc
    

Getting started with CUDA C/C++

Check out CUDA Tutorial and CUDA by Example.