Skip to content

Commit

Permalink
Docker: Enable integrated GPU even if an NVIDIA GPU is present
Browse files Browse the repository at this point in the history
Signed-off-by: Andrej Orsula <[email protected]>
  • Loading branch information
AndrejOrsula committed Sep 27, 2024
1 parent 9b398f2 commit bf400df
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions .docker/run.bash
Original file line number Diff line number Diff line change
Expand Up @@ -118,18 +118,20 @@ if [[ "${ENABLE_GPU,,}" = true ]]; then
DOCKER_VERSION="$(${WITH_SUDO} docker version --format '{{.Server.Version}}')"
MIN_VERSION_FOR_TOOLKIT="19.3"
if [ "$(printf '%s\n' "${MIN_VERSION_FOR_TOOLKIT}" "${DOCKER_VERSION}" | sort -V | head -n1)" = "$MIN_VERSION_FOR_TOOLKIT" ]; then
GPU_OPT="--gpus all"
DOCKER_RUN_OPTS+=" --gpus all"
else
GPU_OPT="--runtime nvidia"
DOCKER_RUN_OPTS+=" --runtime nvidia"
fi
GPU_ENVS=(
CUSTOM_ENVS+=(
NVIDIA_VISIBLE_DEVICES="all"
NVIDIA_DRIVER_CAPABILITIES="all"
)
elif [[ $(getent group video) ]]; then
GPU_OPT="--device=/dev/dri:/dev/dri --group-add video"
else
GPU_OPT="--device=/dev/dri:/dev/dri"
fi
if [[ -e /dev/dri ]]; then
DOCKER_RUN_OPTS+=" --device=/dev/dri:/dev/dri"
if [[ $(getent group video) ]]; then
DOCKER_RUN_OPTS+=" --group-add video"
fi
fi
fi

Expand Down Expand Up @@ -161,8 +163,6 @@ fi
DOCKER_RUN_CMD=(
${WITH_SUDO} docker run
"${DOCKER_RUN_OPTS}"
"${GPU_OPT}"
"${GPU_ENVS[@]/#/"--env "}"
"${GUI_VOLUMES[@]/#/"--volume "}"
"${GUI_ENVS[@]/#/"--env "}"
"${CUSTOM_VOLUMES[@]/#/"--volume "}"
Expand Down

0 comments on commit bf400df

Please sign in to comment.