While using torch.nn.DataParrallel with two models receive AttributeError and only accessing one GPU

Viewed 16

I keep trying to run multiple GPUs but when I run this specific line for update_parameters I get an AttributeError that DataParrallel has no attribute update_parameters.

This is how I defined my nn.DataParrallel

    if torch.cuda.device_count() > 1:
    print("Let's use", torch.cuda.device_count(), "GPUs!")
    
    agent = torch.nn.DataParallel([agent.actor,agent.critic], device_ids=[0,1,2,3])

But when I get to this line it crashes and says the error I mentioned above.

            # Update actor and critic according to the batch
            value_loss, policy_loss = agent.update_params(batch)

The "agent" variable is a class that initializes the actor-critc models. Help would be greatly appreciated.

0 Answers
Related