2022-07-23 13:16:10 +02:00
|
|
|
#!/usr/bin/env bash
|
2022-02-25 16:33:46 +01:00
|
|
|
|
2022-07-23 13:55:05 +02:00
|
|
|
# Installs GPU drivers on Linux
|
|
|
|
# bash <(curl -s https://raw.githubusercontent.com/photoprism/photoprism/develop/scripts/dist/install-gpu.sh)
|
|
|
|
|
2022-07-23 13:08:24 +02:00
|
|
|
PATH="/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/scripts:$PATH"
|
2022-03-23 08:16:01 +01:00
|
|
|
|
2022-03-01 13:55:05 +01:00
|
|
|
# abort if not executed as root
|
2022-02-25 16:33:46 +01:00
|
|
|
if [[ $(id -u) != "0" ]]; then
|
|
|
|
echo "Error: Run ${0##*/} as root" 1>&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2022-07-23 13:55:05 +02:00
|
|
|
if [[ $PHOTOPRISM_ARCH ]]; then
|
|
|
|
SYSTEM_ARCH=$PHOTOPRISM_ARCH
|
|
|
|
else
|
|
|
|
SYSTEM_ARCH=$(uname -m)
|
|
|
|
fi
|
|
|
|
|
2022-02-25 16:33:46 +01:00
|
|
|
DESTARCH=${DESTARCH:-$SYSTEM_ARCH}
|
|
|
|
TMPDIR=${TMPDIR:-/tmp}
|
|
|
|
|
2022-07-23 13:55:05 +02:00
|
|
|
. /etc/os-release
|
2022-02-25 16:33:46 +01:00
|
|
|
|
2022-03-23 08:16:01 +01:00
|
|
|
apt-get update
|
|
|
|
apt-get -qq upgrade
|
|
|
|
apt-get -qq install lshw jq
|
2022-02-25 16:33:46 +01:00
|
|
|
|
|
|
|
# shellcheck disable=SC2207
|
2022-03-23 08:16:01 +01:00
|
|
|
GPU_DETECTED=($(lshw -c display -json 2>/dev/null | jq -r '.[].configuration.driver'))
|
2022-02-25 16:33:46 +01:00
|
|
|
|
2022-04-18 14:30:47 +02:00
|
|
|
echo "GPU detected: ${GPU_DETECTED[*]}"
|
|
|
|
|
2022-07-23 13:55:05 +02:00
|
|
|
case $DESTARCH in
|
|
|
|
amd64 | AMD64 | x86_64 | x86-64)
|
|
|
|
echo "Installing GPU drivers for ${DESTARCH^^}..."
|
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
echo "Installing GPU drivers for ${DESTARCH^^} not supported at this time."
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2022-02-25 16:33:46 +01:00
|
|
|
# shellcheck disable=SC2068
|
|
|
|
for t in ${GPU_DETECTED[@]}; do
|
|
|
|
case $t in
|
2022-11-16 13:44:52 +01:00
|
|
|
i915 | i965 | intel | opencl | icd)
|
2022-04-18 14:30:47 +02:00
|
|
|
echo "Installing Intel Drivers..."
|
2022-11-16 13:44:52 +01:00
|
|
|
apt-get -qq install intel-opencl-icd intel-media-va-driver-non-free i965-va-driver-shaders mesa-va-drivers libmfx-gen-dev va-driver-all vainfo libva-dev
|
2022-02-25 16:33:46 +01:00
|
|
|
;;
|
|
|
|
|
|
|
|
nvidia)
|
2022-11-04 10:53:00 +01:00
|
|
|
echo "NVIDIA Container Toolkit must be installed: https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html"
|
2022-03-23 13:27:25 +01:00
|
|
|
;;
|
|
|
|
|
2022-04-18 14:30:47 +02:00
|
|
|
"null")
|
2022-03-23 13:27:25 +01:00
|
|
|
# ignore
|
2022-02-25 16:33:46 +01:00
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
echo "Unsupported GPU: \"$t\"";
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
echo "Done."
|