安装说明¶
前提条件:torchtune 需要 PyTorch,因此请使用 本地安装 页面,为您的目标主机和环境安装相应版本。
通过 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 .
安装夜间构建¶
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”。