Build the OCCT with VTK to support the offscreen/software rendering on headless ( no Graphics drivers ) ubuntu (20.04) machine

I have written a console program to read the Step file and Write a GLB file using OpenCASCADE. This program is working fine on headless Ubuntu machine.
Now I want to generate the image ( png, jpg ) of the loaded Step model through the same program.

I found that VTK with the OSMESA libraries can be used in software rendering mode to capture the image of the loaded model.
I am not sure how to build the OCCT with the VTK offscreen/software rendering mode support on a headless Ubuntu machine.

Do we need to install VTK separately and then link it with the VTK, if so then how we can do it? What the different environments variables to be set?

If we don't need to install VTK separately then what is the way to install VTK within the OCCT and the configuration of the environment variables in both VTK and OCCT to successfully build and install the OCCT with VTK to support the offscreen/software rendering on headless Ubuntu machine.

Thanks

Dmitrii Pasukhin's picture

You be able to dump image w/o VTK.

Please take a look into: Offscreen OCCT Viewer – Unlimited 3D (wordpress.com)

Best regards, Dmitrii.

Vikas Beske's picture

Hi Dmitrii,

I have tried the article you suggested and it is working on Linux machine with GUI. But when I tried the same application on a headless linux machine ( without GUI ) then the same app is not working, giving some error.

So I am going with VTK and OSMESA libraries to dump the image, but not able to build OCCT with VTK

Thanks

Dmitrii Pasukhin's picture

Hello, which kind of problems?

Vikas Beske's picture

Hi Dmitrii,

I am getting below error while dumping the image.

Caught error: Can not connect to the server ""

I think the reason behind this is code is trying to access some display and since my machine is headless and has no GUI and graphics drives it does not get that display and gives this error.

Thanks

gkv311 n's picture

The most straightforward way is to use Xvfb project (xvfb-run) for running a virtual (offscreen) X11 server on a headless worstation. You may give snippets how to use it on the internet.

Dmitrii Pasukhin's picture

Please try to use export DISPLAY=":0." or something similar. It is for XLib

Best regards, Dmitrii.

Vikas Beske's picture

Hi Dmitrii,

I tried using below commands but still I am getting error as Can not connect to the server ""

export DISPLAY=":0."
export DISPLAY=":0.0"
export DISPLAY=":1"
export DISPLAY=":1.0"

So I tried directly setting the display name at the time of creation of Aspect_DisplayConnection
I tried using the same values as above but got the error message as Can not connect to the server ":0." and similar for other values

The same code is working fine on the linux machine where I have GUI and GPU. There the Display name being used is ":1"

Regards
Vikas

Dmitrii Pasukhin's picture

In this case, please follow gkv recommendation.

Best regards, Dmitrii.