You can also install CUDA directly from the offline installer, but this is a little easier.
sudo apt update
sudo apt upgrade -y
mkdir install ; cd install
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-ubuntu1804.pin