imitation icon indicating copy to clipboard operation
imitation copied to clipboard

Device misplacement

Open U12358 opened this issue 11 months ago • 0 comments

Bug description

File "imitation/algorithms/bc.py", line 495, in train training_metrics = self.loss_calculator(self.policy, obs_tensor, acts) File "imitation/algorithms/bc.py", line 146, in call loss = neglogp + ent_loss + l2_loss RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!

ent_loss = -self.ent_weight * (entropy if entropy is not None else th.zeros(1))

If entropy is None th.zeros(1) is at CPU when model is at CUDA

Steps to reproduce

Pretrain PPO model with use_sde=True

Environment

  • OS: Ubuntu 22.04
  • Python: 3.9
  • Imitation: 1.0.1
  • SB3: 2.2.1

U12358 avatar Dec 25 '25 17:12 U12358