Last active
May 16, 2023 22:04
-
-
Save sergey-cheperis/6eb57493293f0e9f19f86e6031727528 to your computer and use it in GitHub Desktop.
Prevent NVIDIA driver from auto-updating and breaking vast.ai
This file contains hidden or 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 | |
# This script "pins" currently installed nvidia driver to prevent it from auto-updating and breaking running vast.ai services. | |
# It creates the file /etc/apt/preferences.d/nvidia-manual-pin. | |
# | |
# From time to time, you'll still need to update the driver manually. Only do this while no vast.ai jobs are running | |
# (except your default jobs). Follow these steps: | |
# | |
# 1. Stop vast.ai and related things: `systemctl stop vastai docker cron` | |
# 2. Remove the pin: `rm -f /etc/apt/preferences.d/nvidia-manual-pin` | |
# 3. Do the update: `apt dist-upgrade` | |
# 4. Reboot. | |
# 5. After rebooting, run this script again to pin the new version of the driver. | |
cat /proc/driver/nvidia/version | |
FULL_VERSION=`cat /proc/driver/nvidia/version | grep NVRM | egrep -o "[0-9]{3}\.[0-9]{2,3}\.[0-9]{2,3}"` | |
if [ x$FULL_VERSION == x ] | |
then | |
MINOR_VERSION=`cat /proc/driver/nvidia/version | grep NVRM | egrep -o "[0-9]{3}\.[0-9]{2,3}"` | |
if [ x$MINOR_VERSION == x ] | |
then | |
echo ERROR: could not determine version | |
exit 1 | |
fi | |
else | |
MINOR_VERSION=${FULL_VERSION%.*} | |
fi | |
MAJOR_VERSION=${MINOR_VERSION%.*} | |
echo Major: $MAJOR_VERSION, minor: $MINOR_VERSION | |
FILE=/etc/apt/preferences.d/nvidia-manual-pin | |
echo "Package: nvidia-*-$MAJOR_VERSION libnvidia-*-$MAJOR_VERSION" > $FILE | |
echo "Pin: version $MINOR_VERSION*" >> $FILE | |
echo "Pin-Priority: 1001" >> $FILE | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment