-
Notifications
You must be signed in to change notification settings - Fork 36
/
upgrade.sh
executable file
·95 lines (69 loc) · 1.77 KB
/
upgrade.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/bash
uninstall()
{
rm -f /usr/bin/nvidia-container-runtime-hook
ln -s /usr/bin/nvidia-container-toolkit /usr/bin/nvidia-container-runtime-hook
if lsmod | grep cgpu_km ;then
rmmod cgpu_km
if [ $? -ne 0 ]; then
echo "error: rmmod cgpu_km fail!"
return 1
else
echo "rmmod cgpu_km OK"
fi
fi
if [ -f "/lib/modules/$(uname -r)/kernel/virt/lib/cgpu_km.ko" ] ; then
rm -f /lib/modules/$(uname -r)/kernel/virt/lib/cgpu_km.ko
fi
if [ -f "/lib/modules/$(uname -r)/extra/cgpu_km.ko" ] ; then
rm -f /lib/modules/$(uname -r)/extra/cgpu_km.ko
fi
depmod
return 0
}
install()
{
make
rm -f /usr/bin/nvidia-container-runtime-hook
cp ./cgpu-container-wrapper /usr/bin/nvidia-container-runtime-hook
cp cgpu_km.ko /lib/modules/$(uname -r)/kernel/virt/lib/cgpu_km.ko
if [ $? -ne 0 ]; then
echo "error: cp cgpu_km.ko to /lib/modules/$(uname -r)/kernel/virt/lib/ fail!"
return 1
fi
depmod
if [ ! -c /dev/nvidia0 -o ! -c /dev/nvidiactl ]; then
nvidia-smi > /dev/null
fi
if [ -c /dev/nvidiactl ]; then
modprobe cgpu_km
fi
if ! lsmod | grep cgpu_km; then
echo "error: cgpu_km not insmod"
return 1
fi
return 0
}
s=0
for i in `seq 8`
do
if [ -d /proc/cgpu_km/$s ] ; then
count=`ls -l /proc/cgpu_km/$s | grep "^d" | wc -l`
if [ $count -ge 1 ] ; then
echo "docker is running, upgrade fail! "
exit 1;
fi
fi
s=`expr $s + 1`;
done
uninstall
if [ $? -ne 0 ]; then
echo "uninstall cgpu fail,can not upgrade cgpu!"
exit 1
fi
install
if [ $? -ne 0 ]; then
echo "install cgpu fail,can not upgrade cgpu!"
exit 1
fi
exit 0