Building ParaView with GPU accelerated MESA


(Mathieu Westphal (Kitware)) #1

Note: This tutorial used this wiki article as a base.
https://www.paraview.org/Wiki/ParaView/ParaView_And_Mesa_3D

Before getting into details of Mesa graphics hardware drivers, a disclaimer. If you have graphics hardware Mesa is not your best option. To get the best performance from your graphics card you’ll need to install the vendor provided driver. Vendor provided OpenGL drivers are typically much faster of a much higher quality than Mesa’s which can be quite buggy. Many distros now provide third-party non-opensource source drivers through specialized package repositories. The details of installing vendor provided drivers in beyond the scope of this document. Please consult distro and/or vendor-specific documentation.

If you’re running a Linux OS with X11 and graphics hardware and have not installed any OpenGL libraries you’re probably already using Mesa or Nouveau! Note that the windowing system, in this case X11, is required for on-screen interactive rendering. On Linux systems the easiest way to install Mesa is through your distro’s package manager. Most distros also provide packages for Mesa’s software-based renderers as well. Unfortunately, some OpenGL features may be disabled by your distro’s package maintainers to avoid patent or other licensing restrictions. If you find that this is the case and if for some reason you do not want to use your graphics hardware vendor software then you’ll likely want to build Mesa from source.

1. Download, Build and Install LLVM

$ wget http://releases.llvm.org/7.0.1/llvm-7.0.1.src.tar.xz
$ mkdir llvm
$ cd llvm
$ tar -xvf /path/to/llvm-7.0.1.src.tar.xz
$ mkdir llvm_build
$ mkdir llvm_install
$ cd  llvm_build
$ cmake                                           \
  -DCMAKE_BUILD_TYPE=Release                    \
  -DBUILD_SHARED_LIBS=ON                            \
  -DCMAKE_INSTALL_PREFIX=/path/to/llvm_install  \
  -DLLVM_ENABLE_RTTI=ON                         \
  -DLLVM_INSTALL_UTILS=ON                       \
  -DLLVM_TARGETS_TO_BUILD:STRING=X86            \
  ../llvm-7.0.1.src
$ make -j8 install

2. Download, Build and Install Mesa
Mesa download usually contains llvm-dependent preprocessed files. We do not want that, as they may rely on another version of llvm so we download a specific version without these.

$ wget https://gitlab.freedesktop.org/mesa/mesa/-/archive/mesa-18.3.3/mesa-mesa-18.3.3.tar.bz2
$ mkdir mesa
$ cd mesa
$ tar -xvf /path/to/mesa-mesa-18.3.3.tar.bz2
$ cd mesa-mesa-18.3.3
$ autoreconf --force --verbose --install
$ cd ../
$ mkdir mesa_build
$ mkdir mesa_install
$ cd mesa_build
$ ../mesa-mesa-18.3.3/configure --prefix=/path/to/mesa_install \
--enable-opengl --disable-osmesa --disable-gallium-osmesa \
--enable-glx --with-platforms=x11 --disable-gles1 --disable-gles2 \
--disable-va --disable-gbm --disable-xvmc --disable-vdpau \
--disable-shared-glapi --disable-dri --with-dri-drivers= \ 
--enable-llvm  --with-llvm-prefix=/path/to/llvm_install  \
--with-gallium-drivers=swrast,swr --with-swr-archs=avx,avx2 --disable-egl 
$ make -j8 install

3. Download and Build ParaView with mesa
Note : a glx related warning may be seen, that’s ok.
https://gitlab.kitware.com/paraview/paraview/issues/18777

$ mkdir paraview
$ cd paraview
$ git clone https://gitlab.kitware.com/paraview/paraview
$ cd paraview
$ git submodule update --init --recursive
$ cd ../
$ mkdir paraview_build
$ cd paraview_build
$ cmake -GNinja -DOPENGL_gl_LIBRARY=/path/to/mesa/install/lib/libGL.so \
-DOPENGL_INCLUDE_DIR=/path/to/mesa/install/include/GL \
-DOPENGL_EGL_INCLUDE_DIR= -D OPENGL_GLES2_INCLUDE_DIR= \
-DOPENGL_GLES3_INCLUDE_DIR= -DOPENGL_GLX_INCLUDE_DIR= \
-DOPENGL_egl_LIBRARY= -DOPENGL_gles2_LIBRARY=  \
-DOPENGL_gles3_LIBRARY= -DOPENGL_glu_LIBRARY= \
-DOPENGL_glx_LIBRARY= -DOPENGL_opengl_LIBRARY= ../paraview
$ LD_LIBRARY_PATH=/path/to/llvm_install/lib ninja

Note : depending of your version of ParaView, some cmake options may be ignored. This is ok.

4. Run ParaView (5.6.0 and earlier versions)

To Run it with mesa :

$ LD_LIBRARY_PATH=/path/to/llvm_install/lib:/path/to/mesa_install/lib ./bin/paraview
Help -> About : OpenGL : Mesa, llvmpipe...

If you have your GPU hardware vendor driver installed and module loaded, you can still use it :

LD_LIBRARY_PATH= ./bin/paraview
Help->About : OpenGL : Nvidia ...

5. Run ParaView (master version)
Note : This may change fast, see here :
https://gitlab.kitware.com/paraview/paraview/issues/18780

To Run it with mesa :

$ LD_LIBRARY_PATH=/path/to/llvm_install/lib:/path/to/mesa_install/lib ./bin/paraview
Help -> About : OpenGL : Mesa, llvmpipe...

If you have your GPU hardware vendor driver installed and module loaded, you can still use it :

LD_LIBRARY_PATH=/path/to/llvm/install/lib/:/path/to/mesa/install/lib  LD_PRELOAD=/usr/lib/libGL.so ./bin/paraview
Help->About : OpenGL : Nvidia ...

(Mathieu Westphal (Kitware)) #2

@cory.quammen : I have no idea why the coloring and bolding is all over the place.


(Cory Quammen (Kitware)) #3

Use ```bash to start the script portion. That seems to fix the formatting for me.


(Jean M. Favre) #4

Thanks to @mwestphal for the great tips.
I have been running ParaView 5.6 with Mesa 17.2.8 compiled with LLVM 5 for several months and things work well. Switching to Mesa 18.3.3 and following the recipes above, I get a run-time error:

ERROR: In /apps/daint/UES/ParaView/src/ParaView-v5.6.0/VTK/Rendering/OpenGL2/vtkShaderProgram.cxx, line 447

vtkShaderProgram (0x1bc0920): 0:1(10): error: GLSL 1.50 is not supported. Supported versions are: 1.10, and 1.20

and

indentERROR: In /apps/daint/UES/ParaView/src/ParaView-v5.6.0/VTK/Rendering/OpenGL2/vtkOpenGLRenderWindow.cxx, line 749

vtkOSOpenGLRenderWindow (0x1579a60): Unable to find a valid OpenGL 3.2 or later implementation. Please update your video card driver to the latest version. If you are using Mesa please make sure you have version 11.2 or later and make sure your driver in Mesa supports OpenGL 3.2 such as llvmpipe or openswr.

is this error with GLSL 1.5 not supported specific to ParaView 5.6? Is it worth it trying with the development branch?


(Mathieu Westphal (Kitware)) #5

I did not experience this issue with any version. I tested master, 5.6.0 and 5.5.0.