-
Notifications
You must be signed in to change notification settings - Fork 2.6k
fix(docker) rocm 6.3 based image #8152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
heathen711
wants to merge
18
commits into
invoke-ai:main
Choose a base branch
from
heathen711:bugfix/heathen711/rocm-docker
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+863
−396
Open
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
c10a6fd
fix(docker) rocm 2.4.6 based image
heathen711 96523ca
fix(docker) Add cloned dockerbuild
heathen711 28e0242
Fix tagging & remove force reinstall
heathen711 47508b8
bugfix(docker) combined the dockerfiles and reduced image size
heathen711 f27471c
bugfix(docker): Use uv.lock for docker, and update to newer index urls.
heathen711 641a6cf
bugfix(docker) Remove the need for UV index as that is now baked into…
heathen711 a3cb3e0
bugfix(ci) Clean up more space for typegen check
heathen711 0db304f
bugfix(uv) Lock torchvision and ensure the docker uses the same rocm …
heathen711 31ca314
Missed files
heathen711 6d7b231
Merge remote-tracking branch 'origin' into bugfix/heathen711/rocm-docker
heathen711 8c5fcfd
cleanup(docker) remove no cache argument
heathen711 233740a
Merge remote-tracking branch 'origin' into bugfix/heathen711/rocm-docker
heathen711 8213f62
bugfix(docker) render group controls the devices, but it needs to mat…
heathen711 3e8e0f6
Merge remote-tracking branch 'origin' into bugfix/heathen711/rocm-docker
heathen711 78eb6b0
cleanup(docker)
heathen711 017d38e
cleanup(github actions)
heathen711 1b6ebed
Revert "cleanup(github actions)"
heathen711 2caa1b1
Merge remote-tracking branch 'origin' into bugfix/heathen711/rocm-docker
heathen711 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
# syntax=docker/dockerfile:1.4 | ||
|
||
#### Web UI ------------------------------------ | ||
|
||
FROM docker.io/node:22-slim AS web-builder | ||
ENV PNPM_HOME="/pnpm" | ||
ENV PATH="$PNPM_HOME:$PATH" | ||
RUN corepack use pnpm@8.x | ||
RUN corepack enable | ||
|
||
WORKDIR /build | ||
COPY invokeai/frontend/web/ ./ | ||
RUN --mount=type=cache,target=/pnpm/store \ | ||
pnpm install --frozen-lockfile | ||
RUN npx vite build | ||
|
||
## Backend --------------------------------------- | ||
|
||
FROM library/ubuntu:24.04 | ||
|
||
ARG DEBIAN_FRONTEND=noninteractive | ||
RUN rm -f /etc/apt/apt.conf.d/docker-clean; echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache | ||
RUN --mount=type=cache,target=/var/cache/apt \ | ||
--mount=type=cache,target=/var/lib/apt \ | ||
apt update && apt install -y --no-install-recommends \ | ||
ca-certificates \ | ||
git \ | ||
gosu \ | ||
libglib2.0-0 \ | ||
libgl1 \ | ||
libglx-mesa0 \ | ||
build-essential \ | ||
libopencv-dev \ | ||
libstdc++-10-dev \ | ||
wget | ||
|
||
ENV \ | ||
PYTHONUNBUFFERED=1 \ | ||
PYTHONDONTWRITEBYTECODE=1 \ | ||
VIRTUAL_ENV=/opt/venv \ | ||
INVOKEAI_SRC=/opt/invokeai \ | ||
PYTHON_VERSION=3.12 \ | ||
UV_PYTHON=3.12 \ | ||
UV_COMPILE_BYTECODE=1 \ | ||
UV_MANAGED_PYTHON=1 \ | ||
UV_LINK_MODE=copy \ | ||
UV_PROJECT_ENVIRONMENT=/opt/venv \ | ||
INVOKEAI_ROOT=/invokeai \ | ||
INVOKEAI_HOST=0.0.0.0 \ | ||
INVOKEAI_PORT=9090 \ | ||
PATH="/opt/venv/bin:$PATH" \ | ||
CONTAINER_UID=${CONTAINER_UID:-1000} \ | ||
CONTAINER_GID=${CONTAINER_GID:-1000} | ||
|
||
ARG GPU_DRIVER=cuda | ||
|
||
# Install `uv` for package management | ||
COPY --from=ghcr.io/astral-sh/uv:0.6.9 /uv /uvx /bin/ | ||
|
||
# Install python & allow non-root user to use it by traversing the /root dir without read permissions | ||
RUN --mount=type=cache,target=/root/.cache/uv \ | ||
uv python install ${PYTHON_VERSION} && \ | ||
# chmod --recursive a+rX /root/.local/share/uv/python | ||
chmod 711 /root | ||
|
||
WORKDIR ${INVOKEAI_SRC} | ||
|
||
# Install project's dependencies as a separate layer so they aren't rebuilt every commit. | ||
# bind-mount instead of copy to defer adding sources to the image until next layer. | ||
# | ||
# NOTE: there are no pytorch builds for arm64 + cuda, only cpu | ||
# x86_64/CUDA is the default | ||
RUN --mount=type=cache,target=/root/.cache/uv \ | ||
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \ | ||
--mount=type=bind,source=uv.lock,target=uv.lock \ | ||
# this is just to get the package manager to recognize that the project exists, without making changes to the docker layer | ||
--mount=type=bind,source=invokeai/version,target=invokeai/version \ | ||
ulimit -n 30000 && \ | ||
uv sync --group $GPU_DRIVER --frozen | ||
|
||
RUN --mount=type=cache,target=/var/cache/apt \ | ||
--mount=type=cache,target=/var/lib/apt \ | ||
if [ "$GPU_DRIVER" = "rocm" ]; then \ | ||
wget -O /tmp/amdgpu-install.deb \ | ||
https://repo.radeon.com/amdgpu-install/6.3.4/ubuntu/noble/amdgpu-install_6.3.60304-1_all.deb && \ | ||
apt install -y /tmp/amdgpu-install.deb && \ | ||
apt update && \ | ||
amdgpu-install --usecase=rocm -y && \ | ||
apt-get autoclean && \ | ||
apt clean && \ | ||
rm -rf /tmp/* /var/tmp/* && \ | ||
usermod -a -G render ubuntu && \ | ||
usermod -a -G video ubuntu && \ | ||
echo "\\n/opt/rocm/lib\\n/opt/rocm/lib64" >> /etc/ld.so.conf.d/rocm.conf && \ | ||
ldconfig && \ | ||
update-alternatives --auto rocm; \ | ||
fi | ||
|
||
## Heathen711: Leaving this for review input, will remove before merge | ||
# RUN --mount=type=cache,target=/var/cache/apt \ | ||
# --mount=type=cache,target=/var/lib/apt \ | ||
# if [ "$GPU_DRIVER" = "rocm" ]; then \ | ||
# groupadd render && \ | ||
# usermod -a -G render ubuntu && \ | ||
# usermod -a -G video ubuntu; \ | ||
# fi | ||
|
||
## Link amdgpu.ids for ROCm builds | ||
## contributed by https://github.com/Rubonnek | ||
# RUN mkdir -p "/opt/amdgpu/share/libdrm" &&\ | ||
# ln -s "/usr/share/libdrm/amdgpu.ids" "/opt/amdgpu/share/libdrm/amdgpu.ids" | ||
|
||
# build patchmatch | ||
RUN cd /usr/lib/$(uname -p)-linux-gnu/pkgconfig/ && ln -sf opencv4.pc opencv.pc | ||
RUN python -c "from patchmatch import patch_match" | ||
|
||
RUN mkdir -p ${INVOKEAI_ROOT} && chown -R ${CONTAINER_UID}:${CONTAINER_GID} ${INVOKEAI_ROOT} | ||
|
||
COPY docker/docker-entrypoint.sh ./ | ||
ENTRYPOINT ["/opt/invokeai/docker-entrypoint.sh"] | ||
CMD ["invokeai-web"] | ||
|
||
# --link requires buldkit w/ dockerfile syntax 1.4, does not work with podman | ||
COPY --link --from=web-builder /build/dist ${INVOKEAI_SRC}/invokeai/frontend/web/dist | ||
|
||
# add sources last to minimize image changes on code changes | ||
COPY invokeai ${INVOKEAI_SRC}/invokeai | ||
|
||
# this should not increase image size because we've already installed dependencies | ||
# in a previous layer | ||
RUN --mount=type=cache,target=/root/.cache/uv \ | ||
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \ | ||
--mount=type=bind,source=uv.lock,target=uv.lock \ | ||
ulimit -n 30000 && \ | ||
uv pip install -e . | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this ulimit doesn't affect much, wondering what's the reason for it here and the value of 30000?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CUDA and CPU doesn't hit the limit, but with ROCM it fails as to many files are being opened. I can try to lower the limit if it concerns you, I just made it something high and was able to continue, so never went back.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doesn't matter much, this only applies during build, it's just really weird that this is needed at all.