温馨提示×

Ubuntu下PyTorch的官方文档在哪里找

小樊
45
2025-12-30 11:58:57
栏目: 智能运维

官方文档入口

  • 主页与安装页:访问 https://pytorch.org,在导航选择 Docs 进入文档,或直接打开 https://pytorch.org/get-started/locally/ 获取按系统、包管理器和 CUDA 版本生成的一键安装命令。
  • 官方文档站点:所有文档统一托管在 https://docs.pytorch.org,包含 API 参考教程版本说明 等。
  • 源码与版本化文档:GitHub 仓库 https://github.com/pytorch/pytorchdocs/ 目录包含文档源码;每个版本都有对应的在线文档(例如 v2.4、v2.5 等),可在 docs.pytorch.org 的版本选择器切换。

Ubuntu用户快速定位

  • Get Started Locally 页面依次选择:LinuxPipConda、你的 Python 版本、所需的 CUDA 版本(或 CPU),页面会生成可直接复制的命令。
  • 若使用 Conda,常见命令示例:
    • CPU:conda install pytorch torchvision torchaudio cpuonly -c pytorch
    • GPU(指定 CUDA):conda install pytorch torchvision torchaudio pytorch-cuda=11.8 -c pytorch -c nvidia
  • 若使用 Pip,常见命令示例:
    • CPU:pip3 install torch torchvision torchaudio
    • GPU(CUDA 12.1):pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121
  • 安装完成后可用以下命令验证:
    • python -c “import torch; print(torch.version)”
    • python -c “import torch; print(torch.cuda.is_available())”

离线查看文档

  • 使用 wgetcurl 下载所需页面或整个站点(示例):
    • wget https://docs.pytorch.org/docs/stable/index.html
  • 也可克隆仓库后在本地构建:
    • git clone https://github.com/pytorch/pytorch
    • 参考仓库 README 中的文档构建说明(需 Sphinx 等工具)。

0