RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!
reason
self.q_outs = [init_(nn.Linear(self.hidden_size, 1)) for _ in range(num_q_outs)]self.to(device)
In this way, the to(device) won’t transfer these parameters to the desired device.
command
sh ./train_mpe_maddpg.sh
error
RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!
reason
self.q_outs = [init_(nn.Linear(self.hidden_size, 1)) for _ in range(num_q_outs)]
self.to(device)
In this way, theto(device)
won’t transfer these parameters to the desired device.ref
https://discuss.pytorch.org/t/is-it-mandatory-to-add-modules-to-modulelist-to-access-its-parameters/81622/7