安装说明¶
先决条件¶
torchtune 需要 PyTorch,因此请根据您的主机和环境进行安装 使用“本地启动”页面。您还应该安装 torchvision (用于多模态 LLM)和 torchao (用于量化 API)。您可以安装 stable 或 nightly 版本,其中包含以下命令:
# 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"]
安装 nightly build¶
Torchtune 每天晚上都会使用对 Branch 的最新提交进行构建。如果您需要最新的更新
到包中,而不通过 进行安装,您可以使用以下命令进行安装:main
git clone
pip install --pre torchtune --extra-index-url https://download.pytorch.org/whl/nightly/cpu --no-cache-dir
注意
--no-cache-dir
将直接不查找 torchtune 的缓存版本,从而覆盖
您现有的 Torchtune 安装。pip
如果您已经安装了 PyTorch,则 torchtune 将默认使用该版本。但是,如果您想
使用 nightly 版本的 PyTorch,您可以将选项附加到上述命令中。如果你
选择此安装方法,您可能需要更改索引 URL 中的“cpu”后缀以匹配您的 CUDA
版本。例如,如果您运行的是 CUDA 12,则索引 URL 将为 “https://download.pytorch.org/whl/nightly/cu121”。--force-reinstall