关于DGL的bug Data type not recognized with bits 16
dgl._ffi.base.DGLError: [21:21:28] /opt/dgl/src/array/cuda/sddmm.cu:112: Data type not recognized with bits 16
这个bug可能的原因是模型计算时候的数据出现了16位的。
解决办法:
找到可能出现16位的变量,改成32位。
如果喂给模型的tensor都是32位的,还是报这个错,有可能的原因是,torch的autocast
,为了加速训练,会将32位的tensor转换成16位,所以error了。尤其是在allennlp框架下,这种可能出现的可能性很大,解决办法就是在model forward时候,使用
from torch.cuda.amp import autocast as autocast
with autocast(False):
即可禁用它