Skip to content

Instantly share code, notes, and snippets.

@michelesr
Created March 19, 2022 21:10
Show Gist options
  • Save michelesr/6f67cf8474250337a948b28eeb7cb45a to your computer and use it in GitHub Desktop.
Save michelesr/6f67cf8474250337a948b28eeb7cb45a to your computer and use it in GitHub Desktop.
Turn NVIDIA discrete card off on Linux
#!/bin/bash
set -ex
CONTROLLER_BUS_ID=0000:00:01.0
DEVICE_BUS_ID=0000:01:00.0
if sudo lsof /dev/nvidia0 ; then
echo 'Some processes are still using the card, aborting.'
exit 1
fi
sudo modprobe -r nvidia_drm nvidia_modeset nvidia_uvm nvidia
sudo tee /sys/bus/pci/devices/${DEVICE_BUS_ID}/remove <<<1
sudo tee /sys/bus/pci/devices/${CONTROLLER_BUS_ID}/power/control <<<auto
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment