Chapter 02

安装与依赖

📌 commit 964f70e上海 AI Lab 的栈:MMEngine + transformers

XTuner 装机比 NeMo 简单、比 Megatron 友好。本章给三条路径和验证脚本。

2.1三条路径

方式命令场景
稳定版pip install -U xtuner常用
含 DeepSpeedpip install -U "xtuner[deepspeed]"多卡用
开发git clone && pip install -e ".[all]"本仓 commit 964f70e

2.2依赖矩阵

版本角色
mmengine>= 0.10★ 训练 Runner
transformers>= 4.45模型源
peft>= 0.11LoRA
deepspeed>= 0.14多机大模型
bitsandbytes>= 0.43QLoRA
accelerate>= 0.27底层
flash-attn>= 2.6性能
lmdeploy>= 0.6推理部署

2.3验证

xtuner list-cfg | head -20         # 看内置 100+ 配置
xtuner --help

2.4仓库结构

xtuner/                            https://github.com/InternLM/xtuner
├── xtuner/
│   ├── tools/                     ★ CLI 入口
│   │   ├── train.py
│   │   ├── chat.py
│   │   ├── test.py
│   │   ├── model_converters/
│   │   └── ...
│   ├── configs/                   ★ 100+ 内置配置
│   │   ├── internlm/
│   │   ├── qwen/
│   │   ├── llama/
│   │   ├── intern_vl/
│   │   ├── llava/
│   │   └── ...
│   ├── dataset/                   数据集处理
│   ├── model/                     模型 wrapper(SFT / DPO / VL)
│   ├── engine/                     MMEngine hook
│   └── utils/
├── docs/                         中英双语
└── tests/

2.5常见装机问题

现象处理
"No module mmengine"pip install mmengine
flash-attn 编译失败用 conda gcc-11;或装预编译 wheel
deepspeed 装不上装 CUDA toolkit;CUDA >= 11.8
"xtuner: command not found"重启 shell;或 python -m xtuner.tools.train ...

2.6这章你需要带走的