pytorch-a2c-ppo-acktr-gail icon indicating copy to clipboard operation
pytorch-a2c-ppo-acktr-gail copied to clipboard

Env Observation space dimension error whenever I try to train any model

Open ashwinipokle opened this issue 5 years ago • 6 comments

Hello,

I followed steps mentioned here to install requirements for this repository. There is one minor change, I am using virtualenv instead of conda to install pytorch. I wanted to test my installation and I tried to train model using the commands mentioned in this section. I am unable to get any model to train. Everytime I get the following error.

Traceback (most recent call last): File "main.py", line 14, in from a2c_ppo_acktr import algo, utils File "/home/admin/ppo_mm/pytorch-a2c-ppo-acktr-gail/a2c_ppo_acktr/algo/init.py", line 1, in from .a2c_acktr import A2C_ACKTR File "/home/admin/ppo_mm/pytorch-a2c-ppo-acktr-gail/a2c_ppo_acktr/algo/a2c_acktr.py", line 5, in from a2c_ppo_acktr.algo.kfac import KFACOptimizer File "/home/admin/ppo_mm/pytorch-a2c-ppo-acktr-gail/a2c_ppo_acktr/algo/kfac.py", line 8, in from a2c_ppo_acktr.utils import AddBias File "/home/admin/ppo_mm/pytorch-a2c-ppo-acktr-gail/a2c_ppo_acktr/utils.py", line 7, in from a2c_ppo_acktr.envs import VecNormalize File "/home/admin/ppo_mm/pytorch-a2c-ppo-acktr-gail/a2c_ppo_acktr/envs.py", line 146 assert len(op) == 3, f"Error: Operation, {str(op)}, must be dim3"

ashwinipokle avatar Apr 28 '19 00:04 ashwinipokle

Quick update: I followed installation instructions in anaconda environment and I still get a similar error whenever I try to train model. Traceback (most recent call last): File "main.py", line 166, in main() File "main.py", line 46, in main base_kwargs={'recurrent': args.recurrent_policy}) File "/home/admin/ppo_mm/pytorch-a2c-ppo-acktr-gail/a2c_ppo_acktr/model.py", line 21, in init if len(obs_shape) == 3: TypeError: object of type 'NoneType' has no len()

Seems like this is an issue with the version of OpenAI gym being used. Could you please let me know which version of OpenAI gym is compatible with the codebase ?

ashwinipokle avatar Apr 28 '19 00:04 ashwinipokle

me too

YuiiCh avatar May 21 '19 14:05 YuiiCh

It seems to work for me (I tested it with the latest versions of gym and baselines). Could you check whether you install the latest versions of gym and baselines?

I ran

 python main.py --env-name "PongNoFrameskip-v4"

ikostrikov avatar May 21 '19 17:05 ikostrikov

Tried with latest versions of gym and baseline. The issue still remains. Any ideas here ?

niagl avatar Jun 11 '19 19:06 niagl

Thank you, now it works~

发件人: Nikhil Agarwal 发送时间: 2019年6月12日 3:20 收件人: ikostrikov/pytorch-a2c-ppo-acktr-gail 抄送: YuiiCh; Comment 主题: Re: [ikostrikov/pytorch-a2c-ppo-acktr-gail] Env Observation spacedimension error whenever I try to train any model (#191)

Tried with latest versions of gym and baseline. The issue still remains. Any ideas here ? — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

YuiiCh avatar Jun 12 '19 01:06 YuiiCh

For me it was because I was using Python 3.5, once I updated to 3.6 it was working (I was getting the error: pytorch-a2c-ppo-acktr-gail/a2c_ppo_acktr/envs.py", line 146 assert len(op) == 3, f"Error: Operation, {str(op)}, must be dim3")

Looking at the code there:

super(TransposeImage, self).init(env) assert len(op) == 3, f"Error: Operation, {str(op)}, must be dim3"

It's using an f-string which is only supported in >=Python 3.6. So I think this means that this code won't work in Python 3.5 (which is annoying, as I can only get mujoco-py to run in python 3.5... but that's a whole different issue!). It might be worth mentioning this somewhere!

henrycharlesworth avatar Jul 02 '19 12:07 henrycharlesworth