-
Notifications
You must be signed in to change notification settings - Fork 1
/
argus.sh
executable file
·64 lines (56 loc) · 1.87 KB
/
argus.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
#!/bin/bash
set -e
# get path to argus
ARGUS_PATH="$(dirname "$(realpath "${BASH_SOURCE[0]}")")"
echo "Argus path is $ARGUS_PATH"
# export default env for all unset vars
set -a
. "$ARGUS_PATH/default.env"
set +a
# detect if a gpu is available
set +e
if [ -z ${ARGUS_GPU_NVIDIA+x} ]; then
export ARGUS_GPU_NVIDIA=false
if lspci | grep -q 'NVIDIA' || lspci | grep -q "VGA.*NVIDIA" || \
(command -v nvidia-smi >/dev/null 2>&1 && [[ $(nvidia-smi -L | grep "GPU 0:" | awk -F ': ' '{print $2}' | awk -F '(' '{print $1}') == *"NVIDIA"* ]]); then
echo "NVIDIA GPU has been found"
if cat /etc/docker/daemon.json | grep -q nvidia-container-runtime; then
export ARGUS_GPU_NVIDIA=true
else
echo "Missing nvidia docker toolkit, falling back to CPU"
fi
fi
fi
if [ -z ${ARGUS_GPU_INTEL+x} ]; then
export ARGUS_GPU_INTEL=false
if lspci | grep -q "VGA.*Intel"; then
echo "INTEL GPU has been found"
export ARGUS_GPU_INTEL=true
export ARGUS_RENDER_GROUP_ID=$(getent group render | cut -d":" -f3)
fi
fi
if [ -z ${ARGUS_GPU_AMD+x} ]; then
export ARGUS_GPU_AMD=false
if lspci | grep -q "VGA.*AMD"; then
echo "AMD GPU has been found"
export ARGUS_GPU_AMD=true
fi
fi
set -e
# add docker compose overlay yml for gpu if detected
docker_compose="docker compose -f $ARGUS_PATH/docker-compose.yml -f $ARGUS_PATH/docker-compose.nodeodm.yml -f $ARGUS_PATH/docker-compose.webodm.yml"
if $ARGUS_GPU_NVIDIA; then
echo "Using NVIDIA GPU"
docker_compose="$docker_compose -f $ARGUS_PATH/docker-compose.gpu.nvidia.yml"
elif $ARGUS_GPU_INTEL; then
echo "Using INTEL GPU"
docker_compose="$docker_compose -f $ARGUS_PATH/docker-compose.gpu.intel.yml"
elif $ARGUS_GPU_AMD; then
echo "Using AMD GPU"
echo "NodeODM has no support for AMD GPU at the moment, falling back to CPU"
else
echo "Using CPU"
fi
# run docker compose with provided arguments
echo "Runing command: $docker_compose $@"
$docker_compose "$@"