nikhilbarhate99 / PPO-PyTorch

Minimal implementation of clipped objective Proximal Policy Optimization (PPO) in PyTorch
MIT License
1.57k stars 332 forks source link

I got an error while running the program #42

Closed robot-xyh closed 3 years ago

robot-xyh commented 3 years ago

Hi I got an error while running the program

Traceback (most recent call last):
  File "C:\Users\admin\Documents\GitHub\PPO-PyTorch\train.py", line 302, in <module>
    train()
  File "C:\Users\admin\Documents\GitHub\PPO-PyTorch\train.py", line 218, in train
    action = ppo_agent.select_action(state)
  File "C:\Users\admin\Documents\GitHub\PPO-PyTorch\PPO.py", line 204, in select_action
    action, action_logprob = self.policy_old.act(state)
  File "C:\Users\admin\Documents\GitHub\PPO-PyTorch\PPO.py", line 107, in act
    dist = MultivariateNormal(action_mean, cov_mat)
  File "C:\ProgramData\Anaconda3\lib\site-packages\torch\distributions\multivariate_normal.py", line 149, in __init__
    self._unbroadcasted_scale_tril = torch.cholesky(covariance_matrix)
RuntimeError: CUDA error: no kernel image is available for execution on the device

On line 107, I deleted .unsqueeze(dim=0),act function can run.But the evaluate function still reports an error, I don’t know how to modify it.

torch : 1.7.0+cu110

thanks

nikhilbarhate99 commented 3 years ago

This looks like a CUDA compatibility error. See on PyTorch forum here.

Do NOT change tensor dimensions unless absolutely required. For most RL implementations, it is a bad idea to change dimensions from what the author has provided unless you know what you are doing and can perform proper checks.

So, if you do decide to change dimensions (like deleted .unsqueeze(dim=0) ) then make sure all the tensor dimensions in update() function are correct. If they get broadcasted in an unexpected manner; the algorithm will not learn any useful policy without throwing any error and will end up wasting enormous amount of time.

Also, check the Note which I have added now in the Usage section of the README.md file to run the training on a CPU device.

robot-xyh commented 3 years ago

Thank you very much for your help, I now use the CPU for training, and the program runs very well