解决报错:“slow_conv2d_cpu“ not implemented for ‘Half‘ | 训练DreamBooth

用了autodl上的镜像:CrazyBoyM/dreambooth-for-diffusion/dreambooth-for-diffusion:v3,在无卡模式下调试代码到时候,因为没有Cuda支持,无法使用半精度VAE模块进行推理,因此在获取latent图像时出现报错:

"slow_conv2d_cpu" not implemented for 'Half'

解决方案:

参考python - "RuntimeError: "slow_conv2d_cpu" not implemented for 'Half'" - Stack Overflow

既然无法使用half精度,那就不进行转换。找到train_dreambooth.py文件的611-665行:

weight_dtype = torch.float32
if args.mixed_precision == "fp16":
    weight_dtype = torch.float16
elif args.mixed_precision == "bf16":
    weight_dtype = torch.bfloat16

注释掉转换half精度的代码,使用float32精度。

再重新运行VAE的encoder,就不会再报错了。

猜你喜欢

转载自blog.csdn.net/weixin_41467446/article/details/130725080
今日推荐