Skip to content

Instantly share code, notes, and snippets.

@thr3a
Last active May 7, 2024 15:11
Show Gist options
  • Save thr3a/5dbc7a3849309f1454bcb2ce5f5d893b to your computer and use it in GitHub Desktop.
Save thr3a/5dbc7a3849309f1454bcb2ce5f5d893b to your computer and use it in GitHub Desktop.
techbookfest-16
version: "3"
services:
app:
build:
context: .
dockerfile: Dockerfile
image: kohya:latest
stop_grace_period: 0s
ipc: host
tty: true
deploy:
resources:
reservations:
devices:
- driver: nvidia
device_ids: ['1']
capabilities: [gpu]
volumes:
- ./:/app
- ./cache:/root/.cache
- /home/thr3a/lora-trains:/data
# command: sleep infinity
# command: python tools/resize_images_to_resolution.py --max_resolution 1024x1024 --save_as_png --interpolation lanczos4 --copy_associated_files /data/ebifly/orig /data/ebifly/train/
command: accelerate launch --num_cpu_threads_per_process 8 sdxl_train_network.py --config_file=/data/ebifly/config.toml --dataset_config /data/ebifly/database.toml
# sha256:21196d81f56b48dbee70494d5f10322e1a77cc47ffe202a3bf68eab81533c20f
FROM --platform=linux/x86_64 nvcr.io/nvidia/cuda:12.1.1-cudnn8-devel-ubuntu22.04
# マウント時にパーミッションエラーを避けるためにホスト側のUID,GIDに合わせてください
# IDはidコマンドで確認できます。 例えばuid=2000(thr3a) gid=2000(thr3a) …と表示された場合2箇所を2000に変更します。
ARG UID=1000
ARG GID=1000
ARG PYTHON_VERSION=3.11
ARG PACKAGES="git curl ca-certificates vim wget unzip build-essential cmake jq libopencv-dev"
ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=Asia/Tokyo
ENV PYTHONUNBUFFERED=1
ENV PIP_NO_CACHE_DIR=on
ENV PYTHONDONTWRITEBYTECODE=1
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv f23c5a6cf475977595c89f51ba6932366a755776 \
&& echo "deb http://ppa.launchpadcontent.net/deadsnakes/ppa/ubuntu jammy main" > /etc/apt/sources.list.d/python.list \
&& echo "deb-src http://ppa.launchpad.net/deadsnakes/ppa/ubuntu jammy main" >> /etc/apt/sources.list.d/python.list
RUN apt-get update \
&& apt-get install -y --no-install-recommends ${PACKAGES} python${PYTHON_VERSION} \
&& ln -nfs /usr/bin/python${PYTHON_VERSION} /usr/bin/python \
&& ln -nfs /usr/bin/python${PYTHON_VERSION} /usr/bin/python3 \
&& rm -rf /var/lib/apt/lists/* \
&& curl -sSL https://bootstrap.pypa.io/get-pip.py | python -
RUN groupadd -g $UID user && \
useradd -m -s /bin/bash -u $UID -g $GID user
WORKDIR /app
ADD ./setup.py ./
ADD ./requirements.txt ./
RUN pip install -U torch torchvision xformers==0.0.24 --index-url https://download.pytorch.org/whl/cu121
RUN pip install -U pip && pip install -r requirements.txt
USER user
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment