Skip to content

Instantly share code, notes, and snippets.

@sodonnell
Created May 30, 2019 00:24
Show Gist options
  • Select an option

  • Save sodonnell/ca4ebf6ffa605a85c42e6747fc31afa0 to your computer and use it in GitHub Desktop.

Select an option

Save sodonnell/ca4ebf6ffa605a85c42e6747fc31afa0 to your computer and use it in GitHub Desktop.
Automatically discover and enable NVIDIA Tesla K20/K20X GPU/CUDA devices on Red Hat Enterprise Linux (RHEL).
#!/bin/sh
#
# /etc/init.d/nvload
#
# This script was used to ensure all new/existing NVIDIA GPU/CUDA devices
# are loaded properly on an AMAX Tesla K20/K20X GPU Clustering platform,
# running Red Hat Enterprise Linux (RHEL).
#
# Author: Sean O'Donnell <sean@seanodonnell.com>
#
/sbin/modprobe nvidia
if [ "$?" -eq 0 ]; then
# Count the number of NVIDIA 3D and VGA controllers found.
N3D=`/sbin/lspci | grep -i NVIDIA | grep "3D controller" | wc -l`
NVGA=`/sbin/lspci | grep -i NVIDIA | grep "VGA compatible controller" | wc -l`
N=`expr $N3D + $NVGA - 1`
for i in `seq 0 $N`; do
/bin/mknod -m 666 /dev/nvidia$i c 195 $i;
done
/bin/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