pyvista / pyvista-support

[moved] Please head over to the Discussions tab of the PyVista repository
https://github.com/pyvista/pyvista/discussions
59 stars 4 forks source link

running pyvista on headless machine with Centos OS #521

Closed chen112p closed 2 years ago

chen112p commented 2 years ago

Hello, I understand this topic has been discussed few times. Wondering if anyone made it work on a headless virtual machine with Centos OS. All I am trying to do is to load existing vtk files and put them together as a gif animation. I have installed Xvfb image and mesa-libGL. Also, created a shell script to config Xvfb image

But still when running the python script, it tells me 'could not find a decent visual' image

I have checked that there is a xvfb process running in the background: image

Can you tell what i missed and where i did wrong here?

Thanks!

Junting

Originally posted by @chen112p in https://github.com/pyvista/pyvista-support/issues/190#issuecomment-950256838

redoules commented 2 years ago

Hello, Xvfg seems to be unmaintained. I've got some good results with XDummy.

First I made sure OpenGL is installed with xdummy

yum install mesa-libGL mesa-dri-drivers xorg-x11-drv-dummy xserver-xorg-video-dummy

I then created a config file for XDummy (dummy-1920x1080.conf)

Section "Monitor"
  Identifier "Monitor0"
  HorizSync 28.0-80.0
  VertRefresh 48.0-75.0
  Modeline "1920x1080_60.00" 172.80 1920 2040 2248 2576 1080 1081 1084 1118 -HSync +Vsync
EndSection

Section "Device"
  Identifier "Card0"
  Driver "dummy"
  VideoRam 256000
EndSection

Section "Screen"
  DefaultDepth 24
  Identifier "Screen0"
  Device "Card0"
  Monitor "Monitor0"
  SubSection "Display"
    Depth 24
    Modes "1920x1080_60.00"
  EndSubSection
EndSection

I then started Xdummy on the server

sudo X :99 -config dummy-1920x1080.conf

Once the server started, make sure you export the environnement variables

export DISPLAY=:99
export MESA_GL_VERSION_OVERRIDE=3.2

After than I managed to run a python program that was using VTK python headless.py

Note that for pyvista, you might need to export some additionnal env variables

export PYVISTA_OFF_SCREEN=true
export PYVISTA_USE_IPYVTK=true

Useful links for reference : https://stackoverflow.com/questions/8545291/opengl-glx-extension-not-supported https://stackoverflow.com/questions/27407774/get-supported-glsl-versions https://docs.mesa3d.org/envvars.html https://github.com/gcaufield/MonkeyContainer/blob/master/dummy-1920x1080.conf https://vtk.org/pipermail/vtkusers/2018-April/101556.html