pykt-team / pykt-toolkit

pyKT: A Python Library to Benchmark Deep Learning based Knowledge Tracing Models
https://pykt.org
MIT License
194 stars 53 forks source link

DKT-F:Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu! #153

Open WinterGan opened 6 months ago

WinterGan commented 6 months ago

Hi , I am currently working with DKT-F and encountered the following error: "Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!"

sonyawong commented 6 months ago

Hi , I am currently working with DKT-F and encountered the following error: "Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!"

Hi, this issue is caused by the tensors are not on the same device. Could u provide more details about your errors?Such as which line did the error occur?

WinterGan commented 6 months ago

Hi , I am currently working with DKT-F and encountered the following error: "Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!"

Hi, this issue is caused by the tensors are not on the same device. Could u provide more details about your errors?Such as which line did the error occur?

File "/home/gzd/Desktop/pykt-toolkit/pykt/models/dkt_forget.py", line 56, in forward rgap, sgap, pcount = self.rgap_eye[rgap].to(device), self.sgap_eye[sgap].to(device), self.pcount_eye[pcount].to(device)

sonyawong commented 6 months ago

.rgap_eye[rgap].to(device), self.sgap_eye[sgap].to(device), self.pcount_eye[pcount].to(device)

The tensors of self.rgap_eye, self.sgap_eye and self.pcount_eye are not on GPUs. The following codes may work.

self.rgap_eye = torch.eye(num_rgap) --> self.rgap_eye = torch.eye(num_rgap).to(device) self.sgap_eye = torch.eye(num_sgap) --> self.sgap_eye = torch.eye(num_sgap).to(device) self.pcount_eye = torch.eye(num_pcount) --> self.pcount_eye = torch.eye(num_pcount).to(device)

xiangxin-oss commented 6 months ago

您好,我运行最新的sparseKT模型,也遇到了类似的错误,而且报错的行很多。 image