Skip to content

Instantly share code, notes, and snippets.

@DaneGardner
Last active February 25, 2025 14:22
Show Gist options
  • Save DaneGardner/accd6fd330348543167719002a661bd5 to your computer and use it in GitHub Desktop.
Save DaneGardner/accd6fd330348543167719002a661bd5 to your computer and use it in GitHub Desktop.
Installing CUDA 9.1 on Ubuntu 18.04 (circ. 5/18)

Install CUDA 9.1 on Ubuntu 18.04

Prep system

sudo apt install build-essential gcc-6 g++-6

sudo update-alternatives --remove-all gcc
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 10
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 20
sudo update-alternatives --set gcc /usr/bin/gcc-6

sudo update-alternatives --remove-all g++
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-6 10
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 20
sudo update-alternatives --set g++ /usr/bin/g++-6

Install Nvidia driver

sudo modprobe -r nouveau
sudo apt install nvidia-driver-390 nvidia-headless-390 nvidia-utils-390
sudo modprobe -i nvidia

Install CUDA toolkit

pushd /tmp/

curl -LO https://developer.nvidia.com/compute/cuda/9.1/Prod/local_installers/cuda_9.1.85_387.26_linux
curl -LO https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/1/cuda_9.1.85.1_linux
curl -LO https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/2/cuda_9.1.85.2_linux
curl -LO https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/3/cuda_9.1.85.3_linux

# do not install driver or samples
sudo sh cuda_9.1.85_387.26_linux --silent --override --toolkit

# install the patches
sudo sh cuda_9.1.85.1_linux --silent --accept-eula
sudo sh cuda_9.1.85.2_linux --silent --accept-eula
sudo sh cuda_9.1.85.3_linux --silent --accept-eula

# set system wide paths
echo 'PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/local/cuda/bin"' | sudo tee /etc/environment
echo /usr/local/cuda-9.1/lib64 | sudo tee /etc/ld.so.conf.d/cuda-9.1.conf
sudo ldconfig

rm /tmp/cuda_9.1.85*_linux
popd

Check that it's working

# reboot system for changes to take effect
sudo reboot

lsmod | grep nouv && echo FAIL || echo OKAY
lsmod | grep nvid && echo OKAY || echo FAIL

grep -E 'NVIDIA.*390.[0-9]+' /proc/driver/nvidia/version &>/dev/null && echo OKAY || echo FAIL
nvcc -V | grep -E "V9.1.[0-9]+" &>/dev/null && echo OKAY || echo FAIL

# this should return stats for all installed cards
nvidia-smi

Optional Fans Speed Settings

sudo apt install xorg lightdm

# reconfigure Xorg server for installed devices
/usr/sbin/service lightdm stop
/usr/bin/nvidia-xconfig -a --cool-bits=12 --allow-empty-initial-configuration --preserve-busid --no-allow-glx-with-composite --no-add-argb-glx-visuals
/usr/sbin/service lightdm start
/usr/sbin/service lightdm status

export DISPLAY=:0
export XAUTHORITY=/var/run/lightdm/root/${DISPLAY}
/usr/bin/nvidia-settings -a GPUFanControlState=1 -a GPUTargetFanSpeed=75
@pcamp96
Copy link

pcamp96 commented Feb 25, 2025

Any chance of this working on 24.04? Trying to get my Quadro P4000 working in Ubuntu 24.04 to use for Plex transcoding and, well, it's not too happy without CUDA.

@DaneGardner
Copy link
Author

Any chance of this working on 24.04? Trying to get my Quadro P4000 working in Ubuntu 24.04 to use for Plex transcoding and, well, it's not too happy without CUDA.

If Plex will work with such an old version of CUDA, it might be worth trying if you can't get newer versions working. Let us know how it goes if you give it a try!

@pcamp96
Copy link

pcamp96 commented Feb 25, 2025

Any chance of this working on 24.04? Trying to get my Quadro P4000 working in Ubuntu 24.04 to use for Plex transcoding and, well, it's not too happy without CUDA.

If Plex will work with such an old version of CUDA, it might be worth trying if you can't get newer versions working. Let us know how it goes if you give it a try!

I spent the better part of 6+ hours yesterday trying to get it to work and I couldn't get CUDA to properly install on the system. I was able to get the 390 drivers working, and nvidia-smi showed the card, but without CUDA or the toolkit installed it was all but useless on the system.

I'm gonna end up selling the P4000 and going with the GTX 1650 that I have in another system instead. It has more modern drivers and should more easily work.

Thanks for the reply though! I wished I could have got the P4000 working, it would have been killer for Plex transcoding lol.

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