46 lines
1.3 KiB
Bash
Executable file
46 lines
1.3 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# Installe les artefacts de configuration (APT pinning + env CUDA) depuis le dépôt
|
|
# vers /etc/... de façon simple et reproductible.
|
|
|
|
set -euo pipefail
|
|
|
|
fatal(){ echo "ERROR: $*" >&2; exit 1; }
|
|
info(){ echo "INFO: $*"; }
|
|
|
|
require_root() {
|
|
if [[ "${EUID:-$(id -u)}" -ne 0 ]]; then
|
|
fatal "Run as root: sudo $0"
|
|
fi
|
|
}
|
|
|
|
repo_root() {
|
|
# Répertoire du script (supposé être à la racine du repo)
|
|
cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd
|
|
}
|
|
|
|
main() {
|
|
require_root
|
|
local root
|
|
root="$(repo_root)"
|
|
|
|
[[ -f "$root/apt/99-nvidia-from-ubuntu-cuda-from-nvidia.pref" ]] || fatal "Missing: apt/99-nvidia-from-ubuntu-cuda-from-nvidia.pref"
|
|
[[ -f "$root/env/cuda-12-8.sh" ]] || fatal "Missing: env/cuda-12-8.sh"
|
|
|
|
info "Installing APT pinning file..."
|
|
install -D -m 0644 "$root/apt/99-nvidia-from-ubuntu-cuda-from-nvidia.pref" \
|
|
/etc/apt/preferences.d/99-nvidia-from-ubuntu-cuda-from-nvidia.pref
|
|
|
|
info "Installing CUDA environment file..."
|
|
install -D -m 0644 "$root/env/cuda-12-8.sh" \
|
|
/etc/profile.d/cuda-12-8.sh
|
|
|
|
info "Refreshing APT metadata..."
|
|
apt-get update -y
|
|
|
|
info "Done."
|
|
info "Quick checks:"
|
|
echo " apt-cache policy nvidia-driver-580-open libnvidia-gl-580 | sed -n '1,120p'"
|
|
echo " source /etc/profile.d/cuda-12-8.sh ; which nvcc ; nvcc --version"
|
|
}
|
|
|
|
main "$@"
|