Forge Analytics

Installing ParaView with OSMesa on Ubuntu

An installation guide for a batch-executable ParaView build using OSMesa for CPU-based rendering on Ubuntu 16.04 LTS.

What Is ParaView

From the ParaView website:

ParaView is an open-source, multi-platform data analysis and visualization application. ParaView users can quickly build visualizations to analyze their data using qualitative and quantitative techniques. The data exploration can be done interactively in 3D or programmatically using ParaView’s batch processing capabilities.

ParaView was developed to analyze extremely large datasets using distributed memory computing resources. It can be run on supercomputers to analyze datasets of petascale size as well as on laptops for smaller data, has become an integral tool in many national laboratories, universities and industry, and has won several awards related to high performance computation.

ParaView for Computer Aided Engineering (CAE)

ParaView is particularly useful for CAE applications, as an open-source post-processing package that requires no license fees and is capable of interfacing with simulation results from both commercial and open-source solvers.

The combination of scriptability, extensibility and its open-source license makes it an excellent platform for automating CAE analysis workflows.

Installation

In this guide, we will be installing ParaView using the off-screen build of the Mesa graphics library, called OSMesa.

Building ParaView with OSMesa’s off-screen interface will allow users to execute scripts to produce data visualizations without requiring the batch process to use or even have access to a display device.

This build of ParaView can be used to execute data visualization processes in the background on a workstation, or on an HPC system as a batch submission job.

Dependencies

Most system dependencies can be installed with Ubuntu’s system package manager.

In your terminal, run:

sudo apt install autoconf build-essential libtool gfortran

However, the ParaView installation process requires a CMake version newer than 3.6.1. For this, we’ll install CMake from source.

Below is a simple example for installing to /opt. You may wish to change these steps to conform to your administration policies.

cd /opt
sudo wget https://cmake.org/files/v3.10/cmake-3.10.1-Linux-x86_64.sh
sudo chmod +x cmake-3.10.1-Linux-x86_64.sh
sudo ./cmake-3.10.1-Linux-x86_64.sh

Scroll down until you are prompted to accept or reject the license agreement. Press y to accept.

Next, you will be asked where you would like to install CMake. Press y.

Then, link the executables to /usr/local/bin by executing the following in your terminal:

sudo ln -s /opt/cmake-3.10.1-Linux-x86_64/bin/* /usr/local/bin

Finally, check that cmake can be executed:

cmake --version

You should see “cmake version 3.10.1” printed to the terminal.

Installing ParaView

The instructions below provide sensible defaults for installing ParaView 5.4.1 to your system. You may need to adjust some settings to suit your needs.

We will be using the “ParaView Superbuild” approach for the install. You can read more about it here.

First, collect and configure the required source code. In a terminal, execute:

cd /opt
sudo git clone --recursive https://gitlab.kitware.com/paraview/paraview-superbuild.git
cd paraview-superbuild
sudo git checkout v5.4.1
sudo git submodule update

Then, make a build directory for the ParaView installation:

sudo mkdir -p /opt/paraview-5.4.1
cd /opt/paraview-5.4.1

Next, we’ll configure the CMake settings:

sudo cmake ../paraview-superbuild/
sudo ccmake .

Then, use the arrow keys and the enter button to change the following settings from their defaults:

CMAKE_INSTALL_PREFIX=/opt/paraview-5.4.1
ENABLE_ffmpeg=ON
ENABLE_fontconfig=ON
ENABLE_freetype=ON
ENABLE_matplotlib=ON
ENABLE_mpi=ON
ENABLE_numpy=ON
ENABLE_osmesa=ON
ENABLE_ospray=ON
ENABLE_png=ON
ENABLE_python=ON
ENABLE_pythonsetuptools=ON
ENABLE_scipy=ON

Then, hit c to save your configuration to CMakeCache.txt. Then hit q to exit.

Next, in your terminal, build and install ParaView:

sudo cmake .
sudo make -j 4 && sudo make install

Testing

To test your ParaView installation, you can use the following Python script.

import paraview.simple


def main():
    render_view = paraview.simple.GetActiveViewOrCreate('RenderView')
    render_view.ViewSize = [1920, 1080]

    sphere = paraview.simple.Sphere()
    sphere_display = paraview.simple.Show(sphere, render_view)
    sphere_display.DiffuseColor = [1.0, 0.0, 0.0]

    render_view.CameraPosition = [-5.0, 0.0, 0.0]
    render_view.CameraFocalPoint = [0.0, 0.0, 0.0]
    render_view.CameraViewUp = [0.0, 0.0, 1.0]
    render_view.CameraParallelScale = 1.0

    paraview.simple.SaveScreenshot('./test.png', render_view)


if __name__ == '__main__':
    main()

To execute the script, run:

/opt/paraview-5.4.1/bin/pvbatch /path/to/script.py

The output should be a png image file called test.png that is saved to the directory from which the script was called.

The image should look like this:

ParaView Test

Have a Question?

Contact Us