Skip to content

Instantly share code, notes, and snippets.

@kewitz
Created February 3, 2015 12:34
Show Gist options
  • Select an option

  • Save kewitz/3337719a7228ee1c150a to your computer and use it in GitHub Desktop.

Select an option

Save kewitz/3337719a7228ee1c150a to your computer and use it in GitHub Desktop.
CUDA On/Off switcher for Ubuntu
#!/bin/bash
if [ "$#" != "1" ]; then
echo -e "Usage: cuda [on|off]"
exit 1
fi
if [ "$1" == "on" -o "$1" == "ON" ]; then
sudo tee /proc/acpi/bbswitch <<<ON
sleep 1
sudo modprobe nvidia-331-updates-uvm
fi
if [ "$1" == "off" -o "$1" == "OFF" ]; then
sudo rmmod nvidia_uvm
sleep 1
sudo rmmod nvidia
sleep 1
sudo tee /proc/acpi/bbswitch <<<OFF
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment