Skip to content

Commit a4048b7

Browse files
authored
[assets] fix docker images (#8203)
1 parent 73b12ba commit a4048b7

File tree

13 files changed

+56
-40
lines changed

13 files changed

+56
-40
lines changed

.dockerignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
.github
44
.venv
55
cache
6-
data
76
docker
87
saves
98
hf_cache
109
ms_cache
1110
om_cache
11+
shared_data
1212
output
1313
.dockerignore
1414
.gitattributes

.github/workflows/push_docker.yml renamed to .github/workflows/docker.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: push_docker
1+
name: docker
22

33
on:
44
workflow_dispatch:
@@ -32,7 +32,15 @@ jobs:
3232
url: https://hub.docker.com/r/hiyouga/llamafactory
3333

3434
steps:
35-
- name: Checkout repository
35+
- name: Free up disk space
36+
run: |
37+
df -h
38+
sudo rm -rf /usr/share/dotnet
39+
sudo rm -rf /opt/ghc
40+
sudo rm -rf /opt/hostedtoolcache
41+
df -h
42+
43+
- name: Checkout
3644
uses: actions/checkout@v4
3745

3846
- name: Set up Docker Buildx

README.md

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -474,16 +474,25 @@ huggingface-cli login
474474
> [!IMPORTANT]
475475
> Installation is mandatory.
476476
477+
#### Install from Source
478+
477479
```bash
478480
git clone --depth 1 https://github.com/hiyouga/LLaMA-Factory.git
479481
cd LLaMA-Factory
480482
pip install -e ".[torch,metrics]" --no-build-isolation
481483
```
482484

483-
Extra dependencies available: torch, torch-npu, metrics, deepspeed, liger-kernel, bitsandbytes, hqq, eetq, gptq, aqlm, vllm, sglang, galore, apollo, badam, adam-mini, qwen, minicpm_v, modelscope, openmind, swanlab, quality
485+
Extra dependencies available: torch, torch-npu, metrics, deepspeed, liger-kernel, bitsandbytes, hqq, eetq, gptq, aqlm, vllm, sglang, galore, apollo, badam, adam-mini, qwen, minicpm_v, modelscope, openmind, swanlab, dev
484486

485-
> [!TIP]
486-
> Use `pip install -e . --no-deps --no-build-isolation` to resolve package conflicts.
487+
#### Install from Docker Image
488+
489+
```bash
490+
docker run -it --rm --gpus=all --ipc=host hiyouga/llamafactory:latest
491+
```
492+
493+
Find the pre-built images: https://hub.docker.com/r/hiyouga/llamafactory/tags
494+
495+
Please refer to [build docker](#build-docker) to build the image yourself.
487496

488497
<details><summary>Setting up a virtual environment with <b>uv</b></summary>
489498

@@ -671,7 +680,7 @@ docker run -dit --ipc=host --gpus=all \
671680
-v ./hf_cache:/root/.cache/huggingface \
672681
-v ./ms_cache:/root/.cache/modelscope \
673682
-v ./om_cache:/root/.cache/openmind \
674-
-v ./data:/app/data \
683+
-v ./shared_data:/app/shared_data \
675684
-v ./output:/app/output \
676685
-p 7860:7860 \
677686
-p 8000:8000 \
@@ -686,14 +695,14 @@ For Ascend NPU users:
686695
```bash
687696
docker build -f ./docker/docker-npu/Dockerfile \
688697
--build-arg PIP_INDEX=https://pypi.org/simple \
689-
--build-arg EXTRAS=metrics \
698+
--build-arg EXTRAS=torch-npu,metrics \
690699
-t llamafactory:latest .
691700

692701
docker run -dit --ipc=host \
693702
-v ./hf_cache:/root/.cache/huggingface \
694703
-v ./ms_cache:/root/.cache/modelscope \
695704
-v ./om_cache:/root/.cache/openmind \
696-
-v ./data:/app/data \
705+
-v ./shared_data:/app/shared_data \
697706
-v ./output:/app/output \
698707
-v /usr/local/dcmi:/usr/local/dcmi \
699708
-v /usr/local/bin/npu-smi:/usr/local/bin/npu-smi \
@@ -723,7 +732,7 @@ docker run -dit --ipc=host \
723732
-v ./hf_cache:/root/.cache/huggingface \
724733
-v ./ms_cache:/root/.cache/modelscope \
725734
-v ./om_cache:/root/.cache/openmind \
726-
-v ./data:/app/data \
735+
-v ./shared_data:/app/shared_data \
727736
-v ./output:/app/output \
728737
-p 7860:7860 \
729738
-p 8000:8000 \
@@ -742,7 +751,7 @@ docker exec -it llamafactory bash
742751
- `hf_cache`: Utilize Hugging Face cache on the host machine. Reassignable if a cache already exists in a different directory.
743752
- `ms_cache`: Similar to Hugging Face cache but for ModelScope users.
744753
- `om_cache`: Similar to Hugging Face cache but for Modelers users.
745-
- `data`: Place datasets on this dir of the host machine so that they can be selected on LLaMA Board GUI.
754+
- `shared_data`: Place datasets on this dir of the host machine so that they can be selected on LLaMA Board GUI.
746755
- `output`: Set export dir to this location so that the merged result can be accessed directly on the host machine.
747756

748757
</details>

README_zh.md

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -476,16 +476,25 @@ huggingface-cli login
476476
> [!IMPORTANT]
477477
> 此步骤为必需。
478478
479+
#### 从源码安装
480+
479481
```bash
480482
git clone --depth 1 https://github.com/hiyouga/LLaMA-Factory.git
481483
cd LLaMA-Factory
482484
pip install -e ".[torch,metrics]" --no-build-isolation
483485
```
484486

485-
可选的额外依赖项:torch、torch-npu、metrics、deepspeed、liger-kernel、bitsandbytes、hqq、eetq、gptq、aqlm、vllm、sglang、galore、apollo、badam、adam-mini、qwen、minicpm_v、modelscope、openmind、swanlab、quality
487+
可选的额外依赖项:torch、torch-npu、metrics、deepspeed、liger-kernel、bitsandbytes、hqq、eetq、gptq、aqlm、vllm、sglang、galore、apollo、badam、adam-mini、qwen、minicpm_v、modelscope、openmind、swanlab、dev
486488

487-
> [!TIP]
488-
> 遇到包冲突时,可使用 `pip install -e . --no-deps --no-build-isolation` 解决。
489+
#### 从镜像安装
490+
491+
```bash
492+
docker run -it --rm --gpus=all --ipc=host hiyouga/llamafactory:latest
493+
```
494+
495+
查看全部镜像:https://hub.docker.com/r/hiyouga/llamafactory/tags
496+
497+
请参阅[构建 Docker](#构建-docker) 来重新构建镜像。
489498

490499
<details><summary>使用 <b>uv</b> 构建虚拟环境</summary>
491500

@@ -673,7 +682,7 @@ docker run -dit --ipc=host --gpus=all \
673682
-v ./hf_cache:/root/.cache/huggingface \
674683
-v ./ms_cache:/root/.cache/modelscope \
675684
-v ./om_cache:/root/.cache/openmind \
676-
-v ./data:/app/data \
685+
-v ./shared_data:/app/shared_data \
677686
-v ./output:/app/output \
678687
-p 7860:7860 \
679688
-p 8000:8000 \
@@ -688,14 +697,14 @@ docker exec -it llamafactory bash
688697
```bash
689698
docker build -f ./docker/docker-npu/Dockerfile \
690699
--build-arg PIP_INDEX=https://pypi.org/simple \
691-
--build-arg EXTRAS=metrics \
700+
--build-arg EXTRAS=torch-npu,metrics \
692701
-t llamafactory:latest .
693702

694703
docker run -dit --ipc=host \
695704
-v ./hf_cache:/root/.cache/huggingface \
696705
-v ./ms_cache:/root/.cache/modelscope \
697706
-v ./om_cache:/root/.cache/openmind \
698-
-v ./data:/app/data \
707+
-v ./shared_data:/app/shared_data \
699708
-v ./output:/app/output \
700709
-v /usr/local/dcmi:/usr/local/dcmi \
701710
-v /usr/local/bin/npu-smi:/usr/local/bin/npu-smi \
@@ -725,7 +734,7 @@ docker run -dit --ipc=host \
725734
-v ./hf_cache:/root/.cache/huggingface \
726735
-v ./ms_cache:/root/.cache/modelscope \
727736
-v ./om_cache:/root/.cache/openmind \
728-
-v ./data:/app/data \
737+
-v ./shared_data:/app/shared_data \
729738
-v ./output:/app/output \
730739
-p 7860:7860 \
731740
-p 8000:8000 \
@@ -744,7 +753,7 @@ docker exec -it llamafactory bash
744753
- `hf_cache`:使用宿主机的 Hugging Face 缓存文件夹,允许更改为新的目录。
745754
- `ms_cache`:类似 Hugging Face 缓存文件夹,为 ModelScope 用户提供。
746755
- `om_cache`:类似 Hugging Face 缓存文件夹,为 Modelers 用户提供。
747-
- `data`:宿主机中存放数据集的文件夹路径。
756+
- `shared_data`:宿主机中存放数据集的文件夹路径。
748757
- `output`:将导出目录设置为该路径后,即可在宿主机中访问导出后的模型。
749758

750759
</details>

docker/docker-cuda/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# https://hub.docker.com/r/hiyouga/pytorch/tags
2-
ARG BASE_IMAGE=hiyouga/pytorch:th2.6.0-cu124-flashattn2.7.4-cxx11abi0
2+
ARG BASE_IMAGE=hiyouga/pytorch:th2.6.0-cu124-flashattn2.7.4-cxx11abi0-devel
33
FROM ${BASE_IMAGE}
44

55
# Installation arguments
@@ -47,7 +47,7 @@ RUN if [ "${INSTALL_FLASHATTN}" == "true" ]; then \
4747
fi
4848

4949
# Set up volumes
50-
VOLUME [ "/root/.cache/huggingface", "/root/.cache/modelscope", "/root/.cache/openmind", "/app/data", "/app/output" ]
50+
VOLUME [ "/root/.cache/huggingface", "/root/.cache/modelscope", "/root/.cache/openmind", "/app/shared_data", "/app/output" ]
5151

5252
# Expose port 7860 for LLaMA Board
5353
ENV GRADIO_SERVER_PORT=7860

docker/docker-cuda/Dockerfile.base

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Start from the pytorch official image (ubuntu-22.04 + cuda-12.4.1 + python-3.11)
22
# https://hub.docker.com/r/pytorch/pytorch/tags
3-
FROM pytorch/pytorch:2.6.0-cuda12.4-cudnn9-runtime
3+
FROM pytorch/pytorch:2.6.0-cuda12.4-cudnn9-devel
44

55
# Define environments
66
ENV MAX_JOBS=16

docker/docker-cuda/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ services:
1111
- ../../hf_cache:/root/.cache/huggingface
1212
- ../../ms_cache:/root/.cache/modelscope
1313
- ../../om_cache:/root/.cache/openmind
14-
- ../../data:/app/data
14+
- ../../shared_data:/app/shared_data
1515
- ../../output:/app/output
1616
ports:
1717
- "7860:7860"

docker/docker-npu/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ FROM ${BASE_IMAGE}
44

55
# Installation arguments
66
ARG PIP_INDEX=https://pypi.org/simple
7-
ARG EXTRAS=metrics
7+
ARG EXTRAS=torch-npu,metrics
88
ARG HTTP_PROXY=""
99

1010
# Define environments
@@ -39,7 +39,7 @@ COPY . /app
3939
RUN pip install --no-cache-dir -e ".[${EXTRAS}]" --no-build-isolation
4040

4141
# Set up volumes
42-
VOLUME [ "/root/.cache/huggingface", "/root/.cache/modelscope", "/root/.cache/openmind", "/app/data", "/app/output" ]
42+
VOLUME [ "/root/.cache/huggingface", "/root/.cache/modelscope", "/root/.cache/openmind", "/app/shared_data", "/app/output" ]
4343

4444
# Expose port 7860 for LLaMA Board
4545
ENV GRADIO_SERVER_PORT=7860

docker/docker-npu/docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ services:
55
context: ../..
66
args:
77
PIP_INDEX: https://pypi.org/simple
8-
EXTRAS: metrics
8+
EXTRAS: torch-npu,metrics
99
container_name: llamafactory
1010
volumes:
1111
- ../../hf_cache:/root/.cache/huggingface
1212
- ../../ms_cache:/root/.cache/modelscope
1313
- ../../om_cache:/root/.cache/openmind
14-
- ../../data:/app/data
14+
- ../../shared_data:/app/shared_data
1515
- ../../output:/app/output
1616
- /usr/local/dcmi:/usr/local/dcmi
1717
- /usr/local/bin/npu-smi:/usr/local/bin/npu-smi

docker/docker-rocm/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ RUN if [ "${INSTALL_FLASHATTN}" == "true" ]; then \
5252
fi
5353

5454
# Set up volumes
55-
VOLUME [ "/root/.cache/huggingface", "/root/.cache/modelscope", "/root/.cache/openmind", "/app/data", "/app/output" ]
55+
VOLUME [ "/root/.cache/huggingface", "/root/.cache/modelscope", "/root/.cache/openmind", "/app/shared_data", "/app/output" ]
5656

5757
# Expose port 7860 for LLaMA Board
5858
ENV GRADIO_SERVER_PORT=7860

docker/docker-rocm/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ services:
1111
- ../../hf_cache:/root/.cache/huggingface
1212
- ../../ms_cache:/root/.cache/modelscope
1313
- ../../om_cache:/root/.cache/openmind
14-
- ../../data:/app/data
14+
- ../../shared_data:/app/shared_data
1515
- ../../output:/app/output
1616
ports:
1717
- "7860:7860"

pyproject.toml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,4 @@ conflicts = [
9292
{ extra = "torch-npu" },
9393
{ extra = "sglang" },
9494
],
95-
[
96-
{ extra = "vllm" },
97-
{ extra = "sglang" },
98-
],
99-
[
100-
{ extra = "sglang" },
101-
{ extra = "minicpm_v" },
102-
],
10395
]

setup.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def get_console_scripts() -> list[str]:
4545
"torch": ["torch>=2.0.0", "torchvision>=0.15.0"],
4646
"torch-npu": ["torch==2.4.0", "torch-npu==2.4.0.post2", "decorator"],
4747
"metrics": ["nltk", "jieba", "rouge-chinese"],
48-
"deepspeed": ["deepspeed>=0.10.0,<=0.16.5"],
48+
"deepspeed": ["deepspeed>=0.10.0,<=0.16.9"],
4949
"liger-kernel": ["liger-kernel>=0.5.5"],
5050
"bitsandbytes": ["bitsandbytes>=0.39.0"],
5151
"hqq": ["hqq"],
@@ -58,7 +58,6 @@ def get_console_scripts() -> list[str]:
5858
"apollo": ["apollo-torch"],
5959
"badam": ["badam>=1.2.1"],
6060
"adam-mini": ["adam-mini"],
61-
"qwen": ["transformers_stream_generator"],
6261
"minicpm_v": [
6362
"soundfile",
6463
"torchvision",
@@ -68,7 +67,6 @@ def get_console_scripts() -> list[str]:
6867
"msgpack",
6968
"referencing",
7069
"jsonschema_specifications",
71-
"transformers==4.48.3",
7270
],
7371
"modelscope": ["modelscope"],
7472
"openmind": ["openmind"],

0 commit comments

Comments
 (0)