Open GodeWithWind opened 1 year ago
报错的具体堆栈看下
这个bug是我们之前为了解决https://github.com/shenweichen/DeepCTR-Torch/issues/192 发布的https://github.com/shenweichen/DeepCTR-Torch/commit/2d56269259197ad67360a21fce0477c57b454818 这次改动中引入的,当时考虑到sparse_embedding_list
可能为空,因此将sparse_embedding_list[0].device
改为了self.device
。但是多gpu训练时self.device
只是gpus[0]
这一个gpu,所以会导致linear_logit
和sparse_feat_logit
不在同一个gpu上,继而引发如上报错。
多gpu训练时,有两种方法可以获取当前所在的gpu:
self.weight.device
,如下图:
但是当输入的dense_feature_columns
为空时(例如AFM模型,或其他用户未使用dense feature的情况),不会创建self.weight参数,需要先进行判断再使用。
我们准备采用方案1,会在后续的发布中合并此处改动,感谢您的提问。
@zanshuxun 您好,请问这个改动什么时候可以发布哈?
RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cuda:1! 下面是代码
model = DeepFM(linear_feature_columns=linear_feature_columns, dnn_feature_columns=dnn_feature_columns, task='binary', device=device, gpus=[0, 1], dnn_dropout=0.5)