Skip to content

Instantly share code, notes, and snippets.

@debaraj-barua
Last active June 18, 2021 10:41
Show Gist options
  • Save debaraj-barua/daedb797e0a818e31ada10b940d1818c to your computer and use it in GitHub Desktop.
Save debaraj-barua/daedb797e0a818e31ada10b940d1818c to your computer and use it in GitHub Desktop.
How to make hybrid graphics running Ubuntu 16.04 play nice with nvidia drivers and CUDA?

with Ubuntu 18.04 and higher, this might be useful: https://askubuntu.com/questions/61396/how-do-i-install-the-nvidia-drivers/61433#61433

However, it seems that contrary to what the ubuntu-drivers devices | grep nvidia recommends, for Ubuntu 16.04, installing the latest recommended version of the driver (currently 430) does not play nice with X (maybe my kernal is not updated). And once I update the kernal I'll have to go through this all over again. So, better write shit down.

For now, following this

Removing earlier versions

NOTE: May remove CUDA installations as well*

sudo apt-get purge nvidia*
sudo apt-get autoremove

Install 375 version of the driver

sudo apt-get install nvidia-375 nvidia-modprobe

Install CUDA

Check pre-installation steps at NVIDIA docs.

Finally download the toolkit at http://developer.nvidia.com/cuda-downloads.

For installing CUDA 10.1 at Ubuntu 16.04, x86_64:

Installer used: deb(network)

wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/cuda-ubuntu1604.pin
sudo mv cuda-ubuntu1604.pin /etc/apt/preferences.d/cuda-repository-pin-600
sudo apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/7fa2af80.pub
sudo add-apt-repository "deb http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/ /"
sudo apt-get update
sudo apt-get -y install cuda

Post installation steps:

Add exports for environment variables to bashrc:

export PATH=/usr/local/cuda-10.1/bin:/usr/local/cuda-10.1/NsightCompute-2019.1${PATH:+:${PATH}}
export LD_LIBRARY_PATH="/usr/local/cuda-10.1/lib64:${LD_LIBRARY_PATH+${LD_LIBRARY_PATH}}"

Finally move CUDA out from root into home and create symlink to avoid path issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment