Wiki source for CudaStartup


Show raw source

**Script to startup NVIDIA CUDA devices ( /dev/nv* ), on Debian GNU/Linux 5.0.3 Lenny.**

Put this code on /dev/init.d/cuda.sh .

Then, to enable this script to be executed on boot:

%%
update-rc.d cuda.sh defaults
%%

The code:
%%(bash script)
#!/bin/bash
#
# Startup/shutdown script for nVidia CUDA
#
# chkconfig: 345 80 20
# description: Startup/shutdown script for nVidia CUDA

#Removi essa parada tb
# Source function library.
#. /etc/init.d/functions

#Script feito para RHEL, editado para funcionar no debian
#Original no /root/cuda.sh.bkp


DRIVER=nvidia
RETVAL=0

# Create /dev nodes for nvidia devices
function createnodes() {
# Count the number of NVIDIA controllers found.
N3D=`/usr/bin/lspci | grep -i nVidia | grep "3D controller" | wc -l`
NVGA=`/usr/bin/lspci | grep -i nVidia | 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
RETVAL=$?
[ "$RETVAL" = 0 ] || exit $RETVAL
done

mknod -m 666 /dev/nvidiactl c 195 255
RETVAL=$?
[ "$RETVAL" = 0 ] || exit $RETVAL
}

# Remove /dev nodes for nvidia devices
function removenodes() {
rm -f /dev/nvidia*
}

# Start daemon
function start() {
echo -n $"Loading $DRIVER kernel module: "
#Removi a checagem de erro aqui
modprobe $DRIVER #&& success || failure
RETVAL=$?
echo
[ "$RETVAL" = 0 ] || exit $RETVAL
echo -n $"Initializing CUDA /dev entries: "
#Removi a checagem de erro aqui
createnodes #&& success || failure
RETVAL=$?
echo
[ "$RETVAL" = 0 ] || exit $RETVAL
}

# Stop daemon
function stop() {
echo -n $"Unloading $DRIVER kernel module: "
#Removi a checagem de erro aqui
rmmod -f $DRIVER #&& success || failure
RETVAL=$?
echo
[ "$RETVAL" = 0 ] || exit $RETVAL

echo -n $"Removing CUDA /dev entries: "
#Removi a checagem de erro aqui
removenodes #&& success || failure
RETVAL=$?
echo
[ "$RETVAL" = 0 ] || exit $RETVAL
}

# See how we were called
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo $"Usage: $0 {start|stop|restart}"
RETVAL=1
esac
exit $RETVAL
%%

Attention, this script was dirty and quickly modified from this one [[http://forums.nvidia.com/index.php?showtopic=52629]] , to run on Debian.

Happy cuda hacking.
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki