-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add services and shell script to install artifacts in CoreOS
- Loading branch information
Showing
13 changed files
with
190 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.sh text eol=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Tag the device as master-of-seat so that logind is happy | ||
# (see LP: #1365336) | ||
SUBSYSTEM=="pci", ATTRS{vendor}=="0x10de", DRIVERS=="nvidia", TAG+="seat", TAG+="master-of-seat" | ||
|
||
# Start and stop nvidia-persistenced on power on and power off | ||
# respectively | ||
ACTION=="add" DEVPATH=="/bus/acpi/drivers/NVIDIA ACPI Video Driver" SUBSYSTEM=="drivers" RUN+="/bin/systemctl start --no-block nvidia-persistenced.service" | ||
ACTION=="remove" DEVPATH=="/bus/acpi/drivers/NVIDIA ACPI Video Driver" SUBSYSTEM=="drivers" RUN+="/bin/systemctl stop --no-block nvidia-persistenced" | ||
|
||
# Start and stop nvidia-persistenced when loading and unloading | ||
# the driver | ||
ACTION=="add" DEVPATH=="/module/nvidia" SUBSYSTEM=="module" RUN+="/bin/systemctl start --no-block nvidia-persistenced.service" | ||
ACTION=="remove" DEVPATH=="/module/nvidia" SUBSYSTEM=="module" RUN+="/bin/systemctl stop --no-block nvidia-persistenced" | ||
|
||
# Load and unload nvidia-modeset module | ||
ACTION=="add" DEVPATH=="/module/nvidia" SUBSYSTEM=="module" RUN+="/opt/bin/nvidia-insmod.sh nvidia-modeset.ko" | ||
ACTION=="remove" DEVPATH=="/module/nvidia" SUBSYSTEM=="module" RUN+="/usr/sbin/rmmod -r nvidia-modeset" | ||
|
||
# Load and unload nvidia-drm module | ||
ACTION=="add" DEVPATH=="/module/nvidia" SUBSYSTEM=="module" RUN+="/opt/bin/nvidia-insmod.sh nvidia-drm.ko" | ||
ACTION=="remove" DEVPATH=="/module/nvidia" SUBSYSTEM=="module" RUN+="/usr/sbin/rmmod nvidia-drm" | ||
|
||
# Load and unload nvidia-uvm module | ||
ACTION=="add" DEVPATH=="/module/nvidia" SUBSYSTEM=="module" RUN+="/opt/bin/nvidia-insmod.sh nvidia-uvm.ko" | ||
ACTION=="remove" DEVPATH=="/module/nvidia" SUBSYSTEM=="module" RUN+="/usr/sbin/rmmod -r nvidia-uvm" | ||
|
||
# This will create the device nvidia device nodes | ||
ACTION=="add" DEVPATH=="/module/nvidia" SUBSYSTEM=="module" RUN+="/opt/bin/nvidia-smi" | ||
|
||
# Create the device node for the nvidia-uvm module | ||
ACTION=="add" DEVPATH=="/module/nvidia_uvm" SUBSYSTEM=="module" RUN+="/opt/bin/create-uvm-dev-node.sh" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/sh | ||
|
||
# Get the major device number for nvidia-uvm and create the node | ||
echo "Set up NVIDIA UVM" | ||
major=`grep nvidia-uvm /proc/devices | awk '{print $1}'` | ||
if [ -n "$major" ]; then | ||
mknod -m 666 /dev/nvidia-uvm c $major 0 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
[Unit] | ||
Description=NVIDIA Docker plugin | ||
Documentation=https://github.com/NVIDIA/nvidia-docker/wiki | ||
After=local-fs.target network.target nvidia-start.service | ||
Wants=docker.service | ||
|
||
[Service] | ||
Environment="SOCK_DIR=/var/lib/nvidia-docker" | ||
Environment="SPEC_FILE=/etc/docker/plugins/nvidia-docker.spec" | ||
Environment="PATH=/opt/bin/:/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin" | ||
|
||
#User=nvidia-docker | ||
User=root | ||
#PermissionsStartOnly=true | ||
Restart=on-failure | ||
RestartSec=1 | ||
TimeoutStartSec=0 | ||
TimeoutStopSec=20 | ||
|
||
ExecStart=/opt/bin/nvidia-docker-plugin -s $SOCK_DIR | ||
ExecStartPost=/bin/sh -c '/bin/mkdir -p $( dirname $SPEC_FILE )' | ||
ExecStartPost=/bin/sh -c '/bin/echo unix://$SOCK_DIR/nvidia-docker.sock > $SPEC_FILE' | ||
ExecStopPost=/bin/rm -f $SPEC_FILE | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/sh | ||
|
||
/usr/sbin/insmod /opt/lib/modules/$(uname -r)/video/$1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[Unit] | ||
Description=NVIDIA Persistence Daemon | ||
Wants=local-fs.target | ||
|
||
[Service] | ||
Type=forking | ||
ExecStart=/opt/bin/nvidia-persistenced --user nvidia-persistenced --no-persistence-mode --verbose | ||
ExecStopPost=/bin/rm -rf /var/run/nvidia-persistenced |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[Unit] | ||
Description=Load NVIDIA module | ||
After=local-fs.target | ||
|
||
[Service] | ||
ExecStart=/opt/bin/nvidia-start.sh | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/sh | ||
|
||
/opt/bin/nvidia-insmod.sh nvidia.ko | ||
|
||
# Start the first devices | ||
/usr/bin/mknod -m 666 /dev/nvidiactl c 195 255 2>/dev/null | ||
/usr/bin/mknod -m 666 /dev/nvidia0 c 195 0 2>/dev/null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/bash | ||
|
||
NVIDIA_DOCKER_VERSION=${1:-1.0.1} | ||
|
||
if [[ $(uname -r) != *"-coreos-"* ]]; then | ||
echo "OS is not CoreOS" | ||
exit 1 | ||
fi | ||
|
||
wget -P /tmp https://github.com/NVIDIA/nvidia-docker/releases/download/v${NVIDIA_DOCKER_VERSION}/nvidia-docker_${NVIDIA_DOCKER_VERSION}_amd64.tar.xz | ||
tar --strip-components=1 -C /opt/bin -xvf /tmp/nvidia-docker*.tar.xz && rm /tmp/nvidia-docker*.tar.xz | ||
echo "Setting up permissions" | ||
chown root:root /opt/bin/nvidia-docker* | ||
setcap cap_fowner+pe /opt/bin/nvidia-docker-plugin | ||
|
||
echo "Configuring nvidia user" | ||
id -u nvidia-docker >/dev/null 2>&1 || \ | ||
useradd -r -M -d /var/lib/nvidia-docker -s /usr/sbin/nologin -c "NVIDIA Docker plugin" nvidia-docker | ||
mkdir -p /var/lib/nvidia-docker 2>/dev/null | ||
chown nvidia-docker: /var/lib/nvidia-docker | ||
|
||
systemctl enable nvidia-docker.service | ||
systemctl start nvidia-docker.service |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/bin/bash | ||
|
||
if [[ $(uname -r) != *"-coreos-"* ]]; then | ||
echo "OS is not CoreOS" | ||
exit 1 | ||
fi | ||
|
||
COREOS_TRACK_DEFAULT=beta | ||
COREOS_VERSION_DEFAULT=1185.5.0 | ||
# If we are on CoreOS by default use the current CoreOS version | ||
if [[ -f /etc/lsb-release && -f /etc/coreos/update.conf ]]; then | ||
source /etc/lsb-release | ||
source /etc/coreos/update.conf | ||
|
||
COREOS_TRACK_DEFAULT=$GROUP | ||
COREOS_VERSION_DEFAULT=$DISTRIB_RELEASE | ||
if [[ $DISTRIB_ID != *"CoreOS"* ]]; then | ||
echo "Distribution is not CoreOS" | ||
exit 1 | ||
fi | ||
fi | ||
|
||
DRIVER_VERSION=${1:-375.20} | ||
COREOS_TRACK=${2:-$COREOS_TRACK_DEFAULT} | ||
COREOS_VERSION=${3:-$COREOS_VERSION_DEFAULT} | ||
|
||
# this is where the modules go | ||
release=$(uname -r) | ||
|
||
mkdir -p /opt/lib64/tls 2>/dev/null | ||
mkdir -p /opt/bin 2>/dev/null | ||
ln -sfT lib64 /opt/lib 2>/dev/null | ||
mkdir -p /opt/lib64/modules/$release/video/ | ||
|
||
tar xvf libraries-$DRIVER_VERSION.tar.bz2 -C /opt/lib64/ | ||
tar xvf libraries-tls-$DRIVER_VERSION.tar.bz2 -C /opt/lib64/tls/ | ||
tar xvf modules-$COREOS_VERSION-$DRIVER_VERSION.tar.bz2 -C /opt/lib64/modules/$release/video/ | ||
tar xvf tools-$DRIVER_VERSION.tar.bz2 -C /opt/bin/ | ||
|
||
install -m 755 create-uvm-dev-node.sh /opt/bin/ | ||
install -m 755 nvidia-start.sh /opt/bin/ | ||
install -m 755 nvidia-insmod.sh /opt/bin/ | ||
cp -f 71-nvidia.rules /etc/udev/rules.d/ | ||
udevadm control --reload-rules | ||
|
||
mkdir -p /etc/ld.so.conf.d/ 2>/dev/null | ||
echo "/opt/lib64" > /etc/ld.so.conf.d/nvidia.conf | ||
ldconfig | ||
|
||
echo "Configuring nvidia persistence user" | ||
id -u nvidia-persistenced >/dev/null 2>&1 || \ | ||
useradd --system --home '/' --shell '/sbin/nologin' -c 'NVIDIA Persistence Daemon' nvidia-persistenced | ||
|
||
cp *.service /etc/systemd/system/ | ||
systemctl daemon-reload | ||
systemctl enable nvidia-start.service | ||
systemctl start nvidia-start.service |