This repository has been archived by the owner on Mar 16, 2023. It is now read-only.
forked from hookenz/coreos-nvidia
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall_nvidia.sh
78 lines (61 loc) · 1.84 KB
/
install_nvidia.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
#!/bin/sh
set -e
mkdir -p /usr/src/kernels
cd /usr/src/kernels
#get kernel source. recent CoreOS build from plain
#kernel source. that's why this works
curl https://www.kernel.org/pub/linux/kernel/\
v`uname -r | grep -o '^[0-9]'`.x/\
linux-`uname -r | grep -o '[0-9].[0-9].[0-9]'`.tar.xz \
> linux.tar.xz
mkdir linux
tar -xvf linux.tar.xz -C linux --strip-components=1
# set gcc version used to compile kernel
DRIVER_GCC_VER=$(grep -o -e 'gcc version [0-9].[0-9]' /proc/version | \
sed 's/gcc version //')
apt-get update
apt-get install -y gcc-${DRIVER_GCC_VER} g++-${DRIVER_GCC_VER}
update-alternatives --install \
/usr/bin/gcc gcc /usr/bin/gcc-${DRIVER_GCC_VER} 60 \
--slave \
/usr/bin/g++ g++ /usr/bin/g++-${DRIVER_GCC_VER}
#print gcc ver to check
update-alternatives --set gcc "/usr/bin/gcc-${DRIVER_GCC_VER}"
#prepare source for modules
cd linux
zcat /proc/config.gz > .config
make modules_prepare
echo "#define UTS_RELEASE \"$(uname -r)\"" \
> include/generated/utsrelease.h
# Nvidia drivers setup
cd /opt/nvidia
if [ "$DRIVER_VER" = "CUDA" ];
then
chmod +x ./cuda.run
./cuda.run \
--silent \
--driver \
--kernel-source-path=/usr/src/kernels/linux
else
chmod +x driver.run
./driver.run \
--silent \
--kernel-source-path=/usr/src/kernels/linux
fi
modprobe nvidia
#todo: install with --compat32-libdir?
# Nvidia CUDA setup
#use proper gcc
update-alternatives --remove gcc /usr/bin/gcc-${DRIVER_GCC_VER}
update-alternatives --install \
/usr/bin/gcc gcc /usr/bin/gcc-${CUDA_GCC_VER} 60 \
--slave \
/usr/bin/g++ g++ /usr/bin/g++-${CUDA_GCC_VER}
#print gcc ver to check
update-alternatives --config gcc
chmod +x cuda.run
./cuda.run --silent --toolkit --samples
# run samples setup (again.just to get kenerl module nvidia_uvm!)
cd /usr/local/cuda/samples/1_Utilities/deviceQuery
make
./deviceQuery