分析解决【No module named ‘triton‘】的问题

(一)现象

在Windows11下训练Stable-Diffusion的LoRA模型的时候,总是重复提示:

A matching Triton is not available, some optimizations will not be enabled.
Error caught was: No module named ‘triton’

意思是:

没有匹配的 Triton,一些优化将不会被启用。
捕获的错误是: 没有名为 "TRITON "的模块

虽然过程并不会中断,但是看着好难受。

(二)分析

上网搜了一下,应该是 xformers 需要用到 Triton 进行优化工作。

网上有人说:

并没有Windows下的Triton,所以Windows下会报错,而Linux就有Triton。

直接安装果然没有:

> pip install triton
ERROR: Could not find a version that satisfies the requirement triton (from versions: none)
ERROR: No matching distribution found for triton

看了下https://github.com/openai/tritonhttps://triton-lang.org/https://pypi.org/project/triton/
果然哪里都没有提供Windows的二进制下载,难道要自己编译?

但实际上有大神编译了Windows下二进制:
🔗triton-2.0.0-cp310-cp310-win_amd64.whl

(三)安装

下载triton-2.0.0-cp310-cp310-win_amd64.whl后安装:
⚠️根据实际情况,你可能也需要安装在项目虚拟环境中,请参考(3.1)章节。

> python.exe -m pip install triton-2.0.0-cp310-cp310-win_amd64.whl

结果又又提示要CMake……且自动下载cmake-3.26.3-py2.py3-none-win_amd64.whl巨慢无比,天朝网络啊……
只好用迅雷下载,参考页面:🔗https://pypi.org/project/cmake/#files
然后手动安装。
⚠️根据实际情况,你可能也需要安装在项目虚拟环境中,请参考(3.1)章节。

> python.exe -m pip install cmake-3.26.3-py2.py3-none-win_amd64.whl
> python.exe -m pip install triton-2.0.0-cp310-cp310-win_amd64.whl

(3.1)项目虚拟环境

不好意思之前没说清楚。

上面的安装,我这里都需要装在 >>项目的虚拟环境<<中,不能直接python.exe执行装在本机自身环境里。
需要进入项目目录,然后下面这样:
👇👇👇👇👇👇

> .\venv\Scripts\python.exe -m pip install triton-2.0.0-cp310-cp310-win_amd64.whl

☝☝☝☝☝☝

(3.2)环境版本问题

评论区有反馈说报错:

triton-2.0.0-cp310-cp310-win_amd64.whl is not a supported wheel on this platform

我检查了,确认这个triton链接和我本地安装的确实是同一个文件(SHA256:)。

那是不是报错环境的问题呢?python或pip版本不支持这个?我无法确定,自己看看,不支持就升级嘛。
我的是python 3.10pip 23.0.1。并且查看是支持它的,如下:

PS D:\lora-scripts> .\venv\Scripts\python.exe -m pip debug --verbose

WARNING: This command is only meant for debugging. Do not use this with automation for parsing and getting these details, since the output and options of this command may change without notice.
pip version: pip 23.0.1 from D:\lora-scripts\venv\lib\site-packages\pip (python 3.10)
sys.version: 3.10.11 (tags/v3.10.11:7d4cc5a, Apr  5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)]
sys.executable: D:\lora-scripts\venv\Scripts\python.exe
sys.getdefaultencoding: utf-8
sys.getfilesystemencoding: utf-8
locale.getpreferredencoding: cp936
sys.platform: win32
sys.implementation:
  name: cpython
'cert' config value: Not specified
pip._vendor.certifi.where(): D:\lora-scripts\venv\lib\site-packages\pip\_vendor\certifi\cacert.pem
pip._vendor.DEBUNDLED: False
vendored library versions:
  CacheControl==0.12.11
  colorama==0.4.6
  distlib==0.3.6
  distro==1.8.0
  msgpack==1.0.4
  packaging==21.3
  platformdirs==2.6.2
  pyparsing==3.0.9
  pyproject-hooks==1.0.0
  requests==2.28.2
  certifi==2022.12.07
  chardet==5.1.0
  idna==3.4
  urllib3==1.26.14
  ……太多了省略掉
Compatible tags: 36
  cp310-cp310-win_amd64 #就是这个地方,看看你的支持吗,cp310?
  cp310-abi3-win_amd64
  cp310-none-win_amd64
  cp39-abi3-win_amd64
  cp38-abi3-win_amd64
  cp37-abi3-win_amd64
  cp36-abi3-win_amd64
  cp35-abi3-win_amd64
  cp34-abi3-win_amd64
  ……
PS D:\lora-scripts>

以上✋


然后就OK了,那边的训练PowerShell窗口里就不报错了。

(三)与主题无关

PS:继续吐槽一下咱的网络,好像56kbps猫上网的时代(是的,乖乖用国内源吧,比如清华大学):
在这里插入图片描述

  • 44
    点赞
  • 65
    收藏
    觉得还不错? 一键收藏
  • 37
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 37
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值