From edd24265c8898e114b5bc97034cbfc40dcea91ca Mon Sep 17 00:00:00 2001 From: Christian Bayle Date: Wed, 8 Jan 2025 02:03:57 +0100 Subject: [PATCH 1/5] Remove extra \n that make script fails --- docker/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/run.sh b/docker/run.sh index 1040e865bf1..c857694c9e5 100755 --- a/docker/run.sh +++ b/docker/run.sh @@ -13,7 +13,7 @@ run() { # parse .env file for build args build_args=$(awk '$1 ~ /=[^$]/ && $0 !~ /^#/ {print "--build-arg " $0 " "}' .env) && - profile="$(awk -F '=' '/GPU_DRIVER/ {print $2}' .env)" + profile="$(awk -F '=' '/GPU_DRIVER/ {print $2}' .env |tr -d '\n')" # default to 'cuda' profile [[ -z "$profile" ]] && profile="cuda" From b3564c6bbc8229bda7e06695c89a98185463cda3 Mon Sep 17 00:00:00 2001 From: Christian Bayle Date: Wed, 8 Jan 2025 02:08:51 +0100 Subject: [PATCH 2/5] Add groups and user membership for /dev/kfd and /dev/dri/card0 when required --- docker/docker-entrypoint.sh | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/docker/docker-entrypoint.sh b/docker/docker-entrypoint.sh index ac233276de3..0ba8f32133a 100755 --- a/docker/docker-entrypoint.sh +++ b/docker/docker-entrypoint.sh @@ -19,7 +19,25 @@ USER=ubuntu # if the user does not exist, create it. It is expected to be present on ubuntu >=24.x _=$(id ${USER} 2>&1) || useradd -u ${USER_ID} ${USER} # ensure the UID is correct -usermod -u ${USER_ID} ${USER} 1>/dev/null +usermod -u ${USER_ID} ${USER} || true 1>/dev/null +mkdir -p /home/${USER} +chown ${USER} /home/${USER} + +# Add ${USER} in render group when required +if [ -f /dev/kfd ] +then + RENDER_GID=$(stat -c %g /dev/kfd) + _=$(getent group ${RENDER_GID} 2>&1) || groupadd -g ${RENDER_GID} render + usermod -a -G $RENDER_GID $USER +fi + +# Add ${USER} in video group when required +if [ -f /dev/dri/card0 ] +then + VIDEO_GID=$(stat -c %g /dev/dri/card0) + _=$(getent group ${VIDEO_GID} 2>&1) || groupadd ${VIDEO_GID} video + usermod -a -G $VIDEO_GID $USER +fi ### Set the $PUBLIC_KEY env var to enable SSH access. # We do not install openssh-server in the image by default to avoid bloat. From 2afcb151f78be9db0aa43010aa0467fe08b07dc6 Mon Sep 17 00:00:00 2001 From: Christian Bayle Date: Wed, 8 Jan 2025 02:11:55 +0100 Subject: [PATCH 3/5] Add support for rocm5.7 required by some AMD GPUs --- docker/.env.sample | 9 +++++++-- docker/Dockerfile | 5 ++++- docker/docker-compose.yml | 8 ++++++++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/docker/.env.sample b/docker/.env.sample index eef690a8086..1ca1b599927 100644 --- a/docker/.env.sample +++ b/docker/.env.sample @@ -19,8 +19,13 @@ ## INVOKEAI_PORT is the port on which the InvokeAI web interface will be available # INVOKEAI_PORT=9090 -## GPU_DRIVER can be set to either `cuda` or `rocm` to enable GPU support in the container accordingly. -# GPU_DRIVER=cuda #| rocm +## GPU_DRIVER can be set to either `cuda` or `rocm` or `rocm57` to enable GPU support in the container accordingly. +# CARD like RX 7600 XT seems to work only with rocm57 version +# GPU_DRIVER=cuda #| rocm rocm57 + +# For AMD GPU, Depending on your board you may need to comment out one of these +# HSA_OVERRIDE_GFX_VERSION=10.3.0 +# HSA_OVERRIDE_GFX_VERSION=11.0.0 (at least on some RX 7600 XT) ## CONTAINER_UID can be set to the UID of the user on the host system that should own the files in the container. ## It is usually not necessary to change this. Use `id -u` on the host system to find the UID. diff --git a/docker/Dockerfile b/docker/Dockerfile index 657cf1d30db..dddbf0930bf 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -50,7 +50,10 @@ RUN --mount=type=cache,target=/home/ubuntu/.cache/uv,uid=1000,gid=1000 \ if [ "$TARGETPLATFORM" = "linux/arm64" ] || [ "$GPU_DRIVER" = "cpu" ]; then \ extra_index_url_arg="--extra-index-url https://download.pytorch.org/whl/cpu"; \ elif [ "$GPU_DRIVER" = "rocm" ]; then \ - extra_index_url_arg="--extra-index-url https://download.pytorch.org/whl/rocm6.1"; \ + extra_index_url_arg="--extra-index-url https://download.pytorch.org/whl/rocm6.2"; \ + elif [ "$GPU_DRIVER" = "rocm57" ]; then \ + extra_index_url_arg="--extra-index-url https://download.pytorch.org/whl/rocm5.7 \ + torch==2.3.1+rocm5.7 torchvision==0.18.1+rocm5.7 torchaudio==2.3.1+rocm5.7"; \ else \ extra_index_url_arg="--extra-index-url https://download.pytorch.org/whl/cu124"; \ fi && \ diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 0c2b6fbd789..baf39cfa8e6 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -52,3 +52,11 @@ services: - /dev/dri:/dev/dri profiles: - rocm + + invokeai-rocm57: + <<: *invokeai + devices: + - /dev/kfd:/dev/kfd + - /dev/dri:/dev/dri + profiles: + - rocm57 From dee662f3feb5b70d0e1f091f1da939034be6fb15 Mon Sep 17 00:00:00 2001 From: Christian Bayle Date: Wed, 8 Jan 2025 11:46:44 +0100 Subject: [PATCH 4/5] fix if exists test on device --- docker/docker-entrypoint.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/docker-entrypoint.sh b/docker/docker-entrypoint.sh index 0ba8f32133a..21da2e76188 100755 --- a/docker/docker-entrypoint.sh +++ b/docker/docker-entrypoint.sh @@ -24,7 +24,7 @@ mkdir -p /home/${USER} chown ${USER} /home/${USER} # Add ${USER} in render group when required -if [ -f /dev/kfd ] +if [ -c /dev/kfd ] then RENDER_GID=$(stat -c %g /dev/kfd) _=$(getent group ${RENDER_GID} 2>&1) || groupadd -g ${RENDER_GID} render @@ -32,7 +32,7 @@ then fi # Add ${USER} in video group when required -if [ -f /dev/dri/card0 ] +if [ -c /dev/dri/card0 ] then VIDEO_GID=$(stat -c %g /dev/dri/card0) _=$(getent group ${VIDEO_GID} 2>&1) || groupadd ${VIDEO_GID} video From 78345ee89c93ad9b334df507691253060543910d Mon Sep 17 00:00:00 2001 From: Christian Bayle Date: Wed, 8 Jan 2025 11:56:34 +0100 Subject: [PATCH 5/5] revert unwanted change on rocm version for rocm profile --- docker/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index dddbf0930bf..13c681d8c49 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -50,7 +50,7 @@ RUN --mount=type=cache,target=/home/ubuntu/.cache/uv,uid=1000,gid=1000 \ if [ "$TARGETPLATFORM" = "linux/arm64" ] || [ "$GPU_DRIVER" = "cpu" ]; then \ extra_index_url_arg="--extra-index-url https://download.pytorch.org/whl/cpu"; \ elif [ "$GPU_DRIVER" = "rocm" ]; then \ - extra_index_url_arg="--extra-index-url https://download.pytorch.org/whl/rocm6.2"; \ + extra_index_url_arg="--extra-index-url https://download.pytorch.org/whl/rocm6.1"; \ elif [ "$GPU_DRIVER" = "rocm57" ]; then \ extra_index_url_arg="--extra-index-url https://download.pytorch.org/whl/rocm5.7 \ torch==2.3.1+rocm5.7 torchvision==0.18.1+rocm5.7 torchaudio==2.3.1+rocm5.7"; \