ikostrikov / pytorch-a2c-ppo-acktr-gail

PyTorch implementation of Advantage Actor Critic (A2C), Proximal Policy Optimization (PPO), Scalable trust-region method for deep reinforcement learning using Kronecker-factored approximation (ACKTR) and Generative Adversarial Imitation Learning (GAIL).
MIT License
3.53k stars 832 forks source link

Unable to run enjoy.py #262

Open jakefoster954 opened 3 years ago

jakefoster954 commented 3 years ago

Main.py successfully completes for the reacher environment however I am unable to run enjoy.py. The window opens but then I get a runtime error:

RuntimeError: Tensor for argument #2 'mat1' is on CPU, but expected it to be on GPU (while checking arguments for addmm)

Any advice on how to fix this would be appreciated. See full error message below.

It is worth noting this was run on the version of master before baselines was replaced by stablebaselines.

Creating window glfw Traceback (most recent call last): File "enjoy.py", line 80, in obs, recurrent_hidden_states, masks, deterministic=args.det) File ".../pytorch-a2c-ppo-acktr-gail/a2c_ppo_acktr/model.py", line 55, in act value, actor_features, rnn_hxs = self.base(inputs, rnn_hxs, masks) File "/home/..../anaconda3/envs/pytorch-a2c/lib/python3.7/site-packages/torch/nn/modules/module.py", line 727, in _call_impl result = self.forward(*input, kwargs) File "..../pytorch-a2c-ppo-acktr-gail/a2c_ppo_acktr/model.py", line 226, in forward hidden_critic = self.critic(x) File "..../anaconda3/envs/pytorch-a2c/lib/python3.7/site-packages/torch/nn/modules/module.py", line 727, in _call_impl result = self.forward(*input, *kwargs) File "..../anaconda3/envs/pytorch-a2c/lib/python3.7/site-packages/torch/nn/modules/container.py", line 117, in forward input = module(input) File "..../anaconda3/envs/pytorch-a2c/lib/python3.7/site-packages/torch/nn/modules/module.py", line 727, in _call_impl result = self.forward(input, kwargs) File "..../anaconda3/envs/pytorch-a2c/lib/python3.7/site-packages/torch/nn/modules/linear.py", line 93, in forward return F.linear(input, self.weight, self.bias) File "..../anaconda3/envs/pytorch-a2c/lib/python3.7/site-packages/torch/nn/functional.py", line 1690, in linear ret = torch.addmm(bias, input, weight.t()) RuntimeError: Tensor for argument #2 'mat1' is on CPU, but expected it to be on GPU (while checking arguments for addmm)

ikostrikov commented 3 years ago

Fixed in https://github.com/ikostrikov/pytorch-a2c-ppo-acktr-gail/commit/b25c006bc23c73638e25f734186d3daae49c0576

Could you verify that the fix works for you as well?