Skip to content

Instantly share code, notes, and snippets.

@majidaldo
Forked from tleyden/nvidia_devices.sh
Last active September 21, 2022 03:38
Show Gist options
  • Save majidaldo/87d6a4c58df07f69b269 to your computer and use it in GitHub Desktop.
Save majidaldo/87d6a4c58df07f69b269 to your computer and use it in GitHub Desktop.
add nvidia devices
#!/bin/bash
# Count the number of NVIDIA controllers found.
NVDEVS=`lspci | grep -i NVIDIA`
N3D=`echo "$NVDEVS" | grep "3D controller" | wc -l`
NVGA=`echo "$NVDEVS" | grep "VGA compatible controller" | wc -l`
N=`expr $N3D + $NVGA - 1`
PRFX='--device '
for i in `seq 0 $N`; do
rm -f /dev/nvidia$i
mknod -m 666 /dev/nvidia$i c 195 $i
printf "%s /dev/nvidia$i:/dev/nvidia$i " "$PRFX"
done
rm -f /dev/nvidiactl
mknod -m 666 /dev/nvidiactl c 195 255
printf "%s /dev/nvidiactl:/dev/nvidiactl " "$PRFX"
# Find out the major device number used by the nvidia-uvm driver
D=`grep nvidia-uvm /proc/devices | awk '{print $1}'`
rm -f /dev/nvidia-uvm
mknod -m 666 /dev/nvidia-uvm c $D 0
printf "%s /dev/nvidia-uvm:/dev/nvidia-uvm" "$PRFX"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment