Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CarRacing-v0 - Potential Memory Leak: The _length attribute is too large #2094

Closed
praveenVnktsh opened this issue Nov 15, 2020 · 1 comment
Closed

Comments

@praveenVnktsh
Copy link

praveenVnktsh commented Nov 15, 2020

Hi!

I was working on the CarRacing-v0 environment. When the environment first launches, it seems fine, and consumes about 800MB of memory. But after a few runs, it starts consuming way too much memory and eventually crashes with pyglet throwing an error saying that the _length attribute is too large.

Here is the traceback:

Traceback (most recent call last):
  File "C:\Users\pveen\AppData\Local\Programs\Python\Python36\lib\site-packages\pyglet\graphics\vertexdomain.py", line 241, in _safe_alloc
    return self.allocator.alloc(count)
  File "C:\Users\pveen\AppData\Local\Programs\Python\Python36\lib\site-packages\pyglet\graphics\allocation.py", line 194, in alloc
    raise AllocatorMemoryException(self.capacity + size - free_size)
pyglet.graphics.allocation.AllocatorMemoryException: 67109696

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "test.py", line 53, in <module>
    env.render()
  File "E:\Google Drive\Acads\Junior year\Semester 5\Project Course\Gym\CarRacingv0-PPO-pytorch\environment.py", line 59, in render
    self.env.render(*arg)
  File "C:\Users\pveen\AppData\Local\Programs\Python\Python36\lib\site-packages\gym\core.py", line 240, in render
    return self.env.render(mode, **kwargs)
  File "C:\Users\pveen\AppData\Local\Programs\Python\Python36\lib\site-packages\gym\envs\box2d\car_racing.py", line 460, in render
    self.render_road()
  File "C:\Users\pveen\AppData\Local\Programs\Python\Python36\lib\site-packages\gym\envs\box2d\car_racing.py", line 529, in render_road
    len(polygons_) // 3, ("v3f", polygons_), ("c4f", colors)  # gl.GL_QUADS,
  File "C:\Users\pveen\AppData\Local\Programs\Python\Python36\lib\site-packages\pyglet\graphics\__init__.py", line 287, in vertex_list
    return _get_default_batch().add(count, 0, None, *data)
  File "C:\Users\pveen\AppData\Local\Programs\Python\Python36\lib\site-packages\pyglet\graphics\__init__.py", line 368, in add
    vlist = domain.create(count)
  File "C:\Users\pveen\AppData\Local\Programs\Python\Python36\lib\site-packages\pyglet\graphics\vertexdomain.py", line 271, in create
    start = self._safe_alloc(count)
  File "C:\Users\pveen\AppData\Local\Programs\Python\Python36\lib\site-packages\pyglet\graphics\vertexdomain.py", line 246, in _safe_alloc
    buffer.resize(capacity * buffer.element_size)
  File "C:\Users\pveen\AppData\Local\Programs\Python\Python36\lib\site-packages\pyglet\graphics\vertexbuffer.py", line 427, in resize
    data = (ctypes.c_byte * size)()
OverflowError: The '_length_' attribute is too large

Any hints as to how to solve this would be really helpful. As of now, I am simply catching the exception, and deleting the environment variable and reinitializing it inside a loop to continue training, which is not really a fix :/

@praveenVnktsh praveenVnktsh changed the title CarRacing-v0: The _length attribute is too large CarRacing-v0 - Potential Memory Leak: The _length attribute is too large Nov 15, 2020
@praveenVnktsh
Copy link
Author

I was just going through some other issues, and this one seems to kind of solve it:

#2062

vl = pyglet.graphics.vertex_list(

There is memory leaking in car_racing.py code.

pyglet.graphics.vertex_list() function makes the memory almost double,

And it can be fixed with vl.delete() under this line

vl.draw(gl.GL_QUADS)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant