Resshift项目遇到的问题与解决
下列问题的出现,源自readme.md文件中以下代码的执行。
部署问题
下列问题的出现,源自readme.md文件中以下代码的执行。
conda create -n resshift python=3.10
conda activate resshift
pip install -r requirements.txt
问题1:NotImplementedError: No operator found for `memory_efficient_attention_forward` with inputs:
原因:
xformers使用的是cpu版本
解决办法:
下载xformers的gpu版本(使用pip list 查询xformers版本号)
pip install -U xformers==0.0.23 --index-url https://download.pytorch.org/whl/cu118
注意:这个命令会同时安装xformers=0.0.23和pytorch=2.1.1+cuda118
问题2:ERROR: No matching distribution found for scikit-image
原因:
scikit-image未安装
解决方法:
pip install scikit-image==版本号
或者
pip install -r requirements.txt
问题3:AssertionError: Torch not compiled with CUDA enabled
原因:
使用readme.md中的pip install -r requirements.txt会自动安装cpu版本的torch和torchvision
解决办法
方法一:自行对应torch和torchvision版本(该方法下载速度极慢,可以用clash verge)
pip uninstall torch
pip uninstall torchvision
pip install torch==2.1.1 torchvision==0.16.1 --index-url https://download.pytorch.org/whl/cu118
方法二:下载离线版gpu torch和torchvision
1、详细寻找合适版本torch.whl文件方法如下
torch版本下载地址:download.pytorch.org/whl
2、找到合适版本的torch后,右键复制下载链接,打开以下网址转换成迅雷下载。
迅雷下载链接转换器 - Allen Zou
https://www.allenzou.com/aztools/Commonly012.html
3、控制台进入虚拟环境中,cd到torch文件所在文件夹
pip install torch+xxxx.whl pip install torchvision+xxxx.whl
问题4:RuntimeError: PytorchStreamReader failed reading zip archive: failed finding central directory
原因:
忘了
解决办法:
问题5:A matching Triton is not available, some optimizations will not be enabled. Error caught was: No module named 'triton'
原因:
解决方法:
详见
分析解决【No module named ‘triton‘】的问题_error caught was: no module named 'triton-CSDN博客
问题6:omegaconf.errors.ConfigAttributeError: Missing key tune_decoder full_key: autoencoder.tune_decoder
object_type=dict
原因:
配置文件中缺autoencoder.tune_decoder属性
解决方法:
配置文件中加入
autoencoder:
target: ldm.models.autoencoder.VQModelTorch
ckpt_path: weights/autoencoder_vq_f4.pth
use_fp16: True
tune_decoder: ~
params:
embed_dim: 3
n_embed: 8192
lora_tune_decoder: ~
问题7: assert self.configs.resume AssertionError
原因:
配置文件中缺resume属性
解决方法:
配置文件中加入
resume: ~
问题8:RuntimeError: cutlassF: no kernel found to launch!
具体报错:
"C:\Users\youlibin\.conda\envs\resshift\lib\site-packages\xformers\ops\fmha\__init__.py", line 223, in memory_efficient_attention return _memory_efficient_attention( File "C:\Users\youlibin\.conda\envs\resshift\lib\site-packages\xformers\ops\fmha\__init__.py", line 321, in _memory_efficient_attention return _memory_efficient_attention_forward( File "C:\Users\youlibin\.conda\envs\resshift\lib\site-packages\xformers\ops\fmha\__init__.py", line 341, in _memory_efficient_attention_forward out, *_ = op.apply(inp, needs_gradient=False) File "C:\Users\youlibin\.conda\envs\resshift\lib\site-packages\xformers\ops\fmha\cutlass.py", line 202, in apply return cls.apply_bmhk(inp, needs_gradient=needs_gradient) File "C:\Users\youlibin\.conda\envs\resshift\lib\site-packages\xformers\ops\fmha\cutlass.py", line 266, in apply_bmhk out, lse, rng_seed, rng_offset = cls.OPERATOR( File "C:\Users\youlibin\.conda\envs\resshift\lib\site-packages\torch\_ops.py", line 692, in __call__
return self._op(*args, **kwargs or {})
RuntimeError: cutlassF: no kernel found to launch!
原因:
GPU太好了,pytorch暂时不支持...
解决方法:
50系显卡:
pytorch = 2.7.0+cu128
cuda = 12.8.1
cudnn = 9.8.0
xformers = 0.0.30
运行问题
问题1:使用python inference_resshift.py 图像超分功能生成全黑的图片
示例代码:
python inference_resshift.py -i testdata/RealSet65/0014.jpg -o result/ --task realsr --scale 4
原因:
使用了amp
(文件:ldm/modules/diffusionmodules/model.py)
for i_level in range(self.num_resolutions):
for i_block in range(self.num_res_blocks[i_level]):
h = self.down[i_level].block[i_block](hs[-1], temb)
第530行h出错(当i_level=2,i_block=0时,h中存在nan值)
解决方法:
修改配置文件
use_amp: False
或者
resshift_sampler = ResShiftSampler(
configs,
sf=args.scale,
chop_size=args.chop_size,
chop_stride=chop_stride,
chop_bs=1,
use_amp=False,
seed=args.seed,
padding_offset=configs.model.params.get('lq_size', 64),
)
更多推荐


所有评论(0)