安装和配置gpt-oss-recipes仓库的步骤如下:
- 克隆仓库:通过命令
git clone https://github.com/huggingface/gpt-oss-recipes.git
克隆仓库到本地。 - 创建虚拟环境:使用Python 3.11创建虚拟环境,推荐使用
uv
工具,命令为uv venv gpt-oss --python 3.11
,并激活环境。 - 安装依赖:升级pip后安装PyTorch和Transformers等必要包,命令为
uv pip install torch==2.8.0 torchvision torchaudio --index-url https://download.pytorch.org/whl/test/cu128
和uv pip install -U transformers accelerate
。 - 可选安装Triton内核:若硬件支持MXFP4量化(如H100或RTX 50xx),可通过命令
uv pip install git+https://github.com/triton-lang/triton.git@main#subdirectory=python/triton_kernels
安装。
完成以上步骤后,即可开始使用仓库中的脚本和教程。
本答案来源于文章《微调OpenAI GPT OSS模型的脚本和教程集合》