[vtkusers] Off-screen rendering on a cluster

Nick Gnedin ngnedin at gmail.com
Wed Feb 18 15:27:06 EST 2015


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;
}


More information about the vtkusers mailing list