Something went wrong. Try again.
This repository has no description
Something went wrong. Try again.
Shell
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566#!/usr/bin/env bash# Provisions the four-card serving VM made by bench/gpu-vm/create-vm.sh. Runs INSIDE the# guest as root (re-runnable; every step checks before it changes anything):## ssh <user>@<vm> "sudo APT_PROXY=http://<apt-cache>:3142 NAS_EXPORT=<nas>:/<export> bash -s" \# < bench/gpu-vm/provision.sh## Installs the NVIDIA server driver (headless, open kernel modules), docker with the# NVIDIA container toolkit, the guest agent, and mounts the NAS export that holds the# checkpoints read-only at /mnt/models-nas. A reboot is needed after the first run# so the driver loads; the script says so.set -euo pipefailmain() {
# 595 is the branch the rig's bare-metal eight-card host runs (CUDA 13.2), new enough# for the cu130 torch in the serving image.DRIVER="${NVIDIA_DRIVER:-595}"NAS_EXPORT="${NAS_EXPORT:-}"NAS_MOUNT="${NAS_MOUNT:-/mnt/models-nas}"
if [ -n "${APT_PROXY:-}" ]; then # The rig's apt cache refuses HTTPS CONNECT, so HTTPS repositories go direct. printf 'Acquire::http::Proxy "%s";\nAcquire::https::Proxy "DIRECT";\nAcquire::Retries "5";\n' \ "$APT_PROXY" > /etc/apt/apt.conf.d/01proxyfiexport DEBIAN_FRONTEND=noninteractive# A fresh cloud image is still running cloud-init and unattended-upgrades; wait for the# dpkg lock rather than failing on it.cloud-init status --wait >/dev/null 2>&1 || trueapt() { apt-get -o DPkg::Lock::Timeout=900 "$@"; }apt updateapt install -y qemu-guest-agent nfs-common ca-certificates curl gnupg jq rsync \ "nvidia-headless-${DRIVER}-server-open" "nvidia-utils-${DRIVER}-server"systemctl enable --now qemu-guest-agent || true
# Docker from the Ubuntu archive (docker.io), because it comes through the apt cache;# only the NVIDIA toolkit repository needs a direct HTTPS fetch.rm -f /etc/apt/sources.list.d/docker.listif ! command -v nvidia-ctk >/dev/null; then curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey \ | gpg --dearmor --yes -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg curl -fsSL https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list \ | sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' \ > /etc/apt/sources.list.d/nvidia-container-toolkit.listfiapt updateapt install -y docker.io docker-buildx nvidia-container-toolkitnvidia-ctk runtime configure --runtime=dockersystemctl restart docker
if [ -n "$NAS_EXPORT" ]; then mkdir -p "$NAS_MOUNT" line="$NAS_EXPORT $NAS_MOUNT nfs4 ro,vers=4.2,nconnect=8,hard,_netdev,nofail 0 0" grep -qF " $NAS_MOUNT " /etc/fstab || echo "$line" >> /etc/fstab mountpoint -q "$NAS_MOUNT" || mount "$NAS_MOUNT"fi
if nvidia-smi -L >/dev/null 2>&1; then nvidia-smi -Lelse echo "driver installed but not loaded: reboot the guest, then check nvidia-smi"fi
}main "$@"