diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index 4826a0ab6e..32393ec11e 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -49,9 +49,7 @@ jobs: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | type=match,pattern=\d.\d.\d,enable=${{ github.event_name == 'release' }} - type=sha,enable=${{ github.event_name == 'release' }} type=raw,value=${{ github.event.inputs.version }},enable=${{ github.event_name == 'workflow_dispatch' }} - type=sha,enable=${{ github.event_name == 'workflow_dispatch' }} # 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. # 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. # It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step. diff --git a/README.md b/README.md index d0e319603a..5a7255ebb5 100644 --- a/README.md +++ b/README.md @@ -181,10 +181,29 @@ git clone https://github.com/modelscope/Trinity-RFT cd Trinity-RFT ``` -##### 2. Set Up a Virtual Environment +##### 2. Set Up Environment Choose one of the following options: +##### Using Pre-built Docker Image (Recommended for Beginners) + +We provide a pre-built Docker image with GPU-related dependencies installed. + +```bash +docker pull ghcr.io/modelscope/trinity-rft:latest + +# Run the container, replacing with your actual path +docker run -it \ + --gpus all \ + --shm-size="64g" \ + --rm \ + -v $PWD:/workspace \ + -v :/data \ + ghcr.io/modelscope/trinity-rft:latest +``` + +> 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. + ###### Using Conda ```bash @@ -230,7 +249,6 @@ uv sync --extra vllm --extra dev --extra flash_attn # uv sync --extra tinker --extra dev ``` - #### Via PyPI If you just want to use the package without modifying the code: @@ -247,29 +265,6 @@ uv pip install trinity-rft uv pip install flash-attn==2.8.1 ``` - -#### Using Docker - -We provide a Docker setup for hassle-free environment configuration. - -```bash -git clone https://github.com/modelscope/Trinity-RFT -cd Trinity-RFT - -# Build the Docker image -## Tip: You can modify the Dockerfile to add mirrors or set API keys -docker build -f scripts/docker/Dockerfile -t trinity-rft:latest . - -# Run the container, replacing with your actual path -docker run -it \ - --gpus all \ - --shm-size="64g" \ - --rm \ - -v $PWD:/workspace \ - -v :/data \ - trinity-rft:latest -``` - > For training with **Megatron-LM**, please refer to [Megatron-LM Backend](https://modelscope.github.io/Trinity-RFT/en/main/tutorial/example_megatron.html). ### Step 2: prepare dataset and model diff --git a/README_zh.md b/README_zh.md index 9197031c22..0667367fb6 100644 --- a/README_zh.md +++ b/README_zh.md @@ -181,10 +181,28 @@ git clone https://github.com/modelscope/Trinity-RFT cd Trinity-RFT ``` -### 2. 创建虚拟环境 +### 2. 构建环境 可选择以下任一方式: +#### 使用预构建 Docker 镜像(推荐初学者使用该方法) + + +```bash +docker pull ghcr.io/modelscope/trinity-rft:latest + +# 将 替换为实际需要挂载的路径 +docker run -it \ + --gpus all \ + --shm-size="64g" \ + --rm \ + -v $PWD:/workspace \ + -v :/data \ + ghcr.io/modelscope/trinity-rft:latest +``` + +> 该镜像已经通过 `uv` 安装了 Trinity-RFT 以及所有 GPU 相关依赖,且会自动激活虚拟环境(也可通过 `source /opt/venv/bin/activate` 手动激活)。必要时可使用 `uv pip install` 添加额外的包。 + #### 使用 Conda ```bash @@ -246,28 +264,6 @@ uv pip install trinity-rft uv pip install flash-attn==2.8.1 ``` -## 使用 Docker - -我们提供了 Docker 环境,方便快速配置。 - -```bash -git clone https://github.com/modelscope/Trinity-RFT -cd Trinity-RFT - -# 构建 Docker 镜像 -## 提示:可根据需要修改 Dockerfile 添加镜像源或设置 API 密钥 -docker build -f scripts/docker/Dockerfile -t trinity-rft:latest . - -# 运行容器,请将 替换为实际需要挂载的路径 -docker run -it \ - --gpus all \ - --shm-size="64g" \ - --rm \ - -v $PWD:/workspace \ - -v :/data \ - trinity-rft:latest -``` - > 如需使用 **Megatron-LM** 进行训练,请参考 [Megatron-LM 支持](https://modelscope.github.io/Trinity-RFT/zh/main/tutorial/example_megatron.html) @@ -338,8 +334,6 @@ trinity studio --port 8080 - - ### 第四步:运行 RFT 流程 diff --git a/docs/sphinx_doc/source/tutorial/trinity_installation.md b/docs/sphinx_doc/source/tutorial/trinity_installation.md index 8523518515..d86a8af903 100644 --- a/docs/sphinx_doc/source/tutorial/trinity_installation.md +++ b/docs/sphinx_doc/source/tutorial/trinity_installation.md @@ -1,24 +1,28 @@ (Installation)= # Installation -For installing Trinity-RFT, you have three options: from source (recommended), via PyPI, or using Docker. +For installing Trinity-RFT, you have three options: from source (recommended for experienced users), using Docker (recommended for beginners) or via PyPI. **Before you begin**, check your system setup: -### If you have GPUs and want to use them: +### If you have GPUs and want to use them + Make sure your system meets these requirements: + - **Python**: 3.10 – 3.12 - **CUDA**: 12.8 or higher - **GPUs**: At least 2 available -### If you don’t have GPUs (or prefer not to use them): +### If you don’t have GPUs or prefer not to use them + You can use the `tinker` option instead, which only requires: + - **Python**: 3.11 – 3.12 - **GPUs**: Not required --- -## From Source (Recommended) +## From Source (Recommended for experienced users) This method is best if you plan to customize or contribute to Trinity-RFT. @@ -100,7 +104,31 @@ uv pip install flash-attn==2.8.1 ## Using Docker -We provide a Docker setup for hassle-free environment configuration. +You can download the Trinity-RFT Docker image from Github Container Registry or build it locally. + +### Pull from GitHub Container Registry (Recommended for beginners) + +```bash +git clone https://github.com/modelscope/Trinity-RFT +cd Trinity-RFT + +docker pull ghcr.io/modelscope/trinity-rft:latest + +docker run -it \ + --gpus all \ + --shm-size="64g" \ + --rm \ + -v $PWD:/workspace \ + -v :/data \ + ghcr.io/modelscope/trinity-rft:latest +``` + +```{note} +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. +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. +``` + +### Build Locally ```bash git clone https://github.com/modelscope/Trinity-RFT @@ -120,12 +148,12 @@ docker run -it \ trinity-rft:latest ``` +--- + ```{note} For training with **Megatron-LM**, please refer to {ref}`Megatron-LM Backend `. ``` ---- - ## Troubleshooting If you encounter installation issues, refer to the FAQ or [GitHub Issues](https://github.com/modelscope/Trinity-RFT/issues). diff --git a/docs/sphinx_doc/source_zh/tutorial/trinity_installation.md b/docs/sphinx_doc/source_zh/tutorial/trinity_installation.md index 4244af0021..1b5e52bc71 100644 --- a/docs/sphinx_doc/source_zh/tutorial/trinity_installation.md +++ b/docs/sphinx_doc/source_zh/tutorial/trinity_installation.md @@ -1,24 +1,28 @@ (Installation)= # 安装指南 -安装 Trinity-RFT 有三种方式:源码安装(推荐)、通过 PyPI 安装,或使用 Docker。 +安装 Trinity-RFT 有三种方式:源码安装(推荐有经验的用户使用该方法)、使用 Docker (推荐初学者使用该方法) 或是从 PyPI 安装。 **开始之前**,请检查您的系统配置: -### 如果您拥有 GPU 并希望使用它们: +### 如果您有 GPU 并希望使用它们 + 请确保您的系统满足以下要求: + - **Python**:3.10 – 3.12 - **CUDA**:12.8 或更高版本 - **GPU**:至少 2 块可用 -### 如果您没有 GPU(或不希望使用 GPU): +### 如果您没有 GPU 或不希望使用 GPU + 您可以改用 `tinker` 选项,该选项仅需满足: + - **Python**:3.11 – 3.12 - **GPU**:无需 --- -## 源码安装(推荐) +## 源码安装(推荐有经验的用户使用该方法) 如需修改、扩展 Trinity-RFT,推荐使用此方法。 @@ -80,27 +84,34 @@ uv sync --extra vllm --extra dev --extra flash_attn --- -## 通过 PyPI 安装 +## 使用 Docker -如果您只需使用 Trinity-RFT 而不打算修改代码: +您可以从 Github 拉取 Docker 镜像或是自行构建镜像。 + +### 从 Github 拉取预构建镜像 (推荐初学者使用该方法) ```bash -pip install trinity-rft -pip install flash-attn==2.8.1 -``` +git clone https://github.com/modelscope/Trinity-RFT +cd Trinity-RFT -或使用 `uv`: +docker pull ghcr.io/modelscope/trinity-rft:latest -```bash -uv pip install trinity-rft -uv pip install flash-attn==2.8.1 +docker run -it \ + --gpus all \ + --shm-size="64g" \ + --rm \ + -v $PWD:/workspace \ + -v :/data \ + ghcr.io/modelscope/trinity-rft:latest ``` ---- +```{note} +该 Docker 镜像使用 `uv` 来管理 Python 依赖,进入容器后虚拟环境会自动激活(也可通过 `source /opt/venv/bin/activate` 手动激活)。 +该镜像已经包含了 vllm, flash-attn 以及 Megatron-LM,如果需要使用其他依赖,可直接使用 `uv pip install` 来安装它们。 +``` -## 使用 Docker +### 自行构建 Docker 镜像 -我们提供了 Docker 环境,方便快速配置。 ```bash git clone https://github.com/modelscope/Trinity-RFT @@ -120,11 +131,30 @@ docker run -it \ trinity-rft:latest ``` +--- + +## 通过 PyPI 安装 + +如果您只需使用 Trinity-RFT 而不打算修改代码: + +```bash +pip install trinity-rft +pip install flash-attn==2.8.1 +``` + +或使用 `uv`: + +```bash +uv pip install trinity-rft +uv pip install flash-attn==2.8.1 +``` + +--- + ```{note} 如需使用 **Megatron-LM** 进行训练,请参考 {ref}`Megatron-LM Backend `。 ``` ---- ## 常见问题