Skip to content

Commit

Permalink
Merge pull request #2219 from bmaltais/dev
Browse files Browse the repository at this point in the history
v23.1.0
  • Loading branch information
bmaltais committed Apr 7, 2024
2 parents ed10bf7 + b452f4c commit 16b9209
Show file tree
Hide file tree
Showing 102 changed files with 4,521 additions and 3,274 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/typos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ jobs:
- uses: actions/checkout@v4

- name: typos-action
uses: crate-ci/typos@v1.18.2
uses: crate-ci/typos@v1.19.0
2 changes: 1 addition & 1 deletion .release
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v23.0.15
v23.1.0
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"python.linting.enabled": true,
"python.formatting.provider": "yapf",
"DockerRun.DisableDockerrc": true,
"augment.enableAutomaticCompletions": false
"augment.enableAutomaticCompletions": true
}
52 changes: 39 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ ARG PIP_NO_WARN_SCRIPT_LOCATION=0
ARG PIP_ROOT_USER_ACTION="ignore"

# Install build dependencies
RUN apt-get update && apt-get upgrade -y && \
apt-get install -y --no-install-recommends python3-launchpadlib git curl && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
RUN --mount=type=cache,id=apt-$TARGETARCH$TARGETVARIANT,sharing=locked,target=/var/cache/apt \
--mount=type=cache,id=aptlists-$TARGETARCH$TARGETVARIANT,sharing=locked,target=/var/lib/apt/lists \
apt-get update && apt-get upgrade -y && \
apt-get install -y --no-install-recommends python3-launchpadlib git curl

# Install PyTorch and TensorFlow
# The versions must align and be in sync with the requirements_linux_docker.txt
Expand All @@ -44,24 +44,49 @@ RUN --mount=type=cache,id=pip-$TARGETARCH$TARGETVARIANT,sharing=locked,target=/r

# Replace pillow with pillow-simd (Only for x86)
ARG TARGETPLATFORM
RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
RUN --mount=type=cache,id=apt-$TARGETARCH$TARGETVARIANT,sharing=locked,target=/var/cache/apt \
--mount=type=cache,id=aptlists-$TARGETARCH$TARGETVARIANT,sharing=locked,target=/var/lib/apt/lists \
if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
apt-get update && apt-get install -y --no-install-recommends zlib1g-dev libjpeg62-turbo-dev build-essential && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* && \
pip uninstall -y pillow && \
CC="cc -mavx2" pip install -U --force-reinstall pillow-simd; \
fi

FROM python:3.10-slim as final

ARG TARGETARCH
ARG TARGETVARIANT

ENV NVIDIA_VISIBLE_DEVICES all
ENV NVIDIA_DRIVER_CAPABILITIES compute,utility

WORKDIR /tmp

ENV CUDA_VERSION=12.1.1
ENV NV_CUDA_CUDART_VERSION=12.1.105-1
ENV NVIDIA_REQUIRE_CUDA=cuda>=12.1
ENV NV_CUDA_COMPAT_PACKAGE=cuda-compat-12-1

# Install CUDA partially
ADD https://developer.download.nvidia.com/compute/cuda/repos/debian11/x86_64/cuda-keyring_1.0-1_all.deb .
RUN --mount=type=cache,id=apt-$TARGETARCH$TARGETVARIANT,sharing=locked,target=/var/cache/apt \
--mount=type=cache,id=aptlists-$TARGETARCH$TARGETVARIANT,sharing=locked,target=/var/lib/apt/lists \
dpkg -i cuda-keyring_1.0-1_all.deb && \
rm cuda-keyring_1.0-1_all.deb && \
sed -i 's/^Components: main$/& contrib/' /etc/apt/sources.list.d/debian.sources && \
apt-get update && \
apt-get install -y --no-install-recommends \
# Installing the whole CUDA typically increases the image size by approximately **8GB**.
# To decrease the image size, we opt to install only the necessary libraries.
# Here is the package list for your reference: https://developer.download.nvidia.com/compute/cuda/repos/debian11/x86_64
# !If you experience any related issues, replace the following line with `cuda-12-1` to obtain the complete CUDA package.
cuda-cudart-12-1=${NV_CUDA_CUDART_VERSION} ${NV_CUDA_COMPAT_PACKAGE} libcusparse-12-1 libnvjitlink-12-1

# Install runtime dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends libgl1 libglib2.0-0 libjpeg62 libtcl8.6 libtk8.6 libgoogle-perftools-dev dumb-init && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
RUN --mount=type=cache,id=apt-$TARGETARCH$TARGETVARIANT,sharing=locked,target=/var/cache/apt \
--mount=type=cache,id=aptlists-$TARGETARCH$TARGETVARIANT,sharing=locked,target=/var/lib/apt/lists \
apt-get update && \
apt-get install -y --no-install-recommends libgl1 libglib2.0-0 libjpeg62 libtcl8.6 libtk8.6 libgoogle-perftools-dev dumb-init

# Fix missing libnvinfer7
RUN ln -s /usr/lib/x86_64-linux-gnu/libnvinfer.so /usr/lib/x86_64-linux-gnu/libnvinfer.so.7 && \
Expand All @@ -84,8 +109,9 @@ COPY --link --chmod=775 LICENSE.md /licenses/LICENSE.md
COPY --link --chown=$UID:0 --chmod=775 --from=build /root/.local /home/$UID/.local
COPY --link --chown=$UID:0 --chmod=775 . /app

ENV PATH="/home/$UID/.local/bin:$PATH"
ENV PATH="/usr/local/cuda/lib:/usr/local/cuda/lib64:/home/$UID/.local/bin:$PATH"
ENV PYTHONPATH="${PYTHONPATH}:/home/$UID/.local/lib/python3.10/site-packages"
ENV LD_LIBRARY_PATH="/usr/local/cuda/lib:/usr/local/cuda/lib64:${LD_LIBRARY_PATH}"
ENV LD_PRELOAD=libtcmalloc.so
ENV PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python

Expand All @@ -103,7 +129,7 @@ STOPSIGNAL SIGINT

# Use dumb-init as PID 1 to handle signals properly
ENTRYPOINT ["dumb-init", "--"]
CMD ["python3", "kohya_gui.py", "--listen", "0.0.0.0", "--server_port", "7860"]
CMD ["python3", "kohya_gui.py", "--listen", "0.0.0.0", "--server_port", "7860", "--headless"]

ARG VERSION
ARG RELEASE
Expand Down
Loading

0 comments on commit 16b9209

Please sign in to comment.