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

Setting up headless display #190

Open
Sunil7545 opened this issue Jun 24, 2020 · 9 comments
Open

Setting up headless display #190

Sunil7545 opened this issue Jun 24, 2020 · 9 comments

Comments

@Sunil7545
Copy link

Sunil7545 commented Jun 24, 2020

Hello everyone,
I am using the following lines of code to store the rendered image in the local disk without displaying it.

grid = pv.StructuredGrid(y1, x1, 5*ilm_rpe_2mm)
plotter = pv.Plotter(off_screen=True)
vertices_point = grid.points
plotter.add_mesh(grid, scalars=vertices_point[:, 2], opacity=0.95, clim=[0.2 * 5, 0.4 * 5], cmap='jet')
       
for idx in range(x_radials.shape[0]):
        points = np.column_stack((x_radials[idx], y_radials[idx], 5 * z_radials[idx]))
        spline = pv.Spline(points)
        plotter.add_points(spline)

plotter.set_background([1, 1, 1])
plotter.remove_scalar_bar()
plotter.set_scale(1.0, 1.0, 3.0, False)
plotter.enable_anti_aliasing()
plotter.show()
plotter.screenshot(name, transparent_background=False)

This code is working perfectly with windows 10. But when I am running it on a Linux system, I am getting the following error:

"ERROR:root:bad X server connection. DISPLAY=                                                                                                                                           
Aborted"

Can you please help me with this issue?
I am not able fix it.

Thank You
Sunil

@github-actions
Copy link

Hi and welcome! Thanks for posting your first issue in the PyVista project! Someone from @pyvista/developers will chime in before too long. If your question is support related, it may be automatically transferred to https://github.com/pyvista/pyvista-support

@banesullivan
Copy link
Member

Are you running in a VM with a headless display?

Look through https://docs.pyvista.org/getting-started/installation.html for insight

You may just need to sudo apt install one of libgl1-mesa-glx or libgl1-mesa-dev

@banesullivan
Copy link
Member

banesullivan commented Jun 24, 2020

If it is a headless environment, you may need to set up the display: sudo apt install xvfb

#!/bin/bash
set -x
export DISPLAY=:99.0
export PYVISTA_OFF_SCREEN=true
which Xvfb
Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
sleep 3
set +x
exec "$@"

@Sunil7545
Copy link
Author

Sunil7545 commented Jun 24, 2020 via email

@Sunil7545
Copy link
Author

Hi Bane,

I added the "start" file in the same repository like you have given the example of PVGeo (attached the screenshot) also installed the above mentioned libraries.
But still getting the same error.

Do I need to reference this file in my main code or somewhere?
Sorry for my naive question, I am pretty new to virtual machines and Linux systems.

Please take a look at the attached image

Thank you in advance.
Sunil
xvfb issue

@akaszynski
Copy link
Member

akaszynski commented Jun 25, 2020

Hello @Sunil7545,

You're going to want to create a start_xvfb.sh bash file with @banesullivan's script and give it executable permissions with chmod +x start_xvfb.sh. Then run ./start_xvfb.sh, which will start your headless display in the background. I think the issue is you've yet to actually start the script. You can tell it's running with pgrep Xvfb, which will return a process id if it's actually running.

@Sunil7545
Copy link
Author

Hi Alex,
Thank you again for your suggestion, I followed the procedure, you mentioned, but still getting similar error.
I m using pyvista==0.25.3. It seems Xvfb working fine.

Please take a look at the attached picture,
pyvista_issue

Regards
Sunil

@banesullivan banesullivan transferred this issue from pyvista/pyvista Jun 26, 2020
@banesullivan banesullivan changed the title Windows - Linux Compatibility issue Setting up headless display Jun 26, 2020
@banesullivan
Copy link
Member

banesullivan commented Jun 26, 2020

Try running sleep 30 (if this is automated or just wait a few minutes if you're typing in the commands) to give Xvfb a chance to boot up. I've found that it can take Xvfb a few minutes to boot with some configurations - the other day it took a Docker container I had at least 2 minutes

Otherwise, make sure you're not missing anything from https://docs.pyvista.org/getting-started/installation.html#running-on-remote-servers

@chen112p
Copy link

hello im still having some issue with this topic.
I am running pyvista on a headless centos machine. 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

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

No branches or pull requests

4 participants