Nvidia
Cuda
Linux
If you are new on install Nvidia stuff on Ubuntu, you may sometimes find out: why there are errors like "something version not match", or the command nvidia-smi is just not working, this guide will guide you though to fix the problem and configurate it correctly without that thick as **** Nvidia installation guide.
Try to remove all nvidia related package with the below command:
It might encouter error when try to remove them, or install Cuda after removing them, then it might require you to run:
Just install this package with one command, do not install any other nvidia driver, like nvidia-510 or some other similar thing, which can ensure the Driver and Library's version is matched, they will install the related driver and library themselves with the correct matching version:
Finally, ensure you have disable the auto update from the OS, because it will update the nvidia driver, and will causing the driver version as it would usually mis-match with the Cuda version, and crashed heavily.
To do so, run the below command to edit the file /etc/apt/apt.conf.d/20auto-upgrades:
Then comment out all the lines you see there, and edit the file as:
Then save and quit, it should disable all the update in the OS now, and for the security safety, you need to do the manually upgrade afterward with:
And everytime after the update, it may crash the Cuda again, so you better check it buy running the command below and see if it runs correctly without errors:
Or, you may want the unattanded update be active to apply all the security patch, just not those Nvidia stuff.
To do so, run the below command to edit the file /etc/apt/apt.conf.d/50unattended-upgrades, there should be some lines called "Unattended-Upgrade::Package-Blacklist", editing the lines to look like this and save:
You may also need to consider adding additional lines if you see any other NVIDIA driver names in the output of the command:
Although it is not nessuary, because update all the server packages means you always needs to overlook all the package being update and test, instead of Nvidia stuff only. Some poeple may just want it for specific purpose.
To do so, all you need to use is: apt-mark
For example, if you need to onhold cuda from its update, you may enter the command:
And release it with:
This should much easier to editing APT Preferences File instead for the same purpose. apt-mark support fnmatch() and regex format for the package name as well.
For more information, you may take a look with:
https://www.tecmint.com/disable-lock-blacklist-package-updates-ubuntu-debian-apt/