Skip to content

Commit 0843781

Browse files
committed
organize dockerfiles
1 parent f82947a commit 0843781

File tree

5 files changed

+64
-7
lines changed

5 files changed

+64
-7
lines changed

.github/workflows/docker.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ jobs:
4747
with:
4848
context: .
4949
push: true
50-
file: scripts/docker_for_megatron/Dockerfile
50+
file: scripts/docker/Dockerfile.uv
5151
shm-size: 64g
5252
tags: ${{ steps.meta.outputs.tags }}
5353
labels: ${{ steps.meta.outputs.labels }}
54-
54+
5555
# This step generates an artifact attestation for the image, which is an unforgeable statement about where and how it was built. It increases supply chain security for people who consume the image. For more information, see [Using artifact attestations to establish provenance for builds](/actions/security-guides/using-artifact-attestations-to-establish-provenance-for-builds).
5656
- name: Generate artifact attestation
5757
uses: actions/attest-build-provenance@v3

docs/sphinx_doc/source/tutorial/example_megatron.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ We provide a Docker setup to simplify environment management.
3838
#### Build the Docker Image
3939

4040

41-
Trinity-RFT provides a dedicated Dockerfile for Megatron-LM located at `scripts/docker_for_megatron/Dockerfile`. You can build the image using the following command:
41+
Trinity-RFT provides a dedicated Dockerfile for Megatron-LM located at `scripts/docker/Dockerfile.megatron`. You can build the image using the following command:
4242

4343
```bash
44-
docker build -f scripts/docker_for_megatron/Dockerfile -t trinity-rft-megatron:latest .
44+
docker build -f scripts/docker/Dockerfile.megatron -t trinity-rft-megatron:latest .
4545
```
4646

4747
> 💡 You can customize the Dockerfile before building — for example, to add pip mirrors or set API keys.

docs/sphinx_doc/source_zh/tutorial/example_megatron.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ pip install -v --disable-pip-version-check --no-cache-dir --no-build-isolation \
4343

4444
#### 构建 Docker 镜像
4545

46-
Trinity-RFT 提供了专门用于 Megatron-LM 的 Dockerfile,位于 `scripts/docker_for_megatron/Dockerfile`
46+
Trinity-RFT 提供了专门用于 Megatron-LM 的 Dockerfile,位于 `scripts/docker/Dockerfile.megatron`
4747
可以使用以下命令构建镜像:
4848

4949
```bash
50-
docker build -f scripts/docker_for_megatron/Dockerfile -t trinity-rft-megatron:latest .
50+
docker build -f scripts/docker/Dockerfile.megatron -t trinity-rft-megatron:latest .
5151
```
5252

5353
> 💡 你可以在构建前自定义 Dockerfile —— 例如添加 pip 镜像源或设置 API 密钥。

scripts/docker_for_megatron/Dockerfile renamed to scripts/docker/Dockerfile.megatron

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Build and run the docker image with the following command:
22
#
33
# cd <Trinity-RFT root dir>
4-
# docker build -f scripts/docker_for_megatron/Dockerfile -t trinity-rft-megatron:latest .
4+
# docker build -f scripts/docker/Dockerfile.megatron -t trinity-rft-megatron:latest .
55
# docker run -it --gpus all --shm-size="64g" --rm -v $PWD:/workspace -v <root_path_of_data_and_checkpoints>:/data trinity-rft-megatron:latest
66

77

scripts/docker/Dockerfile.uv

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Build and run the docker image with the following command:
2+
#
3+
# cd <Trinity-RFT root dir>
4+
# docker build -f scripts/docker/Dockerfile.uv -t trinity-rft:latest .
5+
# docker run -it --gpus all --shm-size="64g" --rm -v $PWD:/workspace -v <root_path_of_data_and_checkpoints>:/data trinity-rft:latest
6+
7+
8+
FROM nvcr.io/nvidia/cuda:12.8.1-cudnn-devel-ubuntu22.04
9+
10+
WORKDIR /workspace
11+
12+
RUN chmod 1777 /tmp && apt update && apt install -y \
13+
build-essential \
14+
curl git wget vim tmux net-tools \
15+
python3 python3-pip python3-dev python3-packaging python3-venv \
16+
libomp-dev infiniband-diags libibverbs-dev librdmacm-dev rdma-core perftest \
17+
&& rm -rf /var/lib/apt/lists/* \
18+
&& ln -sf /usr/bin/python3 /usr/bin/python \
19+
&& ln -sf /usr/bin/pip3 /usr/bin/pip
20+
21+
# For Aliyun users: update pip mirror to aliyun to speed up pip install
22+
# RUN pip config set global.index-url http://mirrors.cloud.aliyuncs.com/pypi/simple/ \
23+
# && pip config set install.trusted-host mirrors.cloud.aliyuncs.com
24+
25+
ENV VIRTUAL_ENV=/opt/venv
26+
27+
# copy the Trinity-RFT dir into the workspace
28+
COPY . .
29+
30+
# Install uv
31+
RUN pip install uv && uv venv /opt/venv --python=python3.12
32+
33+
# Install minimal Trinity-RFT
34+
RUN . /opt/venv/bin/activate && \
35+
uv pip install -e.[mm,dev]
36+
37+
# Install flash_attn and Megatron
38+
RUN . /opt/venv/bin/activate && \
39+
uv pip install -e.[flash_attn] && \
40+
uv pip install -e .[megatron] && \
41+
uv pip install -v --no-build-isolation \
42+
--config-settings="--build-option=--cpp_ext" \
43+
--config-settings="--build-option=--cuda_ext" \
44+
git+https://github.com/NVIDIA/apex.git
45+
46+
# Set Env variables
47+
48+
# WANDB
49+
# ENV WANDB_API_KEY=
50+
# ENV WANDB_BASE_URL=
51+
52+
# LLM API
53+
# ENV OPENAI_API_KEY=
54+
# ENV DASH_API_KEY=
55+
56+
ENTRYPOINT ["/bin/bash", "-c", "source /opt/venv/bin/activate && exec \"$@\"", "--"]
57+
CMD ["bash"]

0 commit comments

Comments
 (0)