运行Disco Diffusion Warp时遇RuntimeError:Half类型未实现softmax_lastdim_kernel_impl
解决Disco Diffusion v5.xx(Warp版)的RuntimeError: "softmax_lastdim_kernel_impl" not implemented for 'Half'错误
我在运行Alex Spirin的Colab版Disco Diffusion v5.xx(Warp版本,多个版本都试过),已经把笔记本存到谷歌云端硬盘,上传了视频,操作步骤都是跟着指定YouTube视频和其他教程来的。之前的错误已经按GitHub的issue解决了,现在碰到如下RuntimeError:
RuntimeError Traceback (most recent call last) <ipython-input-17-1c79d8e6a9d5> in <module> 216 torch.cuda.empty_cache() 217 try: --> 218 do_run() 219 except KeyboardInterrupt: 220 pass 13 frames /usr/local/lib/python3.7/dist-packages/torch/nn/functional.py in softmax(input, dim, _stacklevel, dtype) 1678 dim = _get_softmax_dim("softmax", input.dim(), _stacklevel) 1679 if dtype is None: --> 1680 ret = input.softmax(dim) 1681 else: 1682 ret = input.softmax(dim, dtype=dtype) RuntimeError: "softmax_lastdim_kernel_impl" not implemented for 'Half'
解决方法
- 检查GPU类型:Colab分配的K80 GPU不支持Half类型的softmax运算,通过
Runtime > Change runtime type切换到T4或V100,重新连接会话后再运行。 - 修改精度设置:找到笔记本中设置半精度的代码,把
.half()调用替换成.float(),或者在softmax运算时指定dtype为float32:# 示例:修改模型精度 model = model.float() # 或者修改softmax调用 ret = input.softmax(dim, dtype=torch.float32) - 重置运行环境:执行
Runtime > Factory reset runtime,清空之前的环境缓存,重新安装依赖并运行代码,避免残留配置冲突。
内容的提问来源于stack exchange,提问作者Johannes Castner
相关产品推荐
相关产品推荐

