终于成功Windows 下安装 triton 教程

Installation 安装

Triton accelerates your AI model by compiling things on your computer. It's not a simple package that just works with pip install, and you need to install it in the correct environment.Triton 可通过在您的计算机上编译相关组件来加速您的 AI 模型。它并非一个仅适用于  pip install  的简单软件包,您需要在正确的环境中进行安装。

1. GPU

Check your GPU model. Technically they're categorized by 'compute capability' (also known as 'CUDA arch' or 'sm'), and here I use RTX models for example:检查您的 GPU 型号。从技术上讲,它们是按照“计算能力”(也称为“CUDA 架构”或“sm”)进行分类的,在这里我以 RTX 系列为例:

RTX 50xx (Blackwell) RTX 50xx(Blackwell)

RTX 40xx (Ada) RTX 40xx (Ada)

RTX 30xx (Ampere) RTX 30xx(安)

RTX 20xx (Turing) or olderRTX 20xx(图灵)或更早型号

2. Python environment 2. Python 环境

Check how your Python is installed. Either of the following environments is supported:检查您的 Python 安装情况。以下任一环境均受支持:

  • Embeded: You use an all-in-one package of ComfyUI (or some other AI software), and there is a folder python_embeded in it
    • In this case, don't directly run python, but use the full path C:\path\to\python_embeded\python.exe在这种情况下,请不要直接运行  python ,而是使用完整路径  C:\path\to\python_embeded\python.exe
    • Also, don't directly run pip, but instead run C:\path\to\python_embeded\python.exe -m pip另外,不要直接运行  pip ,而是运行  C:\path\to\python_embeded\python.exe -m pip
    • By default there is no pip.exe in the folder python_embeded. If you directly run pip, you're actually running a pip.exe installed somewhere else on your computer默认情况下,文件夹  python_embeded  中没有  pip.exe 。如果您直接运行  pip ,实际上是在运行安装在您计算机其他位置的  pip.exe 。
    • It's ok to first cd to python_embeded, then run .\python.exe, but remember to add .\ to run an executable in the current folder. In PowerShell, without .\, you're still running a python.exe installed somewhere else on your computer可以先从  cd  切换到  python_embeded ,然后运行  .\python.exe ,但请记住要添加  .\  才能在当前文件夹中运行可执行文件。在 PowerShell 中,如果没有  .\ ,您仍然在运行安装在计算机其他位置的  python.exe  。
    嵌入式:您使用的是 ComfyUI(或其他一些 AI 软件)的一体化安装包,其中有一个名为  python_embeded  的文件夹
  • System-wide: You install Python at a location like C:\Python312\ or C:\Program Files\Python312\ and directly use it系统范围:您将 Python 安装在类似  C:\Python312\  或  C:\Program Files\Python312\  的位置,并直接使用它
  • User-wide: You install Python at a location like C:\Users\<your username>\AppData\Local\Programs\Python\Python312\ and directly use it用户范围:您将 Python 安装在类似  C:\Users\<your username>\AppData\Local\Programs\Python\Python312\  的位置,并直接使用它
  • conda: You create a virtual environment using condaconda:您使用  conda 创建一个虚拟环境
  • Python venv: You create a virtual environment using venv or virtualenvPython 虚拟环境:您可以使用 venv 或 virtualenv 创建虚拟环境

For other environment managers like poetry or uv, if you find problems, please open an issue.对于其他环境管理器,如 poetry 或 uv,如果您发现问题,请提交一个议题。

Make sure what environment you're using. You can run Get-Command -All python in PowerShell (or where python in cmd) to see the installation path of Python, and python --version to see its version. If you see multiple Python installations, make sure that you install and run everything from the first one.请确认您所使用的环境。您可以在 PowerShell 中运行  Get-Command -All python (或在 cmd 中运行  where python )来查看 Python 的安装路径,并运行  python --version  来查看其版本。如果您看到多个 Python 安装,请确保从第一个安装中安装和运行所有内容。

  • For example, if you think you're using Python 3.12, but pip downloads a wheel with cp311 in its name, then it means you're not using the Python environment you think例如,如果您认为自己使用的是 Python 3.12,但 pip 下载的 wheel 文件名中带有  cp311 ,那就意味着您使用的并非您所认为的 Python 环境。

Don't mix two environments, unless you know them very well.除非你对两种环境都非常熟悉,否则不要将它们混在一起。

  • If you're using ComfyUI with embeded Python, then don't use conda or venv如果您使用的是带有嵌入式 Python 的 ComfyUI,那么请勿使用 conda 或 venv。
  • If you're already using conda, then always create a new env using conda, and don't use Python venv如果您已经在使用 conda,那么始终使用 conda 创建新的环境,不要使用 Python 的 venv。

3. PyTorch

Although technically Triton can be used alone, in the following let's assume you use it with PyTorch. Check your PyTorch version:尽管从技术上讲,Triton 可以单独使用,但在接下来的内容中,我们假设您将其与 PyTorch 一起使用。检查您的 PyTorch 版本:

Triton 3.1 works with PyTorch >= 2.4 . PyTorch 2.3 and older are not supported.Triton 3.1 与 PyTorch 2.4 及以上版本兼容。不支持 PyTorch 2.3 及更早版本。

Triton 3.2 works with PyTorch >= 2.6 . If you're using PyTorch < 2.6, I recommend to upgrade to 2.6 because there are several improvements to torch.compile.Triton 3.2 与 PyTorch 2.6 及以上版本兼容。如果您使用的是低于 2.6 版本的 PyTorch,我建议您升级到 2.6 版本,因为该版本对  torch.compile  进行了多项改进。

Triton 3.3 (pre-release) works with PyTorch >= 2.7 (nightly).Triton 3.3(预发布版)与 PyTorch >= 2.7(夜间版)兼容。

PyTorch tagged with CUDA 12 is required. CUDA 11 is not supported.需要安装带有 CUDA 12 标签的 PyTorch。CUDA 11 不受支持。

4. CUDA

Since the release triton-windows==3.2.0.post11, a minimal CUDA toolchain is bundled in the Triton wheels, so you don't need to manually install it.自  triton-windows==3.2.0.post11  版本发布以来,Triton 轮子中已捆绑了一个最小的 CUDA 工具链,因此您无需手动安装。

Triton 3.2 bundles CUDA 12.4, and Triton 3.3 bundles CUDA 12.8 . They should be compatible with other CUDA 12.x because of the minor version compatibility of CUDA. CUDA 11 and older are not supported.

If you need to override the CUDA toolchain, you can set the environment variable CUDA_PATH.如果您需要覆盖 CUDA 工具链,可以设置环境变量  CUDA_PATH  。

Instructions for older or custom wheels without bundled CUDA适用于未捆绑 CUDA 的旧版或自定义轮子的说明

  1.  

  •  

  1.  

5. C compiler 5. C编译器

Since the release triton-windows==3.2.0.post13, TinyCC is bundled in the Triton wheels, so you don't need to manually install a C compiler to use Triton. Packages that directly call triton.jit, such as SageAttention, will just work.自  triton-windows==3.2.0.post13  版本发布以来,TinyCC 已被包含在 Triton 轮子中,因此您无需手动安装 C 编译器即可使用 Triton。直接调用  triton.jit  的包,例如 SageAttention,将可直接运行。

You still need to install a C++ compiler if you use torch.compile targeting CPU. This may happen when you use nodes like 'CompileModel' in ComfyUI. Triton does not affect how PyTorch configures the C++ compiler in this case.如果您使用的是针对 CPU 的  torch.compile ,则仍需要安装 C++ 编译器。这种情况可能会在您在 ComfyUI 中使用诸如 'CompileModel' 之类的节点时发生。在这种情况下,Triton 不会影响 PyTorch 对 C++ 编译器的配置。

If you need to override the C compiler, you can set the environment variable CC. MSVC, GCC, and Clang are supported for the JIT compilation in Triton.如果您需要覆盖 C 编译器,可以设置环境变量  CC 。Triton 的即时编译支持 MSVC、GCC 和 Clang。

Instructions for older or custom wheels without bundled TinyCC适用于未附带 TinyCC 的旧版或自定义轮子的说明

      6. vcredist

      vcredist is required (also known as 'Visual C++ Redistributable for Visual Studio 2015-2022', msvcp140.dllvcruntime140.dll), because libtriton.pyd is compiled by MSVC. Install it from https://aka.ms/vs/17/release/vc_redist.x64.exe需要安装 vcredist(也称为“适用于 Visual Studio 2015 - 2022 的 Visual C++ 重分布组件”, msvcp140.dll , vcruntime140.dll ),因为  libtriton.pyd  是由 MSVC 编译的。请从 https://aka.ms/vs/17/release/vc_redist.x64.exe 安装。

      7. Triton 7. 特里同

      Since the release triton-windows==3.2.0.post11, the wheels are published to triton-windows · PyPI自发布以来,已将 wheels 发布到 https://pypi.org/project/triton-windows/ 。

      If you've installed an old version of triton, first uninstall it:如果您已安装了旧版本的  triton ,请先将其卸载:

      pip uninstall triton
      

      Now you can install triton-windows, or upgrade the already installed version:现在您可以安装  triton-windows ,或者升级已安装的版本:

      pip install -U triton-windows
      

      Note again that if you're using the embeded Python, then instead of directly run pip, you need:请注意,如果您使用的是嵌入式 Python,那么您需要执行以下操作,而不是直接运行  pip  :

      C:\path\to\python_embeded\python.exe -m pip install -U triton-windows
      

      For Triton 3.1, you need:对于 Triton 3.1,您需要:

      pip install -U 'triton-windows<3.2'
      

      For Triton 3.3 (pre-release), you need:对于 Triton 3.3(预发布版),您需要:

      pip install -U --pre triton-windows
      评论
      添加红包

      请填写红包祝福语或标题

      红包个数最小为10个

      红包金额最低5元

      当前余额3.43前往充值 >
      需支付:10.00
      成就一亿技术人!
      领取后你会自动成为博主和红包主的粉丝 规则
      hope_wisdom
      发出的红包
      实付
      使用余额支付
      点击重新获取
      扫码支付
      钱包余额 0

      抵扣说明:

      1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
      2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

      余额充值