Skip to content

Instantly share code, notes, and snippets.

@ashwin
Created March 6, 2013 15:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ashwin/5099946 to your computer and use it in GitHub Desktop.
Save ashwin/5099946 to your computer and use it in GitHub Desktop.
Script to create NVIDIA dev files for use by CUDA. This is necessary for headless Ubuntu servers.
#!/bin/bash
/sbin/modprobe nvidia
if [ "$?" -eq 0 ]; then
# 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`
for i in `seq 0 $N`; do
mknod -m 666 /dev/nvidia$i c 195 $i
done
mknod -m 666 /dev/nvidiactl c 195 255
else
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment