forked from Saberwolf64/Proxmox-Nvidia-LXC-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
6.2-1.sh
87 lines (74 loc) · 3.15 KB
/
6.2-1.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
#!/usr/bin/env bash
#remove proxmox ui nag
bash -c "$(wget -qLO - https://gist.githubusercontent.com/whiskerz007/53c6aa5d624154bacbbc54880e1e3b2a/raw/70b66d1852978cc457526df4a2913ca2974970a1/gistfile1.txt)"
# Update Proxmox
apt-get update && apt-get upgrade -qqy
# Install NVidia drivers prerequisites
apt-get install -qqy pve-headers-`uname -r` gcc make
# Setup temporary environment
trap cleanup EXIT
function cleanup() {
popd >/dev/null
rm -rf $TMP_DIR
}
TMP_DIR=$(mktemp -d)
pushd $TMP_DIR >/dev/null
#removal of Nouveau driver from system
cat <<e > /etc/modprobe.d/nvidia-installer-disable-nouveau.conf
# generated by nvidia-installer
blacklist nouveau
options nouveau modeset=0
e
rmmod nouveau
# Install NVidia drivers
LATEST_DRIVER=$(wget -qLO - https://download.nvidia.com/XFree86/Linux-x86_64/latest.txt | awk '{print $2}')
LATEST_DRIVER_URL="https://download.nvidia.com/XFree86/Linux-x86_64/470.161.03/NVIDIA-Linux-x86_64-470.161.03.run"
INSTALL_SCRIPT=$(basename $LATEST_DRIVER_URL)
wget -qLO $INSTALL_SCRIPT $LATEST_DRIVER_URL
bash $INSTALL_SCRIPT --silent
# Install NVidia Persistenced
#/usr/share/doc/NVIDIA_GLX-1.0/sample/nvidia-persistenced-init.tar.bz2
if [ -f /usr/share/doc/NVIDIA_GLX-1.0/samples/nvidia-persistenced-init.tar.bz2 ]; then
tar -jxvf /usr/share/doc/NVIDIA_GLX-1.0/samples/nvidia-persistenced-init.tar.bz2
bash ./nvidia-persistenced-init/install.sh
fi
# Install NVidia Container Runtime
wget -qLO - https://nvidia.github.io/nvidia-container-runtime/gpgkey | apt-key add -
distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
wget -qLO - https://nvidia.github.io/nvidia-container-runtime/$distribution/nvidia-container-runtime.list | tee /etc/apt/sources.list.d/nvidia-container-runtime.list
apt-get update
apt-get install -qqy nvidia-container-runtime
#create LXC
export CTID=$(pvesh get /cluster/nextid)
export PCT_OSTYPE=ubuntu
export PCT_OSVERSION=20
export PCT_DISK_SIZE=20
export PCT_OPTIONS="
-cmode shell
-hostname PLEX
-memory 4096
-features nesting=1
-net0 name=eth0,bridge=vmbr0,ip=dhcp
"
bash -c "$(wget -qLO - https://raw.githubusercontent.com/Saberwolf64/Proxmox-Nvidia-LXC-/proxmox-6.2-1-ubunutu-contributor-Whiskerz007/LXC_create.sh)"
#configure LXC
LXC_CONFIG=/etc/pve/lxc/${CTID}.conf
cat <<EOF >> $LXC_CONFIG
lxc.hook.pre-start: sh -c '[ ! -f /dev/nvidia-uvm ] && /usr/bin/nvidia-modprobe -c0 -u'
lxc.environment: NVIDIA_VISIBLE_DEVICES=all
lxc.environment: NVIDIA_DRIVER_CAPABILITIES=all
lxc.hook.mount: /usr/share/lxc/hooks/nvidia
lxc.hook.pre-start: sh -c 'chown :100000 /dev/nvidia*'
EOF
pct start $CTID
#wait for lxc to report ip from DHCP
until lxc-info $CTID | grep -q IP;do
echo -ne "no ip found \033[0K\r"
done
#Update/upgrade and install plex,NVtop on LXC
lxc-attach -n $CTID -- apt -y install gnupg2
lxc-attach -n $CTID -- bash -c 'wget -q https://downloads.plex.tv/plex-keys/PlexSign.key -O - | apt-key add -'
lxc-attach -n $CTID -- bash -c 'echo "deb https://downloads.plex.tv/repo/deb/ public main" > /etc/apt/sources.list.d/plexmediaserver.list'
lxc-attach -n $CTID -- apt update
lxc-attach -n $CTID -- apt -y upgrade
lxc-attach -n $CTID -- apt-get -y -o Dpkg::Options::="--force-confnew" install plexmediaserver