Skip to content

build(docker): switch from pip to uv for package management #3229

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

Merged

Conversation

jim60105
Copy link
Contributor

@jim60105 jim60105 commented May 10, 2025

This PR updates the Dockerfile by:

I conducted a LoRA training for testing this PR (with Podman + Fedora)
as my knowledge is limited to LoRA on training😆

- Upgrade base image from Python 3.10 to Python 3.11 slim on Debian Bullseye.
- Replace manual PyTorch and dependencies installation with uv environment management and installation.
- Add installation of large dependencies (torch, triton, tensorflow, onnxruntime-gpu) explicitly to optimize image layer caching.
- Switch from pip to uv for package management and dependency synchronization.
- Replace pillow with pillow-simd on amd64 architecture using uv-managed pip for performance improvements.
- Adjust environment variables to use the virtual environment under /venv instead of local user installs.
- Create /venv directory with appropriate permissions and copy the virtual environment from build stage.
- Modify CMD to add --noverify flag when launching kohya_gui.py.
- Remove requirements_linux_docker.txt file, consolidating dependency management into uv and pyproject.toml.

Signed-off-by: CHEN, CHUN <[email protected]>
@bmaltais
Copy link
Owner

This look great! I will merge iT, nice PR!

@bmaltais bmaltais merged commit 44cca1c into bmaltais:dev May 24, 2025
1 check failed
@okingjo
Copy link

okingjo commented May 24, 2025

Still get error: error: Failed to inspect Python interpreter from search path at /usr/bin/python3, looks like the path for python is not set properly,
Got fixed temporarily with the follwoing:
FROM docker.io/library/python:3.10-slim-bullseye AS base instead of FROM docker.io/library/python:3.11-slim-bullseye AS base
add RUN pip install --no-cache-dir -U "uv>=0.5.24" && uv --version after COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
add --python /usr/local/bin/python3.10 --no-managed-python --no-python-downloads for uv sync in install dependencies

@jim60105 jim60105 deleted the feat/use-uv-installation-in-dockerfile branch May 24, 2025 14:44
@jim60105
Copy link
Contributor Author

@okingjo I have successfully built on the current dev branch.
https://github.com/jim60105/kohya_ss/actions/runs/15228159494/job/42832717750

It might be an issue with your platform.
Perhaps try to use docker build --no-cache to avoid build cache issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants