我下载了dgllife并运行了pubchem_aromaticity示例。(https://github.com/chaoyue729/dgl-lifesci/tree/master/examples/property_prediction/pubchem_aromaticity)。但总是报告错误。当我更改args‘设备’=“cpu”时,它可以运行。但太慢了。我要在库达身上查一下。我怎么才能修好它?
def main(args):
args['device'] = torch.device("cuda:0") if torch.cuda.is_available() else torch.device("cpu")
#args['device'] = torch.device("cpu")
......dgl._ffi.base.DGLError:无法将设备cuda:0上的节点特性"hv“分配给设备cpu上的图形。调用DGLGraph.to()将图形复制到同一设备。
我想错误的原因是第46行的main.py的bg,它的类型是"dgl.heterograph.DGLHeteroGraph",不能复制到CUDA。参考文献(https://docs.dgl.ai/guide_cn/graph-gpu.html?highlight=dglerror)但我不知道该怎么设置。
发布于 2022-03-11 07:58:40
我已经解决了这个问题。解决方案是通过"main.py“在函数回归上添加一些代码。
def regress(args, model, bg):
atom_feats, bond_feats = bg.ndata.pop('hv'), bg.edata.pop('he')
atom_feats, bond_feats = atom_feats.to(args['device']), bond_feats.to(args['device'])
bg = bg.to(args['device'])
return model(bg, atom_feats, bond_feats)https://stackoverflow.com/questions/71423479
复制相似问题