Skip to content

Device misplacement #870

@U12358

Description

@U12358

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions