Last active
August 7, 2019 08:58
-
-
Save cloudhan/f4b37344b15ccc008d7631a4cc46e5ac to your computer and use it in GitHub Desktop.
Upgrade old nvidia driver
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
RED='\033[0;31m' | |
GREEN='\033[0;32m' | |
NC='\033[0m' | |
set -ev | |
echo -e "${GREEN}Downloading and installing nvidia repo${NC}" | |
wget http://developer.download.nvidia.cn/compute/cuda/repos/ubuntu1604/x86_64/cuda-repo-ubuntu1604_10.0.130-1_amd64.deb | |
wget http://developer.download.nvidia.cn/compute/machine-learning/repos/ubuntu1604/x86_64/nvidia-machine-learning-repo-ubuntu1604_1.0.0-1_amd64.deb | |
sudo dpkg -i cuda-repo-ubuntu1604_10.0.130-1_amd64.deb nvidia-machine-learning-repo-ubuntu1604_1.0.0-1_amd64.deb | |
echo -e "${GREEN}Updating nvidia driver${NC}" | |
sudo apt-get update && sudo apt-get install cuda-drivers cuda-10-0 cuda-8-0 | |
sudo systemctl isolate multi-user.target | |
sudo systemctl stop lightdm | |
sudo rmmod --force nvidia_uvm nvidia_drm nvidia_modeset nvidia | |
if [[ `lsmod | grep ^nvidia | wc -l` -gt 0 ]]; then | |
echo -e "${RED} Failed to clean nvidia kernal module, Abort!${NC}" | |
exit -1 | |
fi | |
echo -e "${GREEN}Successfully unload all nvidia kernel module${NC}" | |
echo -e "${GREEN}Restoring system status${NC}" | |
sudo systemctl start graphical.target | |
sudo systemctl start lightdm | |
echo -e "${GREEN}Reloading nvidia driver${NC}" | |
nvidia-smi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If old kernel module unload failed, use
lsof /dev/nvidia*
to check what is using them and manually do it.refers to https://stackoverflow.com/a/45319156/2091555 for more information.