Unit 7. Modifying the learning algorithm: Cartpole error


I have implemented everything and getting following error at the end.
Can you help me out with this?

process[cartpole_gym-1]: started with pid [1235]
2021-11-26 00:26:51.197625: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcudart.so.11.0
[WARN] [1637886413.074246, 0.004000]: Start Init ControllersConnection
[WARN] [1637886413.075336, 0.004000]: END Init ControllersConnection
Traceback (most recent call last):
  File "/home/user/catkin_ws/src/tae_cartpole_training/src/train_cartpole.py", line 43, in <module>
  File "/home/user/catkin_ws/src/tae_cartpole_training/src/train_cartpole.py", line 27, in main
    act = deepq.learn(
  File "/home/simulations/baselines/baselines/deepq/deepq.py", line 124, in learn
AttributeError: 'NoneType' object has no attribute 'shape'
[cartpole_gym-1] process has died [pid 1235, exit code 1, cmd /home/user/catkin_ws/src/tae_cartpole_training/src/train_cartpole.py __name:=cartpole_gym __log:=/home/user/.ros/log/60634a0c-4e4f-11ec-9ab9-0242c0a8d008/cartpole_gym-1.log].
log file: /home/user/.ros/log/60634a0c-4e4f-11ec-9ab9-0242c0a8d008/cartpole_gym-1*.log
all processes on machine have died, roslaunch will exit
shutting down processing monitor...
... shutting down processing monitor complete

Thanks :smiley:

btw, I am using the task and the robot environment from openai_ros, I set them up rather than importing directly from the openai_ros package. Using other algorithms, it worked fine but when it comes to implementing the baselines code the error pops up.

Hello @einpunktnull ,

From looking at the error message, it looks like the errors appears because the object env.observation_space is None. So probably, something is happening before that and the object is not being populated properly.

If you can’t figure it out, you should share your code so that we can have a deeper look into it.

1 Like


I was able to figure that out. For some reason, the cartpole env doesn’t have observation_space defined in task env as default. That was why it was spitting error.

The course has been a great help for me so far.

This is a different question, but there a way to multiprocess using Open_AI ros environments w/ python multiprocessing library? All the examples provided in the course uses one simulation environment to train the model, and I was curious if there is a way to utilize multiple simulation environment at the same time to speed up the learning process(for algorithms like A2C and PPO).

Could you please give me some tips or example codes how to do this?
Looking forward to your answer :smiley: