Last active
December 22, 2023 03:35
-
-
Save Ethorbit/87574de509c15409076c7830c49ef2d6 to your computer and use it in GitHub Desktop.
A Proxmox hookscript (/var/lib/vz/snippets/second-gpu.sh) that releases my NVIDIA GPU after the VM stops so that I can display the host terminal.
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 | |
SECOND_GPU="0000:01:00.0" | |
# First argument is the vmid | |
# Second argument is the phase | |
VMID="$1" | |
shift | |
PHASE="$1" | |
if [ "$PHASE" = "post-stop" ]; then | |
sleep 2 | |
while [ -d "/sys/bus/pci/drivers/vfio-pci/$SECOND_GPU" ]; do | |
echo "$SECOND_GPU" > /sys/bus/pci/drivers/vfio-pci/unbind 2>&1 | |
done | |
while [ ! -d "/sys/bus/pci/drivers/nouveau/$SECOND_GPU" ]; do | |
echo "$SECOND_GPU" > /sys/bus/pci/drivers/nouveau/bind 2>&1 | |
done | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment