Notes on getting CUDA running on ubuntu 16.04LTS for a GeForce GT730

I appear to have gotten CUDA working.
Here are some notes on what does and doesn’t work for a legacy card.
1: I never got it working on 18.04LTS or 20.04LTS because the versions of the CUDA toolkit it installed were too modern and overwrote the 390.xx driver required for the GT730 with a more recent driver.
2: when I used meta packages to disallow installation of a newer driver, it still didn’t work because the version of gcc on post-16.04 is higher than the compiler directives for the 390.xx module. It is possible to install multiple instances of gcc and use apt update-alternatives (see but I did not get this to actually work.
So stick with 16.04LTS.
I used Problem installing NVIDIA 390.42 driver on Ubuntu 16.04 specifically the suggestions of installing cuda, then adding the ppa, then installing the driver. This didn’t work because apt couldn’t find the appropriate 390 driver in the given sources, and trying to download the file directly from nvidia had conflicts with a driver that the CUDA installation through dpkg had already installed. Purging the already installed driver also purged CUDA.
At the bottom of the page, someone else suggested a way to get this working on 18.04LTS, that didn’t work when I tried it on 18.04 but did work on 16.04LTS:
download the 390 driver (but not from the PPA because apt can’t find it: I used the 390.132 downloaded directly from nvidia)
remove/blacklist the nouveau driver:
go into single user mode, shut down xwindows via service lightdm stop, then execute the driver .run file
then download the cuda .deb, update sources, and apt-get install cuda toolkit, as in the example.

The nvidia documentation may be correct for 10.xx versions of cuda but is not for 9.1: nsight is located in /usr/local/cuda-9.1/bin and can be run by ./nsight. Its version number matches the cuda toolkit version number, for when you’re setting up your $PATH.