enthought / mayavi

3D visualization of scientific data in Python
http://docs.enthought.com/mayavi/mayavi/
Other
1.28k stars 282 forks source link

Headless rendering opacity issue with depth peeling #1165

Open lopsided opened 1 year ago

lopsided commented 1 year ago

Locally, I found that opacity is not rendered properly unless you set s.scene.renderer.use_depth_peeling = True as per this issue: https://github.com/enthought/mayavi/issues/574

I am now running on a headless server using Xvfb as per https://docs.enthought.com/mayavi/mayavi/tips.html#rendering-using-the-virtual-framebuffer but when I set use_depth_peeling = True any surfaces with opacity completely fail to render.

Without depth peeling the render works, but doesn't look good -- I have seen in a number of places that this is a known issue with vtk.

I believe the exact same issue is happening here: https://github.com/pyvista/pyvista/issues/2592

Are there any other alternatives to Xvfb for headless rendering I could try out?

lopsided commented 1 year ago

TL;DR: export GALLIUM_DRIVER=softpipe fixes the problem.

The problem appears to be with the renderer. When using Xvfb you don't get the hardware support so even with a GPU on the headless machine you can't use it (AFAICT). That means you're using the software renderer llvmpipe by default. This can be changed to swr or softpipe (I found this from here: https://www.paraview.org/Wiki/ParaView/ParaView_And_Mesa_3D). I couldn't get swr to work but setting it to softpipe resolves the issue. Obviously don't expect the performance to be good using this option.

In an attempt to fix gpu support I tried running a full X server on my machine, which shows up as a process in nvidia-smi and gives me OpenGL renderer string: Quadro RTX 4000/PCIe/SSE2 as output to glxinfo | grep -i render. However I still need this fix to use depth peeling, so I'm not actually sure if I'm getting any gpu rendering here or not.

lopsided commented 1 year ago

OK in a last attempt, I installed the llvm-dev package (https://docs.mesa3d.org/drivers/llvmpipe.html) and reinstalled all my conda packages. Nope, GALLIUM_DRIVER=llvmpipe still fails under Xvfb.

BUT (I'm sure coincidentally) now my gpu-aware Xorg server now renders correctly with any setting of GALLIUM_DRIVER (including the previously crashing swr) so I appear to have at least got gpu rendering working.