How to re-install Nvidia/CUDA on Ubuntu 14 machine?

This situation is complicated. I’m running Ubuntu 14.05 and I previously had the Nvidia drivers installed and working. I think it was CUDA version 7-5.18. Everything worked. Then I moved the machine to a location with no internet access. When I rebooted, the standard non-Nvidia driver was used. The Nvidia driver is no longer started. Why? Because the Ubuntu Software Updater breaks things and I only learned after I moved since I don’t reboot the machine every time the Ubuntu Software Updater asks.

The problem is really with the Ubuntu Updater, not Nvidia, but that’s not the problem I’m trying to solve.

My question is this. How can I either re-enable the existing Nvidia driver on that machine, which is not connected to the internet? Is that possible?

Or, how can I re-install the Nvidia driver? I tried to re-install but it complained that it could not find the kernel source code. I asked on the Ubuntu forums, and nobody knows what’s going on there, but it’s possible that a kernel update occurred.

Anyway, can I somehow install or re-enable the Nvidia drivers on this machine which is no longer connected to the internet?

download the appropriate runfile installer from CUDA Toolkit 11.7 Update 1 Downloads | NVIDIA Developer
Put it on a USB key
carry it to your ubuntu machine
transfer it to the machine

follow the instructions in the installation guide to:

  1. clean out the old package manager install
  2. install using the runfile installer method

As I explained, I tried to re-install with the appropriate runtime installer and failed. The complaint was something like:

The driver installation is unable to locate the kernel source. Please make sure that the kernel source packages are installed and set up correctly.

The runtime file is cuda_7.5.18_linux.run

You may need to reconnect that machine to the internet then. Either to use the runfile installer method and load the kernel headers, or to use the package manager method which will almost certainly require packages.

If you want to do a fresh load of Ubuntu from an install DVD, then it should probably not be necessary to connect it to the internet. Everything you need for the runfile installation will be available on the install DVD.

I did connect the machine to the internet. I did “apt-get source linux-source” and tried to build, but the install still fails. Are there any ideas on how to install the Nvidia driver on this machine?