Skip to content

Commit 8e1adfd

Browse files
authored
[Doc] Update docker install guide (#469)
1 parent ded6d23 commit 8e1adfd

File tree

5 files changed

+121
-76
lines changed

5 files changed

+121
-76
lines changed

.github/workflows/docker.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@ jobs:
4949
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
5050
tags: |
5151
type=match,pattern=\d.\d.\d,enable=${{ github.event_name == 'release' }}
52-
type=sha,enable=${{ github.event_name == 'release' }}
5352
type=raw,value=${{ github.event.inputs.version }},enable=${{ github.event_name == 'workflow_dispatch' }}
54-
type=sha,enable=${{ github.event_name == 'workflow_dispatch' }}
5553
# This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages.
5654
# It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see [Usage](https://github.com/docker/build-push-action#usage) in the README of the `docker/build-push-action` repository.
5755
# It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step.

README.md

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,29 @@ git clone https://github.com/modelscope/Trinity-RFT
181181
cd Trinity-RFT
182182
```
183183

184-
##### 2. Set Up a Virtual Environment
184+
##### 2. Set Up Environment
185185

186186
Choose one of the following options:
187187

188+
##### Using Pre-built Docker Image (Recommended for Beginners)
189+
190+
We provide a pre-built Docker image with GPU-related dependencies installed.
191+
192+
```bash
193+
docker pull ghcr.io/modelscope/trinity-rft:latest
194+
195+
# Run the container, replacing <path_to_your_data_and_checkpoints> with your actual path
196+
docker run -it \
197+
--gpus all \
198+
--shm-size="64g" \
199+
--rm \
200+
-v $PWD:/workspace \
201+
-v <path_to_your_data_and_checkpoints>:/data \
202+
ghcr.io/modelscope/trinity-rft:latest
203+
```
204+
205+
> This image has used `uv` to install all GPU-related dependencies of Trinity-RFT. The virtual environment will be automatically activated upon entering the container (you can also manually activate it via `source /opt/venv/bin/activate` if needed). You can use `uv pip install` to add extra packages as necessary.
206+
188207
###### Using Conda
189208

190209
```bash
@@ -230,7 +249,6 @@ uv sync --extra vllm --extra dev --extra flash_attn
230249
# uv sync --extra tinker --extra dev
231250
```
232251

233-
234252
#### Via PyPI
235253

236254
If you just want to use the package without modifying the code:
@@ -247,29 +265,6 @@ uv pip install trinity-rft
247265
uv pip install flash-attn==2.8.1
248266
```
249267

250-
251-
#### Using Docker
252-
253-
We provide a Docker setup for hassle-free environment configuration.
254-
255-
```bash
256-
git clone https://github.com/modelscope/Trinity-RFT
257-
cd Trinity-RFT
258-
259-
# Build the Docker image
260-
## Tip: You can modify the Dockerfile to add mirrors or set API keys
261-
docker build -f scripts/docker/Dockerfile -t trinity-rft:latest .
262-
263-
# Run the container, replacing <path_to_your_data_and_checkpoints> with your actual path
264-
docker run -it \
265-
--gpus all \
266-
--shm-size="64g" \
267-
--rm \
268-
-v $PWD:/workspace \
269-
-v <path_to_your_data_and_checkpoints>:/data \
270-
trinity-rft:latest
271-
```
272-
273268
> For training with **Megatron-LM**, please refer to [Megatron-LM Backend](https://modelscope.github.io/Trinity-RFT/en/main/tutorial/example_megatron.html).
274269
275270
### Step 2: prepare dataset and model

README_zh.md

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,28 @@ git clone https://github.com/modelscope/Trinity-RFT
181181
cd Trinity-RFT
182182
```
183183

184-
### 2. 创建虚拟环境
184+
### 2. 构建环境
185185

186186
可选择以下任一方式:
187187

188+
#### 使用预构建 Docker 镜像(推荐初学者使用该方法)
189+
190+
191+
```bash
192+
docker pull ghcr.io/modelscope/trinity-rft:latest
193+
194+
# 将 <path_to_your_data_and_checkpoints> 替换为实际需要挂载的路径
195+
docker run -it \
196+
--gpus all \
197+
--shm-size="64g" \
198+
--rm \
199+
-v $PWD:/workspace \
200+
-v <path_to_your_data_and_checkpoints>:/data \
201+
ghcr.io/modelscope/trinity-rft:latest
202+
```
203+
204+
> 该镜像已经通过 `uv` 安装了 Trinity-RFT 以及所有 GPU 相关依赖,且会自动激活虚拟环境(也可通过 `source /opt/venv/bin/activate` 手动激活)。必要时可使用 `uv pip install` 添加额外的包。
205+
188206
#### 使用 Conda
189207

190208
```bash
@@ -246,28 +264,6 @@ uv pip install trinity-rft
246264
uv pip install flash-attn==2.8.1
247265
```
248266

249-
## 使用 Docker
250-
251-
我们提供了 Docker 环境,方便快速配置。
252-
253-
```bash
254-
git clone https://github.com/modelscope/Trinity-RFT
255-
cd Trinity-RFT
256-
257-
# 构建 Docker 镜像
258-
## 提示:可根据需要修改 Dockerfile 添加镜像源或设置 API 密钥
259-
docker build -f scripts/docker/Dockerfile -t trinity-rft:latest .
260-
261-
# 运行容器,请将 <path_to_your_data_and_checkpoints> 替换为实际需要挂载的路径
262-
docker run -it \
263-
--gpus all \
264-
--shm-size="64g" \
265-
--rm \
266-
-v $PWD:/workspace \
267-
-v <path_to_your_data_and_checkpoints>:/data \
268-
trinity-rft:latest
269-
```
270-
271267
> 如需使用 **Megatron-LM** 进行训练,请参考 [Megatron-LM 支持](https://modelscope.github.io/Trinity-RFT/zh/main/tutorial/example_megatron.html)
272268
273269

@@ -338,8 +334,6 @@ trinity studio --port 8080
338334
</details>
339335

340336

341-
342-
343337
### 第四步:运行 RFT 流程
344338

345339

docs/sphinx_doc/source/tutorial/trinity_installation.md

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,28 @@
11
(Installation)=
22
# Installation
33

4-
For installing Trinity-RFT, you have three options: from source (recommended), via PyPI, or using Docker.
4+
For installing Trinity-RFT, you have three options: from source (recommended for experienced users), using Docker (recommended for beginners) or via PyPI.
55

66
**Before you begin**, check your system setup:
77

8-
### If you have GPUs and want to use them:
8+
### If you have GPUs and want to use them
9+
910
Make sure your system meets these requirements:
11+
1012
- **Python**: 3.10 – 3.12
1113
- **CUDA**: 12.8 or higher
1214
- **GPUs**: At least 2 available
1315

14-
### If you don’t have GPUs (or prefer not to use them):
16+
### If you don’t have GPUs or prefer not to use them
17+
1518
You can use the `tinker` option instead, which only requires:
19+
1620
- **Python**: 3.11 – 3.12
1721
- **GPUs**: Not required
1822

1923
---
2024

21-
## From Source (Recommended)
25+
## From Source (Recommended for experienced users)
2226

2327
This method is best if you plan to customize or contribute to Trinity-RFT.
2428

@@ -100,7 +104,31 @@ uv pip install flash-attn==2.8.1
100104

101105
## Using Docker
102106

103-
We provide a Docker setup for hassle-free environment configuration.
107+
You can download the Trinity-RFT Docker image from Github Container Registry or build it locally.
108+
109+
### Pull from GitHub Container Registry (Recommended for beginners)
110+
111+
```bash
112+
git clone https://github.com/modelscope/Trinity-RFT
113+
cd Trinity-RFT
114+
115+
docker pull ghcr.io/modelscope/trinity-rft:latest
116+
117+
docker run -it \
118+
--gpus all \
119+
--shm-size="64g" \
120+
--rm \
121+
-v $PWD:/workspace \
122+
-v <path_to_your_data_and_checkpoints>:/data \
123+
ghcr.io/modelscope/trinity-rft:latest
124+
```
125+
126+
```{note}
127+
This docker image use `uv` to manage python packages, you need to activate the virtual environment using `source /opt/venv/bin/activate` after entering the docker container.
128+
The image has include dependencies such as vllm, flash-attn and Megatron-LM, if you need to download more packages, don't forget to activate the virtual environment and use `uv pip install` to install them.
129+
```
130+
131+
### Build Locally
104132

105133
```bash
106134
git clone https://github.com/modelscope/Trinity-RFT
@@ -120,12 +148,12 @@ docker run -it \
120148
trinity-rft:latest
121149
```
122150

151+
---
152+
123153
```{note}
124154
For training with **Megatron-LM**, please refer to {ref}`Megatron-LM Backend <Megatron-LM>`.
125155
```
126156

127-
---
128-
129157
## Troubleshooting
130158

131159
If you encounter installation issues, refer to the FAQ or [GitHub Issues](https://github.com/modelscope/Trinity-RFT/issues).

docs/sphinx_doc/source_zh/tutorial/trinity_installation.md

Lines changed: 47 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,28 @@
11
(Installation)=
22
# 安装指南
33

4-
安装 Trinity-RFT 有三种方式:源码安装(推荐)、通过 PyPI 安装,或使用 Docker
4+
安装 Trinity-RFT 有三种方式:源码安装(推荐有经验的用户使用该方法)、使用 Docker (推荐初学者使用该方法) 或是从 PyPI 安装。
55

66
**开始之前**,请检查您的系统配置:
77

8-
### 如果您拥有 GPU 并希望使用它们:
8+
### 如果您有 GPU 并希望使用它们
9+
910
请确保您的系统满足以下要求:
11+
1012
- **Python**:3.10 – 3.12
1113
- **CUDA**:12.8 或更高版本
1214
- **GPU**:至少 2 块可用
1315

14-
### 如果您没有 GPU(或不希望使用 GPU):
16+
### 如果您没有 GPU 或不希望使用 GPU
17+
1518
您可以改用 `tinker` 选项,该选项仅需满足:
19+
1620
- **Python**:3.11 – 3.12
1721
- **GPU**:无需
1822

1923
---
2024

21-
## 源码安装(推荐
25+
## 源码安装(推荐有经验的用户使用该方法
2226

2327
如需修改、扩展 Trinity-RFT,推荐使用此方法。
2428

@@ -80,27 +84,34 @@ uv sync --extra vllm --extra dev --extra flash_attn
8084

8185
---
8286

83-
## 通过 PyPI 安装
87+
## 使用 Docker
8488

85-
如果您只需使用 Trinity-RFT 而不打算修改代码:
89+
您可以从 Github 拉取 Docker 镜像或是自行构建镜像。
90+
91+
### 从 Github 拉取预构建镜像 (推荐初学者使用该方法)
8692

8793
```bash
88-
pip install trinity-rft
89-
pip install flash-attn==2.8.1
90-
```
94+
git clone https://github.com/modelscope/Trinity-RFT
95+
cd Trinity-RFT
9196

92-
或使用 `uv`
97+
docker pull ghcr.io/modelscope/trinity-rft:latest
9398

94-
```bash
95-
uv pip install trinity-rft
96-
uv pip install flash-attn==2.8.1
99+
docker run -it \
100+
--gpus all \
101+
--shm-size="64g" \
102+
--rm \
103+
-v $PWD:/workspace \
104+
-v <path_to_your_data_and_checkpoints>:/data \
105+
ghcr.io/modelscope/trinity-rft:latest
97106
```
98107

99-
---
108+
```{note}
109+
该 Docker 镜像使用 `uv` 来管理 Python 依赖,进入容器后虚拟环境会自动激活(也可通过 `source /opt/venv/bin/activate` 手动激活)。
110+
该镜像已经包含了 vllm, flash-attn 以及 Megatron-LM,如果需要使用其他依赖,可直接使用 `uv pip install` 来安装它们。
111+
```
100112

101-
## 使用 Docker
113+
### 自行构建 Docker 镜像
102114

103-
我们提供了 Docker 环境,方便快速配置。
104115

105116
```bash
106117
git clone https://github.com/modelscope/Trinity-RFT
@@ -120,11 +131,30 @@ docker run -it \
120131
trinity-rft:latest
121132
```
122133

134+
---
135+
136+
## 通过 PyPI 安装
137+
138+
如果您只需使用 Trinity-RFT 而不打算修改代码:
139+
140+
```bash
141+
pip install trinity-rft
142+
pip install flash-attn==2.8.1
143+
```
144+
145+
或使用 `uv`
146+
147+
```bash
148+
uv pip install trinity-rft
149+
uv pip install flash-attn==2.8.1
150+
```
151+
152+
---
153+
123154
```{note}
124155
如需使用 **Megatron-LM** 进行训练,请参考 {ref}`Megatron-LM Backend <Megatron-LM>`。
125156
```
126157

127-
---
128158

129159
## 常见问题
130160

0 commit comments

Comments
 (0)