Skip to content

Commit c5aeb36

Browse files
Cu3PO42hipsterusername
authored andcommitted
fix: repair Dockerfile for ROCm
With these changes, the Docker image can be built and executed successfully on hosts with AMD devices with ROCm acceleration. Previously, a ROCm-enabled version of torch would be installed, but later removed during installation of InvokeAI itself. This was caused by InvokeAI needing a newer torch version than was previously installed. The fix consists of multiple components: * Update the hardcoded versions of torch and torchvision to the versions currently used in pyproject.toml, so that a new version need not be installed during installation of InvokeAI. * Specify --extra-index-url on installation of InvokeAI so that even if a verison mismatch occurs, the correct torch version should still be installed. This also necessitates changing --index-url to --extra-index-url for the Torch repo. Otherwise non-torch dependencies would not be found. * In run.sh, build the image for the selected service.
1 parent 5e77f0d commit c5aeb36

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

docker/Dockerfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ ENV INVOKEAI_SRC=/opt/invokeai
1818
ENV VIRTUAL_ENV=/opt/venv/invokeai
1919

2020
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
21-
ARG TORCH_VERSION=2.1.0
22-
ARG TORCHVISION_VERSION=0.16
21+
ARG TORCH_VERSION=2.1.2
22+
ARG TORCHVISION_VERSION=0.16.2
2323
ARG GPU_DRIVER=cuda
2424
ARG TARGETPLATFORM="linux/amd64"
2525
# unused but available
@@ -35,7 +35,7 @@ RUN --mount=type=cache,target=/root/.cache/pip \
3535
if [ "$TARGETPLATFORM" = "linux/arm64" ] || [ "$GPU_DRIVER" = "cpu" ]; then \
3636
extra_index_url_arg="--extra-index-url https://download.pytorch.org/whl/cpu"; \
3737
elif [ "$GPU_DRIVER" = "rocm" ]; then \
38-
extra_index_url_arg="--index-url https://download.pytorch.org/whl/rocm5.6"; \
38+
extra_index_url_arg="--extra-index-url https://download.pytorch.org/whl/rocm5.6"; \
3939
else \
4040
extra_index_url_arg="--extra-index-url https://download.pytorch.org/whl/cu121"; \
4141
fi &&\
@@ -54,7 +54,7 @@ RUN --mount=type=cache,target=/root/.cache/pip \
5454
if [ "$GPU_DRIVER" = "cuda" ] && [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
5555
pip install -e ".[xformers]"; \
5656
else \
57-
pip install -e "."; \
57+
pip install $extra_index_url_arg -e "."; \
5858
fi
5959

6060
# #### Build the Web UI ------------------------------------

docker/run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ run() {
2121
printf "%s\n" "$build_args"
2222
fi
2323

24-
docker compose build $build_args
24+
docker compose build $build_args $service_name
2525
unset build_args
2626

2727
printf "%s\n" "starting service $service_name"

0 commit comments

Comments
 (0)