slowbull / DDPG

Tensorflow implementation of Deep Deterministic Policy Gradients
20 stars 8 forks source link

AttributeError: 'NoneType' object has no attribute 'decode' --- when env_render is set to True #1

Closed Amir-Ramezani closed 7 years ago

Amir-Ramezani commented 7 years ago

Hi,

I tried to set the render flag to True but I received the following error:

DDPG-master$ python3 ddpg_main.py I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcublas.so.8.0 locally I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcudnn.so.5 locally I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcufft.so.8.0 locally I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcuda.so.1 locally I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcurand.so.8.0 locally W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE3 instructions, but these are available on your machine and could speed up CPU computations. W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations. W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations. W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations. W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations. W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations. I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:910] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero I tensorflow/core/common_runtime/gpu/gpu_device.cc:885] Found device 0 with properties: name: GeForce GTX 1080 major: 6 minor: 1 memoryClockRate (GHz) 1.898 pciBusID 0000:01:00.0 Total memory: 7.92GiB Free memory: 332.19MiB I tensorflow/core/common_runtime/gpu/gpu_device.cc:906] DMA: 0 I tensorflow/core/common_runtime/gpu/gpu_device.cc:916] 0: Y I tensorflow/core/common_runtime/gpu/gpu_device.cc:975] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GTX 1080, pci bus id: 0000:01:00.0) [2017-04-06 14:05:08,630] Making new env: Pendulum-v0 [2017-04-06 14:05:08,636] Creating monitor directory ./results/Pendulum-v0/20170406140508/gym_ddpg Continuous 0%| | 0/100000 [00:00<?, ?it/s][2017-04-06 14:05:10,029] Starting new video recorder writing to /home/amir-ai/DDPG-Codes/slowbull/DDPG-master/results/Pendulum-v0/20170406140508/gym_ddpg/openaigym.video.0.3584.video000000.mp4

Traceback (most recent call last): File "ddpg_main.py", line 133, in tf.app.run() File "/usr/local/lib/python3.4/dist-packages/tensorflow/python/platform/app.py", line 44, in run _sys.exit(main(_sys.argv[:1] + flags_passthrough)) File "ddpg_main.py", line 129, in main agent.train() File "/home/amir-ai/DDPG-Codes/slowbull/DDPG-master/src/agent/ddpg_agent.py", line 35, in train self.evaluate(cur_episode) File "/home/amir-ai/DDPG-Codes/slowbull/DDPG-master/src/agent/ddpg_agent.py", line 117, in evaluate state = self.env.reset() File "/home/amir-ai/gym/gym/core.py", line 123, in reset observation = self._reset() File "/home/amir-ai/gym/gym/wrappers/monitoring.py", line 41, in _reset self._after_reset(observation) File "/home/amir-ai/gym/gym/wrappers/monitoring.py", line 198, in _after_reset self._reset_video_recorder() File "/home/amir-ai/gym/gym/wrappers/monitoring.py", line 219, in _reset_video_recorder self.video_recorder.capture_frame() File "/home/amir-ai/gym/gym/monitoring/video_recorder.py", line 106, in capture_frame frame = self.env.render(mode=render_mode) File "/home/amir-ai/gym/gym/core.py", line 174, in render return self._render(mode=mode, close=close) File "/home/amir-ai/gym/gym/core.py", line 341, in _render return self.env.render(mode, close) File "/home/amir-ai/gym/gym/core.py", line 174, in render return self._render(mode=mode, close=close) File "/home/amir-ai/gym/gym/envs/classic_control/pendulum.py", line 66, in _render from gym.envs.classic_control import rendering File "/home/amir-ai/gym/gym/envs/classic_control/rendering.py", line 23, in from pyglet.gl import File "/usr/local/lib/python3.4/dist-packages/pyglet/gl/init.py", line 236, in import pyglet.window File "/usr/local/lib/python3.4/dist-packages/pyglet/window/init.py", line 1816, in gl._create_shadow_window() File "/usr/local/lib/python3.4/dist-packages/pyglet/gl/init.py", line 205, in _create_shadow_window _shadow_window = Window(width=1, height=1, visible=False) File "/usr/local/lib/python3.4/dist-packages/pyglet/window/xlib/init.py", line 163, in init super(XlibWindow, self).init(args, **kwargs) File "/usr/local/lib/python3.4/dist-packages/pyglet/window/init.py", line 504, in init config = screen.get_best_config(template_config) File "/usr/local/lib/python3.4/dist-packages/pyglet/canvas/base.py", line 161, in get_best_config configs = self.get_matching_configs(template) File "/usr/local/lib/python3.4/dist-packages/pyglet/canvas/xlib.py", line 179, in get_matching_configs configs = template.match(canvas) File "/usr/local/lib/python3.4/dist-packages/pyglet/gl/xlib.py", line 29, in match have_13 = info.have_version(1, 3) File "/usr/local/lib/python3.4/dist-packages/pyglet/gl/glx_info.py", line 86, in have_version client_version = self.get_client_version().split()[0] File "/usr/local/lib/python3.4/dist-packages/pyglet/gl/glx_info.py", line 118, in get_client_version return asstr(glXGetClientString(self.display, GLX_VERSION)) File "/usr/local/lib/python3.4/dist-packages/pyglet/compat.py", line 88, in asstr return s.decode("utf-8") AttributeError: 'NoneType' object has no attribute 'decode' [2017-04-06 14:05:10,204] Finished writing results. You can upload them to the scoreboard via gym.upload('/home/amir-ai/DDPG-Codes/slowbull/DDPG-master/results/Pendulum-v0/20170406140508/gym_ddpg')

Could you tell me what do you think is the problem?

The code runs without problem when the flag is set to False.

I am using python3.4 and I tested gym separately and it rendered the env with no issue.

Thanks,

Amir-Ramezani commented 7 years ago

I changed the python version to 2.7 but still receiving the following error:

DDPG-master$ python ddpg_main.py W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE3 instructions, but these are available on your machine and could speed up CPU computations. W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations. W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations. W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations. W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations. W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations. [2017-04-06 21:45:52,907] Making new env: Pendulum-v0 [2017-04-06 21:45:52,911] DEPRECATION WARNING: env.spec.timestep_limit has been deprecated. Replace your call to env.spec.timestep_limit with env.spec.tags.get('wrapper_config.TimeLimit.max_episode_steps'). This change was made 12/28/2016 and is included in version 0.7.0 [2017-04-06 21:45:52,911] Creating monitor directory ./results/Pendulum-v0/20170406214552/gym_ddpg Continuous 0%| | 0/100000 [00:00<?, ?it/s][2017-04-06 21:45:53,228] Starting new video recorder writing to /home/amir-ai/DDPG-Codes/slowbull/DDPG-master/results/Pendulum-v0/20170406214552/gym_ddpg/openaigym.video.0.22739.video000000.mp4

Traceback (most recent call last): File "ddpg_main.py", line 133, in tf.app.run() File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/platform/app.py", line 44, in run _sys.exit(main(_sys.argv[:1] + flags_passthrough)) File "ddpg_main.py", line 129, in main agent.train() File "/home/amir-ai/DDPG-Codes/slowbull/DDPG-master/src/agent/ddpg_agent.py", line 35, in train self.evaluate(cur_episode) File "/home/amir-ai/DDPG-Codes/slowbull/DDPG-master/src/agent/ddpg_agent.py", line 117, in evaluate state = self.env.reset() File "/usr/local/lib/python2.7/dist-packages/gym/core.py", line 123, in reset observation = self._reset() File "/usr/local/lib/python2.7/dist-packages/gym/wrappers/monitoring.py", line 29, in _reset self._monitor._after_reset(observation) File "/usr/local/lib/python2.7/dist-packages/gym/monitoring/monitor_manager.py", line 265, in _after_reset self._reset_video_recorder() File "/usr/local/lib/python2.7/dist-packages/gym/monitoring/monitor_manager.py", line 286, in _reset_video_recorder self.video_recorder.capture_frame() File "/usr/local/lib/python2.7/dist-packages/gym/monitoring/video_recorder.py", line 106, in capture_frame frame = self.env.render(mode=render_mode) File "/usr/local/lib/python2.7/dist-packages/gym/core.py", line 174, in render return self._render(mode=mode, close=close) File "/usr/local/lib/python2.7/dist-packages/gym/core.py", line 341, in _render return self.env.render(mode, close) File "/usr/local/lib/python2.7/dist-packages/gym/core.py", line 174, in render return self._render(mode=mode, close=close) File "/usr/local/lib/python2.7/dist-packages/gym/envs/classic_control/pendulum.py", line 66, in _render from gym.envs.classic_control import rendering File "/usr/local/lib/python2.7/dist-packages/gym/envs/classic_control/rendering.py", line 23, in from pyglet.gl import File "/usr/local/lib/python2.7/dist-packages/pyglet/gl/init.py", line 236, in import pyglet.window File "/usr/local/lib/python2.7/dist-packages/pyglet/window/init.py", line 1817, in gl._create_shadow_window() File "/usr/local/lib/python2.7/dist-packages/pyglet/gl/init.py", line 205, in _create_shadow_window _shadow_window = Window(width=1, height=1, visible=False) File "/usr/local/lib/python2.7/dist-packages/pyglet/window/xlib/init.py", line 163, in init super(XlibWindow, self).init(args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/pyglet/window/init.py", line 505, in init config = screen.get_best_config(template_config) File "/usr/local/lib/python2.7/dist-packages/pyglet/canvas/base.py", line 161, in get_best_config configs = self.get_matching_configs(template) File "/usr/local/lib/python2.7/dist-packages/pyglet/canvas/xlib.py", line 179, in get_matching_configs configs = template.match(canvas) File "/usr/local/lib/python2.7/dist-packages/pyglet/gl/xlib.py", line 29, in match have_13 = info.have_version(1, 3) File "/usr/local/lib/python2.7/dist-packages/pyglet/gl/glx_info.py", line 89, in have_version client = [int(i) for i in client_version.split('.')] ValueError: invalid literal for int() with base 10: 'None' [2017-04-06 21:45:53,408] Finished writing results. You can upload them to the scoreboard via gym.upload('/home/amir-ai/DDPG-Codes/slowbull/DDPG-master/results/Pendulum-v0/20170406214552/gym_ddpg') Segmentation fault (core dumped)

slowbull commented 7 years ago

There is no problem on my machine. Looks like the error is from pyglet ?

Amir-Ramezani commented 7 years ago

I seems to be a problem between the tensorflow initialization and gym, based on some search results. So, if I move the following lines to top so change the main file like this:

import numpy as np import datetime import gym from gym.wrappers import Monitor

env = gym.make("Pendulum-v0") env.reset() env.render()

then there is no problem and it works fine.

Thanks for your code.