Days are gone when installing CUDA driver was a hazzle. We can now simply install it with apt install. And for cuda toolkit, one can simply install by
apt install nvidia-cuda-toolkit
However, apt install does not install samples. We can install from run file explicitly.
wget http://developer.download.nvidia.com/compute/cuda/10.1/Prod/local_installers/cuda_10.1.243_418.87.00_linux.run sudo sh cuda_10.1.243_418.87.00_linux.run # do not install driver and toolkit
When running the sample, we should set CUDA_PATH to /usr. That is,
CUDA_PATH=/usr make #In an example
The header files in the samples are sometimes needed for some CUDA relying packages such as Libfreenect2. We can include the header path by
export CPATH=$CPATH:$HOME/NVIDIA_CUDA-10.1_Samples/common/inc
Update:
This is kind of ok but will not install the latest cuda version. Probably still need to download cuda from Nvidia website for the latest version.