[vtkusers] Off-screen rendering on a cluster

Burlen Loring burlen.loring at gmail.com
Wed Feb 18 18:16:07 EST 2015


Hi Nick,

One option is to build VTK without X and with OSMesa, a software based 
renderer that comes with Mesa3D OpenGL. The following link is about 
ParaView but also applies to VTK. 
http://www.paraview.org/Wiki/ParaView/ParaView_And_Mesa_3D

Burlen

On 02/18/2015 12:27 PM, Nick Gnedin wrote:
>
> Folks,
>
> I list at the end a short test code that displays a sphere and dumps 
> an image of the scene. The RenderWindow is set for off-screen 
> rendering, and on a regular Linux desktop it works as expected. Now I 
> would like to run it on a regular cluster in a batch mode. When I open 
> an interactive batch job on a worker node (they sit on a separate 
> private network and have no access to Internet) and run my test, it 
> displays an error message and triggers an abort. Can anyone suggest a 
> fix or share a previous experience? As I understand, the problem is 
> that a worker node does not have a valid X11 Dispay.
>
> Many thanks,
>
> Nick Gnedin
>
>
> (gdb) run
> Starting program: /lustre/gnedin/TMP/OS/test
> [Thread debugging using libthread_db enabled]
> ERROR: In 
> /lustre/gnedin/TMP/VTK-6.1.0/Rendering/OpenGL/vtkXOpenGLRenderWindow.cxx, 
> line 531
> vtkXOpenGLRenderWindow (0x1fd2850): bad X server connection. 
> DISPLAY=[New Thread 0x2af3852c5e60 (LWP 29341)]
>
> Program received signal SIGABRT, Aborted.
> 0x00002af384f90265 in raise () from /lib64/libc.so.6
> (gdb) where
> #0  0x00002af384f90265 in raise () from /lib64/libc.so.6
> #1  0x00002af384f91d10 in abort () from /lib64/libc.so.6
> #2  0x00002af377687b0c in vtkXOpenGLRenderWindow::CreateAWindow (
>     this=0x1fd2850)
>     at 
> /lustre/gnedin/TMP/VTK-6.1.0/Rendering/OpenGL/vtkXOpenGLRenderWindow.cxx:532
>
> Here is the code segment (VTK 6.1.0) causing the abort:
>
> 524       // get the default display connection
> 525       if (!this->DisplayId)
> 526         {
> 527         this->DisplayId = XOpenDisplay(static_cast<char *>(NULL));
> 528         if (this->DisplayId == NULL)
> 529           {
> 530           vtkErrorMacro(<< "bad X server connection. DISPLAY="
> 531             << vtksys::SystemTools::GetEnv("DISPLAY") << ". 
> Aborting.\n");
> 532           abort();
> 533           }
> 534         this->OwnDisplay = 1;
> 535         }
>
> My test code:
>
> #include <vtkActor.h>
> #include <vtkPNGWriter.h>
> #include <vtkPolyDataMapper.h>
> #include <vtkRenderer.h>
> #include <vtkRenderLargeImage.h>
> #include <vtkRenderWindow.h>
> #include <vtkSphereSource.h>
>
>
> int main()
> {
>   vtkRenderWindow *win = vtkRenderWindow::New();
>   win->SetOffScreenRendering(1);
>
>   vtkRenderer *ren = vtkRenderer::New();
>   win->AddRenderer(ren);
>
>   vtkActor *act = vtkActor::New();
>   ren->AddViewProp(act);
>
>   vtkPolyDataMapper *map = vtkPolyDataMapper::New();
>   act->SetMapper(map);
>
>   vtkSphereSource *obj = vtkSphereSource::New();
>   map->SetInputConnection(obj->GetOutputPort());
>
>   win->Render();
>
>   vtkRenderLargeImage *rli = vtkRenderLargeImage::New();
>   rli->SetInput(ren);
>
>   vtkPNGWriter *out = vtkPNGWriter::New();
>   out->SetFileName("test.png");
>   out->SetInputConnection(rli->GetOutputPort());
>   out->Write();
>
>   return 0;
> }
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at 
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at: 
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers



More information about the vtkusers mailing list