目录

安装说明

Pre-requisites

torchtune 需要 PyTorch,因此请使用 “本地启动” 页面为您的主机和环境进行安装。您还应该安装 torchvision(用于多模态大语言模型)和 torchao(用于量化 API)。您可以使用以下命令安装稳定版或夜间构建版本:

# Install stable version of PyTorch libraries using pip
pip install torch torchvision torchao

# Or nightly install for latest features
pip install --pre torch torchvision torchao --index-url https://download.pytorch.org/whl/nightly/cu121 # full options are cpu/cu118/cu121/cu124

通过 PyPI 安装

torchtune 的最新稳定版本托管在 PyPI 上,可以通过以下命令下载:

pip install torchtune

要确认包已正确安装,您可以运行以下命令:

tune

并应看到以下输出:

usage: tune [-h] {download,ls,cp,run,validate} ...

Welcome to the torchtune CLI!

options:
-h, --help            show this help message and exit

...

通过 git clone安装 ¶

如果你想要从torchtune获取最新的功能,或者如果你想成为贡献者,你也可以使用以下命令在本地安装该包。

git clone https://github.com/pytorch/torchtune.git
cd torchtune
pip install -e .

# or for a developer installation
pip install -e .["dev"]

安装夜间构建

torchtune 每个晚上都会使用 main 分支的最新提交构建。如果您希望安装包的最新更新,但又不想通过 git clone 安装,请使用以下命令进行安装:

pip install --pre torchtune --extra-index-url https://download.pytorch.org/whl/nightly/cpu --no-cache-dir

注意

--no-cache-dir 将指示 pip 不查找 torchtune 的缓存版本,从而覆盖您现有的 torchtune 安装。

如果您已经安装了 PyTorch,torchtune 将默认使用该版本。但是,如果您想使用 PyTorch 的 nightly 版本,可以在上述命令中附加 --force-reinstall 选项。如果您选择这种安装方法,可能需要将索引 URL 中的“cpu”后缀更改为与您的 CUDA 版本匹配。例如,如果您运行的是 CUDA 12,您的索引 URL 应为“https://download.pytorch.org/whl/nightly/cu121”。

文档

访问 PyTorch 的全面开发人员文档

查看文档

教程

获取面向初学者和高级开发人员的深入教程

查看教程

资源

查找开发资源并解答您的问题

查看资源