Skip to content

Instantly share code, notes, and snippets.

@MasterSkepticista
Created July 16, 2024 09:54
Show Gist options
  • Save MasterSkepticista/59f505bf96088414f27d3a0b18da77d4 to your computer and use it in GitHub Desktop.
Save MasterSkepticista/59f505bf96088414f27d3a0b18da77d4 to your computer and use it in GitHub Desktop.
Reload `nvidia-smi` without a reboot.
#!/bin/bash
# Reloads `nvidia-smi` if you have had NVML/Library updates/mismatches,
# and you use a remote server which you cannot reboot for a whole host
# of scary reasons. Ensure nothing is running on the GPU, else this fails.
# Must be run with sudo. Be careful there are no display targets on the
# It is likely safe.
set -Eeuo pipefail
if [[ $UID != 0 ]]; then
echo "Please run this script with sudo."
echo "sudo $0 $*"
exit 1
fi
systemctl isolate multi-user.target
# Stop nvidia modules.
modprobe -r nvidia_uvm nvidia_modeset
modprobe -r nvidia
systemctl start graphical.target
nvidia-smi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment