Hello,I am a new man in deep learning, please help me, thanks!
hhcNWPU opened this issue · comments
First, thanks your code. However, when I run the "Solving TSP with Improvement-base DRL".
Here "cost = problem.get_costs(instance, solution)", I saw the error information:
File "E:\TSP-improve-master\TSP-improve-master\problems\problem_tsp.py", line 53, in get_costs
d = dataset.gather(1, rec.long().unsqueeze(-1).expand_as(dataset))
RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!
I found the issues closed have the same problem:
"#2"
But I checked the answers, they were have modfiied in my "plots.py" :
Afterwards, I got the error:
RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!
Modify line 54 of plots.py:
Change the following:
plt.plot(initial_value.mean() - np.cumsum(reward.cpu().mean(0)))
To:
plt.plot(initial_value.cpu().mean() - np.cumsum(reward.cpu().mean(0)))
what can I do? Thanks you very much!
Hi,
You may use print(dataset.device) and print(rec.device) to debug and use xxx.to(device) to change devices accordingly.