部署问题
下列问题的出现,源自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
问题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版本(该方法下载速度极慢)
pip uninstall torch
pip uninstall torchvision
pip install torch==2.1.1 torchvision==0.16.1 --index-url https://download.pytorch.org/whl/cu121
方法二:下载离线版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-优快云博客
运行问题
问题1:使用python inference_resshift.py 图像超分功能生成全黑的图片
示例代码:
python inference_resshift.py -i testdata/RealSet65/0014.jpg -o result/ --task realsr --scale 4
原因:
- autoencoder(VQModelTorch类)
- encoder()方法
- h = self.encoder(x) 段代码存在问题
(文件: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值)
解决方法:
文件:inference_resshift.py
修改:形参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),
)