forked from BugRoger/coreos-nvidia-driver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·93 lines (76 loc) · 2.51 KB
/
install.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
#!/bin/sh
set -ev
mkdir -p /opt/nvidia/.work || true
mkdir -p /opt/bin || true
rm -rf /opt/nvidia/current || true
ln -fs /opt/nvidia/$DRIVER_VERSION/$COREOS_VERSION/bin/* /opt/bin
ln -fs /opt/nvidia/$DRIVER_VERSION/$COREOS_VERSION /opt/nvidia/current
ln -fs /opt/nvidia/$DRIVER_VERSION/$COREOS_VERSION/lib64/libnvidia-ml.so.$DRIVER_VERSION /opt/nvidia/$DRIVER_VERSION/$COREOS_VERSION/lib64/libnvidia-ml.so
chmod u+s /opt/nvidia/$DRIVER_VERSION/$COREOS_VERSION/bin/nvidia-modprobe
cat <<EOF > /etc/systemd/system/nvidia-update.service
[Unit]
After=docker.service
Requires=docker.service
Description=NVIDIA Update Driver
[Service]
EnvironmentFile=/etc/os-release
TimeoutStartSec=0
Type=oneshot
RemainAfterExit=yes
ExecStartPre=/usr/bin/docker pull bugroger/coreos-nvidia-driver:\${VERSION}-$DRIVER_VERSION-$NVIDIA_PRODUCT_TYPE
ExecStart=/usr/bin/docker run -v /:/rootfs --privileged bugroger/coreos-nvidia-driver:\${VERSION}-$DRIVER_VERSION-$NVIDIA_PRODUCT_TYPE
[Install]
WantedBy=multi-user.target
EOF
cat <<EOF > /etc/systemd/system/usr-lib64.mount
[Unit]
After=nvidia-update.service
Requires=nvidia-update.service
ConditionPathExists=/opt/nvidia/.work
Description=Nvidia Kernel Modules
[Mount]
EnvironmentFile=/etc/os-release
Type=overlay
What=overlay
Where=/usr/lib64
Options=lowerdir=/usr/lib64,upperdir=/opt/nvidia/$DRIVER_VERSION/\${VERSION}/lib64,workdir=/opt/nvidia/.work
[Install]
WantedBy=multi-user.target
EOF
cat <<EOF > /etc/systemd/system/nvidia-persistenced.service
[Unit]
After=nvidia.service
Requires=nvidia.service
Description=NVIDIA Persistence Daemon
[Service]
Type=forking
ExecStart=/opt/bin/nvidia-persistenced --user nvidia-persistenced --persistence-mode --verbose
ExecStopPost=/bin/rm -rf /var/run/nvidia-persistenced
[Install]
WantedBy=multi-user.target
EOF
cat <<EOF > /etc/systemd/system/nvidia.service
[Unit]
After=usr-lib64.mount
Requires=usr-lib64.mount
Description=NVIDIA Load
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/sbin/ldconfig
ExecStart=/usr/sbin/depmod -a
ExecStart=/opt/bin/nvidia-modprobe -u -m -c 0
ExecStart=/opt/bin/nvidia-smi
[Install]
WantedBy=multi-user.target
EOF
cat <<EOF > /etc/udev/rules.d/01-nvidia.rules
SUBSYSTEM=="pci", ATTRS{vendor}=="0x10de", DRIVERS=="nvidia", TAG+="seat", TAG+="master-of-seat"
EOF
udevadm control --reload-rules
useradd -c "NVIDIA Persistence Daemon" --shell /sbin/nologin --home-dir / nvidia-persistenced || true
systemctl daemon-reload
systemctl enable nvidia-update
systemctl enable usr-lib64.mount
systemctl enable nvidia
systemctl enable nvidia-persistenced