Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CPU error] running ppo_snake.py on CPU/CentOS 8 raises error #12

Open
anthony0727 opened this issue Jun 8, 2021 · 0 comments
Open

Comments

@anthony0727
Copy link
Member

might be :

  • change in newer torch version
(py37) [anthony@localhost]~/rl2/rl2/examples% python3 ppo_snake.py
/home/anthony/.pyenv/versions/3.7.10/envs/py37/lib/python3.7/site-packages/torch/autograd/__init__.py:147: UserWarning: Error detected in AddmmBackward. Traceback of forward call that caused the error:
  File "ppo_snake.py", line 118, in <module>
    log_dir = train(config)
  File "ppo_snake.py", line 64, in train
    worker.run()
  File "/home/anthony/rl2/rl2/workers/base.py", line 146, in run
    done, info, results = self.rollout()
  File "/home/anthony/rl2/rl2/workers/base.py", line 87, in rollout
    info_a = self.agent.step(self.obs, ac, rew, done, obs)
  File "/home/anthony/rl2/rl2/agents/ppo.py", line 217, in step
    info = self.train(advs)
  File "/home/anthony/rl2/rl2/agents/ppo.py", line 242, in train
    loss = self.loss_func(batch_data, self.model, hidden=hidden)
  File "/home/anthony/rl2/rl2/agents/ppo.py", line 23, in loss_func
    ac_dist, val_dist = model(obs, hidden=hidden, mask=dones)
  File "/home/anthony/.pyenv/versions/3.7.10/envs/py37/lib/python3.7/site-packages/torch/nn/modules/module.py", line 889, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/home/anthony/rl2/rl2/models/torch/base.py", line 113, in inner
    results = func(self, *args, **kwargs)
  File "/home/anthony/rl2/rl2/agents/ppo.py", line 102, in forward
    action_dist = self.policy(obs, **kwargs)
  File "/home/anthony/.pyenv/versions/3.7.10/envs/py37/lib/python3.7/site-packages/torch/nn/modules/module.py", line 889, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/home/anthony/rl2/rl2/models/torch/base.py", line 360, in forward
    output = self.head(ir)
  File "/home/anthony/.pyenv/versions/3.7.10/envs/py37/lib/python3.7/site-packages/torch/nn/modules/module.py", line 889, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/home/anthony/rl2/rl2/distributions/torch/distributions.py", line 60, in forward
    x = self.linear(x)
  File "/home/anthony/.pyenv/versions/3.7.10/envs/py37/lib/python3.7/site-packages/torch/nn/modules/module.py", line 889, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/home/anthony/rl2/rl2/networks/torch/networks.py", line 19, in forward
    return self.body(x)
  File "/home/anthony/.pyenv/versions/3.7.10/envs/py37/lib/python3.7/site-packages/torch/nn/modules/module.py", line 889, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/home/anthony/.pyenv/versions/3.7.10/envs/py37/lib/python3.7/site-packages/torch/nn/modules/container.py", line 119, in forward
    input = module(input)
  File "/home/anthony/.pyenv/versions/3.7.10/envs/py37/lib/python3.7/site-packages/torch/nn/modules/module.py", line 889, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/home/anthony/.pyenv/versions/3.7.10/envs/py37/lib/python3.7/site-packages/torch/nn/modules/linear.py", line 94, in forward
    return F.linear(input, self.weight, self.bias)
  File "/home/anthony/.pyenv/versions/3.7.10/envs/py37/lib/python3.7/site-packages/torch/nn/functional.py", line 1753, in linear
    return torch._C._nn.linear(input, weight, bias)
 (Triggered internally at  /pytorch/torch/csrc/autograd/python_anomaly_mode.cpp:104.)
  allow_unreachable=True, accumulate_grad=True)  # allow_unreachable flag
model saved in PPOAgent_20210607224131/ckpt/8k
[TUTORIAL|ERROR] 2021-06-07 22:41:31,681 > RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.FloatTensor [64, 5]], which is output 0 of TBackward, is at version 4; expected version 3 instead. Hint: the backtrace further above shows the operation that failed to compute its gradient. The variable in question was changed in there or anywhere later. Good luck!
[TUTORIAL|DEBUG] 2021-06-07 22:41:31,681 > Traceback (most recent call last):
  File "ppo_snake.py", line 118, in <module>
    log_dir = train(config)
  File "ppo_snake.py", line 64, in train
    worker.run()
  File "/home/anthony/rl2/rl2/workers/base.py", line 146, in run
    done, info, results = self.rollout()
  File "/home/anthony/rl2/rl2/workers/base.py", line 87, in rollout
    info_a = self.agent.step(self.obs, ac, rew, done, obs)
  File "/home/anthony/rl2/rl2/agents/ppo.py", line 217, in step
    info = self.train(advs)
  File "/home/anthony/rl2/rl2/agents/ppo.py", line 244, in train
    self.model.value.step(loss)
  File "/home/anthony/rl2/rl2/models/torch/base.py", line 381, in step
    loss.backward(retain_graph=retain_graph)
  File "/home/anthony/.pyenv/versions/3.7.10/envs/py37/lib/python3.7/site-packages/torch/tensor.py", line 245, in backward
    torch.autograd.backward(self, gradient, retain_graph, create_graph, inputs=inputs)
  File "/home/anthony/.pyenv/versions/3.7.10/envs/py37/lib/python3.7/site-packages/torch/autograd/__init__.py", line 147, in backward
    allow_unreachable=True, accumulate_grad=True)  # allow_unreachable flag
RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.FloatTensor [64, 5]], which is output 0 of TBackward, is at version 4; expected version 3 instead. Hint: the backtrace further above shows the operation that failed to compute its gradient. The variable in question was changed in there or anywhere later. Good luck!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant