TianhongDai / reinforcement-learning-algorithms

This repository contains most of pytorch implementation based classic deep reinforcement learning algorithms, including - DQN, DDQN, Dueling Network, DDPG, SAC, A2C, PPO, TRPO. (More algorithms are still in progress)
662 stars 109 forks source link

BrokenPipeError: [Errno 32] Broken pipe #7

Closed ghost closed 3 years ago

ghost commented 3 years ago

Hi, after I installed using pip install -e ., I tried to run:

python train.py --env-name PongNoFrameskip-v4 --cuda 

in reinforcement-learning-algorithms/rl_algorithms/a2c and I get the following error on google colab:

Logging to logs//PongNoFrameskip-v4/
Logging to logs//PongNoFrameskip-v4/
Logging to logs//PongNoFrameskip-v4/
Logging to logs//PongNoFrameskip-v4/
Logging to logs//PongNoFrameskip-v4/
Logging to logs//PongNoFrameskip-v4/
Logging to logs//PongNoFrameskip-v4/
Logging to logs//PongNoFrameskip-v4/
Logging to logs//PongNoFrameskip-v4/
Logging to logs//PongNoFrameskip-v4/
Logging to logs//PongNoFrameskip-v4/
Logging to logs//PongNoFrameskip-v4/
Logging to logs//PongNoFrameskip-v4/
Logging to logs//PongNoFrameskip-v4/
Logging to logs//PongNoFrameskip-v4/
Logging to logs//PongNoFrameskip-v4/
Traceback (most recent call last):
  File "train.py", line 20, in <module>
    a2c_trainer.learn()
  File "/content/reinforcement-learning-algorithms/rl_algorithms/a2c/a2c_agent.py", line 42, in learn
    _, pi = self.net(input_tensor)
  File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 727, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/content/reinforcement-learning-algorithms/rl_algorithms/a2c/models.py", line 47, in forward
    x = self.cnn_layer(inputs / 255.0)
  File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 727, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/content/reinforcement-learning-algorithms/rl_algorithms/a2c/models.py", line 28, in forward
    x = x.view(-1, 32 * 7 * 7)
RuntimeError: view size is not compatible with input tensor's size and stride (at least one dimension spans across two contiguous subspaces). Use .reshape(...) instead.
Exception ignored in: <bound method SubprocVecEnv.__del__ of <rl_utils.env_wrapper.multi_envs_wrapper.SubprocVecEnv object at 0x7f772325ca58>>
Traceback (most recent call last):
  File "/content/reinforcement-learning-algorithms/rl_utils/env_wrapper/multi_envs_wrapper.py", line 105, in __del__
  File "/content/reinforcement-learning-algorithms/rl_utils/env_wrapper/__init__.py", line 96, in close
  File "/content/reinforcement-learning-algorithms/rl_utils/env_wrapper/multi_envs_wrapper.py", line 89, in close_extras
  File "/usr/lib/python3.6/multiprocessing/connection.py", line 206, in send
  File "/usr/lib/python3.6/multiprocessing/connection.py", line 404, in _send_bytes
  File "/usr/lib/python3.6/multiprocessing/connection.py", line 368, in _send
BrokenPipeError: [Errno 32] Broken pipe
TianhongDai commented 3 years ago

Hi, I test it on my machine with torch==1.1.0 and torch==1.7.1, but I can't reproduce this error. Could I get the version of the pytorch on your machine, please? And one suggestion to solve this problem is to replace .view() with .reshape(), Could you try it firstly?

ghost commented 3 years ago

python3.6, torch==1.7.0+cu101 on google colab, please find the gist here

TianhongDai commented 3 years ago

@emadboctorx Thanks for your information, and I managed to reproduce the same error on google colab. The solution is to replace .view() with .reshape() in https://github.com/TianhongDai/reinforcement-learning-algorithms/blob/master/rl_algorithms/a2c/models.py#L28 and I can run it on colab now.

debug
ghost commented 3 years ago

Thanks, I'll modify the code accordingly