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

100% CPU load when using show_viewer True on Docker #344

Open
Nulliik opened this issue Dec 26, 2024 · 8 comments
Open

100% CPU load when using show_viewer True on Docker #344

Nulliik opened this issue Dec 26, 2024 · 8 comments

Comments

@Nulliik
Copy link

Nulliik commented Dec 26, 2024

Environment:

  • OS: Windows, using Docker
  • GPU RTX 4090

I am trying to setup Genesis working under docker and render the visualization results to Widows X server. Currently everything works, but viewer is rendering scene only using the CPU, I believe it is bound to pyrender and pyopengl. My CPU usage is 100%, but as I turn shadows off it becomes lower and keeps at ~70%.

Setting os.environ["SDL_VIDEO_X11_FORCE_EGL"] = "1" and os.environ['PYOPENGL_PLATFORM'] = 'egl' results in

Exception in thread Thread-2 (_init_and_start_app):
Traceback (most recent call last):
  File "/opt/conda/lib/python3.11/threading.py", line 1045, in _bootstrap_inner
    self.run()
  File "/opt/conda/lib/python3.11/threading.py", line 982, in run
    self._target(*self._args, **self._kwargs)
  File "/opt/conda/lib/python3.11/site-packages/genesis/ext/pyrender/viewer.py", line 1142, in _init_and_start_app
    pyglet.clock.tick()
  File "/opt/conda/lib/python3.11/site-packages/pyglet/clock.py", line 528, in tick
    return _default.tick(poll)
           ^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/lib/python3.11/site-packages/pyglet/clock.py", line 270, in tick
    self.call_scheduled_functions(delta_t)
  File "/opt/conda/lib/python3.11/site-packages/pyglet/clock.py", line 217, in call_scheduled_functions
    item.func(now - item.last_ts, *item.args, **item.kwargs)
  File "/opt/conda/lib/python3.11/site-packages/genesis/ext/pyrender/viewer.py", line 936, in _time_event
    self.on_draw()
  File "/opt/conda/lib/python3.11/site-packages/genesis/ext/pyrender/viewer.py", line 635, in on_draw
    self._render()
  File "/opt/conda/lib/python3.11/site-packages/genesis/ext/pyrender/viewer.py", line 1079, in _render
    retval = renderer.render(self.scene, flags, seg_node_map=seg_node_map)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/lib/python3.11/site-packages/genesis/ext/pyrender/renderer.py", line 141, in render
    self._update_context(scene, flags)
  File "/opt/conda/lib/python3.11/site-packages/genesis/ext/pyrender/renderer.py", line 899, in _update_context
    p._add_to_context()
  File "/opt/conda/lib/python3.11/site-packages/genesis/ext/pyrender/primitive.py", line 359, in _add_to_context
    glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, FLOAT_SZ * 3, ctypes.c_void_p(0))
  File "/opt/conda/lib/python3.11/site-packages/OpenGL/latebind.py", line 63, in __call__
    return self.wrapperFunction( self.baseFunction, *args, **named )
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/lib/python3.11/site-packages/OpenGL/GL/VERSION/GL_2_0.py", line 469, in glVertexAttribPointer
    contextdata.setValue( key, array )
  File "/opt/conda/lib/python3.11/site-packages/OpenGL/contextdata.py", line 58, in setValue
    context = getContext( context )
              ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/lib/python3.11/site-packages/OpenGL/contextdata.py", line 40, in getContext
    raise error.Error(
OpenGL.error.Error: Attempt to retrieve context when no valid context
@Nulliik Nulliik changed the title Full CPU load when using show_viewer True on Docker 100% CPU load when using show_viewer True on Docker Dec 26, 2024
@Nulliik
Copy link
Author

Nulliik commented Dec 26, 2024

@Kashu7100 this error happens with the docker file you created, so I ask for your help

@Nulliik
Copy link
Author

Nulliik commented Dec 26, 2024

Also running rendering demo results in crash

/opt/conda/bin/python /workspace/examples/rendering/demo.py
[Genesis] [22:20:16] [INFO] ╭─────────────────────────────────────────────────────────────────────────────────────╮
[Genesis] [22:20:16] [INFO] │┈┉┈┉┈┉┈┉┈┉┈┉┈┉┈┉┈┉┈┉┈┉┈┉┈┉┈┉┈┉┈┉┈┉┈┉┈┉ Genesis ┈┉┈┉┈┉┈┉┈┉┈┉┈┉┈┉┈┉┈┉┈┉┈┉┈┉┈┉┈┉┈┉┈┉┈┉┈┉│
[Genesis] [22:20:16] [INFO] ╰─────────────────────────────────────────────────────────────────────────────────────╯
[Genesis] [22:20:16] [INFO] Running on [NVIDIA GeForce RTX 4090] with backend gs.cuda. Device memory: 23.99 GB.
[Genesis] [22:20:16] [DEBUG] [Taichi] version 1.7.2, llvm 15.0.4, commit 0131dce9, linux, python 3.11.10
[Genesis] [22:20:16] [DEBUG] [Taichi] Starting on arch=cuda
[Genesis] [22:20:16] [INFO] 🚀 Genesis initialized. 🔖 version: 0.2.0, 🌱 seed: 0, 📏 precision: '32', 🐛 debug: False, 🎨 theme: 'dark'.
[Genesis] [22:20:20] [INFO] Scene <48b5b1f> created.
[Genesis] [22:20:20] [INFO] Adding <gs.RigidEntity>. idx: 0, uid: <0d6b158>, morph: <gs.morphs.Plane>, material: <gs.materials.Rigid>.
[Genesis] [22:20:20] [DEBUG] Preprocessed `.gsd` file found in cache for geom idx 0.
[Genesis] [22:20:20] [INFO] Adding <gs.RigidEntity>. idx: 1, uid: <5194d74>, morph: <gs.morphs.Mesh(file='/opt/conda/lib/python3.11/site-packages/genesis/assets/meshes/sphere.obj')>, material: <gs.materials.Rigid>.
[Genesis] [22:20:22] [INFO] Preprocessing geom idx 1.
[Genesis] [22:20:28] [INFO] Adding <gs.RigidEntity>. idx: 2, uid: <b05341d>, morph: <gs.morphs.Mesh(file='/opt/conda/lib/python3.11/site-packages/genesis/assets/meshes/sphere.obj')>, material: <gs.materials.Rigid>.
[Genesis] [22:20:28] [DEBUG] Preprocessed `.gsd` file found in cache for geom idx 2.
[Genesis] [22:20:28] [INFO] Adding <gs.RigidEntity>. idx: 3, uid: <58b3211>, morph: <gs.morphs.Mesh(file='/opt/conda/lib/python3.11/site-packages/genesis/assets/meshes/sphere.obj')>, material: <gs.materials.Rigid>.
[Genesis] [22:20:28] [DEBUG] Preprocessed `.gsd` file found in cache for geom idx 3.
[Genesis] [22:20:28] [INFO] Adding <gs.RigidEntity>. idx: 4, uid: <df5a9c1>, morph: <gs.morphs.Mesh(file='/opt/conda/lib/python3.11/site-packages/genesis/assets/meshes/sphere.obj')>, material: <gs.materials.Rigid>.
[Genesis] [22:20:28] [DEBUG] Preprocessed `.gsd` file found in cache for geom idx 4.
[Genesis] [22:20:28] [INFO] Adding <gs.RigidEntity>. idx: 5, uid: <291a8d3>, morph: <gs.morphs.Mesh(file='/opt/conda/lib/python3.11/site-packages/genesis/assets/meshes/sphere.obj')>, material: <gs.materials.Rigid>.
[Genesis] [22:20:28] [DEBUG] Preprocessed `.gsd` file found in cache for geom idx 5.
[Genesis] [22:20:28] [INFO] Adding <gs.RigidEntity>. idx: 6, uid: <598c158>, morph: <gs.morphs.Mesh(file='/opt/conda/lib/python3.11/site-packages/genesis/assets/meshes/sphere.obj')>, material: <gs.materials.Rigid>.
[Genesis] [22:20:28] [DEBUG] Preprocessed `.gsd` file found in cache for geom idx 6.
[Genesis] [22:20:28] [INFO] Adding <gs.RigidEntity>. idx: 7, uid: <8f64b87>, morph: <gs.morphs.Mesh(file='/opt/conda/lib/python3.11/site-packages/genesis/assets/meshes/sphere.obj')>, material: <gs.materials.Rigid>.
[Genesis] [22:20:28] [DEBUG] Preprocessed `.gsd` file found in cache for geom idx 7.
[Genesis] [22:20:28] [INFO] Adding <gs.RigidEntity>. idx: 8, uid: <1723faa>, morph: <gs.morphs.Mesh(file='/opt/conda/lib/python3.11/site-packages/genesis/assets/meshes/wooden_sphere_OBJ/wooden_sphere.obj')>, material: <gs.materials.Rigid>.
[Genesis] [22:20:30] [INFO] Preprocessing geom idx 8.
[Genesis] [22:20:36] [INFO] Adding <gs.RigidEntity>. idx: 9, uid: <6a43423>, morph: <gs.morphs.Mesh(file='/opt/conda/lib/python3.11/site-packages/genesis/assets/meshes/wooden_sphere_OBJ/wooden_sphere.obj')>, material: <gs.materials.Rigid>.
[Genesis] [22:20:36] [DEBUG] Preprocessed `.gsd` file found in cache for geom idx 9.
[Genesis] [22:20:36] [INFO] Building scene <48b5b1f>...
[Genesis] [22:20:52] [INFO] Compiling simulation kernels...
[Genesis] [22:20:59] [INFO] Building visualizer...
[Genesis] [22:20:59] [INFO] Viewer created. Resolution: 1920×1080, max_FPS: 60.
[Genesis] [22:21:11] [INFO] Resetting Scene <48b5b1f>.
[Genesis] [22:21:11] [INFO] Running at 402.59 FPS.
[2024-12-26 22:21:12.597] [console] [error] Assertion 'handle != nullptr' failed: OptiX library could not be loaded. [/workspace/Genesis/genesis/ext/LuisaRender/src/compute/src/backends/cuda/optix_api.cpp:162]
     0 [0x7f5f5ffe67fe]: /opt/conda/lib/python3.11/site-packages/genesis/ext/LuisaRender/build/bin/liblc-backend-cuda.so :: luisa::compute::optix::load_optix() + 622
     1 [0x7f5f5ffe6f53]: /opt/conda/lib/python3.11/site-packages/genesis/ext/LuisaRender/build/bin/liblc-backend-cuda.so :: luisa::compute::optix::api() + 115
     2 [0x7f5f5ff1c59b]: /opt/conda/lib/python3.11/site-packages/genesis/ext/LuisaRender/build/bin/liblc-backend-cuda.so :: luisa::compute::cuda::CUDADevice::Handle::optix_context() const + 235
     3 [0x7f5f5ff8d615]: /opt/conda/lib/python3.11/site-packages/genesis/ext/LuisaRender/build/bin/liblc-backend-cuda.so :: luisa::compute::cuda::CUDAPrimitive::_build(luisa::compute::cuda::CUDACommandEncoder&) + 165
     4 [0x7f5f5ff9ced6]: /opt/conda/lib/python3.11/site-packages/genesis/ext/LuisaRender/build/bin/liblc-backend-cuda.so :: luisa::compute::cuda::CUDAMesh::build(luisa::compute::cuda::CUDACommandEncoder&, luisa::compute::MeshBuildCommand*) + 374
     5 [0x7f5f5ff0c7a8]: /opt/conda/lib/python3.11/site-packages/genesis/ext/LuisaRender/build/bin/liblc-backend-cuda.so :: luisa::compute::cuda::CUDAStream::dispatch(luisa::compute::CommandList&&) + 200
     6 [0x7f5f5ff1db4e]: /opt/conda/lib/python3.11/site-packages/genesis/ext/LuisaRender/build/bin/liblc-backend-cuda.so :: luisa::compute::cuda::CUDADevice::dispatch(unsigned long, luisa::compute::CommandList&&) + 94
     7 [0x7f5f98179ec4]: /opt/conda/lib/python3.11/site-packages/genesis/ext/LuisaRender/build/bin/liblc-runtime.so :: luisa::compute::Stream::operator<<(luisa::compute::CommandList::Commit&&) + 52
     8 [0x7f5f9a7a5e08]: /opt/conda/lib/python3.11/site-packages/genesis/ext/LuisaRender/build/bin/libluisa-render-base.so :: luisa::render::Geometry::_process_shape(luisa::render::CommandBuffer&, float, luisa::render::Shape const*, luisa::render::Surface const*, luisa::render::Light const*, luisa::render::Medium const*, luisa::render::Subsurface const*, bool, unsigned long) + 1800
     9 [0x7f5f9a7a7fa2]: /opt/conda/lib/python3.11/site-packages/genesis/ext/LuisaRender/build/bin/libluisa-render-base.so :: luisa::render::Geometry::update(luisa::render::CommandBuffer&, ankerl::unordered_dense::v2_0_2::detail::table<luisa::render::Shape*, void, luisa::hash<luisa::render::Shape*>, std::equal_to<void>, luisa::allocator<luisa::render::Shape*>, ankerl::unordered_dense::v2_0_2::bucket_type::standard, eastl::vector<luisa::render::Shape*, eastl::allocator> > const&, float) + 354
    10 [0x7f5f9a76fcc8]: /opt/conda/lib/python3.11/site-packages/genesis/ext/LuisaRender/build/bin/libluisa-render-base.so :: luisa::render::Pipeline::update(luisa::compute::Stream&) + 792
    11 [0x7f5f9bcbef76]: /opt/conda/lib/python3.11/site-packages/genesis/ext/LuisaRender/build/bin/LuisaRenderPy.cpython-311-x86_64-linux-gnu.so :: unknown + 319350
    12 [0x7f5f9bc97b78]: /opt/conda/lib/python3.11/site-packages/genesis/ext/LuisaRender/build/bin/LuisaRenderPy.cpython-311-x86_64-linux-gnu.so :: unknown + 158584
    13 [0x55dbf9161f36]: /opt/conda/bin/python :: unknown + 2068278
    14 [0x55dbf913f97b]: /opt/conda/bin/python :: _PyObject_MakeTpCall + 667
    15 [0x55dbf914cf94]: /opt/conda/bin/python :: _PyEval_EvalFrameDefault + 1684
    16 [0x55dbf91717df]: /opt/conda/bin/python :: _PyFunction_Vectorcall + 383
    17 [0x55dbf9150ec7]: /opt/conda/bin/python :: _PyEval_EvalFrameDefault + 17863
    18 [0x55dbf9203c5d]: /opt/conda/bin/python :: unknown + 2731101
    19 [0x55dbf920339f]: /opt/conda/bin/python :: PyEval_EvalCode + 159
    20 [0x55dbf922131a]: /opt/conda/bin/python :: unknown + 2851610
    21 [0x55dbf921cf93]: /opt/conda/bin/python :: unknown + 2834323
    22 [0x55dbf9232540]: /opt/conda/bin/python :: unknown + 2921792
    23 [0x55dbf9231ecc]: /opt/conda/bin/python :: _PyRun_SimpleFileObject + 444
    24 [0x55dbf9231c64]: /opt/conda/bin/python :: _PyRun_AnyFileObject + 68
    25 [0x55dbf922c233]: /opt/conda/bin/python :: Py_RunMain + 899
    26 [0x55dbf91f3617]: /opt/conda/bin/python :: Py_BytesMain + 55
    27 [0x7f6111d18d90]: /lib/x86_64-linux-gnu/libc.so.6 :: unknown + 171408
    28 [0x7f6111d18e40]: /lib/x86_64-linux-gnu/libc.so.6 :: __libc_start_main + 128
    29 [0x55dbf91f34ca]: /opt/conda/bin/python :: unknown + 2663626
Aborted (core dumped)

@Kashu7100
Copy link
Collaborator

Kashu7100 commented Dec 27, 2024

OptiX library could not be loaded.

Can you check if you have OptiX on your machine (like find /usr -name "libnvoptix.so*")?

@Nulliik
Copy link
Author

Nulliik commented Dec 27, 2024

Can you check if you have OptiX on your machine (like find /usr -name "libnvoptix.so*")?

It returns nothing, I am not sure where exactly I suppose to have it installed (on my docker or in my Windows system), but current docker image doesn't feature it for me

@Kashu7100
Copy link
Collaborator

Kashu7100 commented Dec 27, 2024

I didn't include the OptiX lib in the Docker (because of license). I think you need to set it up on your host machine.

@zhouxian
Copy link
Collaborator

@Kashu7100 I don't think optix is relevant here? He is just using pyrender

@Kashu7100
Copy link
Collaborator

I encounter the same error on Linux without OptiX, so I doubt it is causing this error. Luisa requires OptiX

@Kashu7100
Copy link
Collaborator

@Nulliik Could you check if other examples (like rigid, etc.) work on your side?

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

3 participants