1. 报错信息
WARNING[XFORMERS]: xFormers can't load C++/CUDA extensions. xFormers was built for:
PyTorch 2.4.1+cu121 with CUDA 1201 (you have 2.7.1+cu126)
Python 3.9.20 (you have 3.9.23)
Please reinstall xformers (see https://github.com/facebookresearch/xformers#installing-xformers)
Memory-efficient attention, SwiGLU, sparse and more won't be available.
Set XFORMERS_MORE_DETAILS=1 for more details
Traceback (most recent call last):
File "<frozen importlib._bootstrap>", line 1030, in gcdimport
File "<frozen importlib._bootstrap>", line 1007, in findand_load
File "<frozen importlib._bootstrap>", line 972, in findand_load_unlocked
File "<frozen importlib._bootstrap>", line 228, in callwith_frames_removed
File "<frozen importlib._bootstrap>", line 1030, in gcdimport
File "<frozen importlib._bootstrap>", line 1007, in findand_load
File "<frozen importlib._bootstrap>", line 986, in findand_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in loadunlocked
File "<frozen importlib._bootstrap_external>", line 850, in exec_module
File "<frozen importlib._bootstrap>", line 228, in callwith_frames_removed
AttributeError: Cannot set attribute 'src' directly. Use '_unsafe_update_src()' and manually clear .hash of all callersinstead.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
RuntimeError: Failed to import diffusers.models.autoencoders.autoencoder_kl because of the following error (look up to see its traceback):
Cannot set attribute 'src' directly. Use ' _unsafe_update_src() ' and manually clear .hash of all callersinstead.
运行时错误:由于以下错误,无法导入diffusers.models.autoencoders.autoencoder_kl(查找以查看其回溯):无法直接设置属性“src”。使用“_unsafe_update_src()”并手动清除所有调用者的.hash。
2. 解决方案
warning先提示xformer版本不兼容,参照官方文档进行重新安装,我这里是cuda12.6版本:
# [linux & win] cuda 12.6 version
pip3 install -U xformers --index-url https://download.pytorch.org/whl/cu126
显然由于某些原因还需要换源:
# [linux & win] cuda 12.6 version
pip3 install -U xformers --index-url https://mirrors.nju.edu.cn/whl/cu126
南大源似乎并没有更新xformers,这里使用的官方指令安装,不然会提示安装torch2.4版本的:
ERROR: Could not find a version that satisfies the requirement torch==2.4.1 (from xformers) (from versions: none)
ERROR: No matching distribution found for torch==2.4.1
使用官方地址顺利更新到了xformers的0.0.31版本,问题解决。
评论