How to hide or supress vtk errors and warnings when using pvBatch

For years I’ve been getting VTK errors while running pvbatch via mpiexec. The errors don’t seem to have any impact as I am able to read in my OpenFOAM cases and generate all the desired images/videos.

But, the VTK output really pollutes stdErr. It’s difficult to see real errors detected in my scripts vs. the verbose output from vtk.

Is there anyway to silence this? I can’t just direct stderr to /dev/null, because inside my scripts there are real error checks (inside python script) that I need to log. I just want to get rid of the vtk stuff. Any ideas on how to do that?

So far I have tried this, but it had no impact:

> import vtk
> a = vtk.vtkOutputWindow()
> a.GlobalWarningDisplayOff()

Below is an example of this vtk output, it repeats once for each core, so for CFD cases with 500 cores, these logs become really hard to parse.

> ERROR: In /home/buildslave/dashboards/buildbot/paraview-pvbinsdash-linux-shared-release_superbuild/build/superbuild/paraview/src/VTK/Rendering/OpenGL2/vtkShaderProgram.cxx, line 408
> vtkShaderProgram (0x8220580): 1: #version 150
> 2: #ifdef GL_ES
> 3: #if __VERSION__ == 300
> 4: #define attribute in
> 5: #define varying out
> 6: #endif // 300
> 7: #else // GL_ES
> 8: #define highp
> 9: #define mediump
> 10: #define lowp
> 11: #if __VERSION__ == 150
> 12: #define attribute in
> 13: #define varying out
> 14: #endif
> 15: #endif // GL_ES
> 16: 
> 17: 
> 18: /*=========================================================================
> 19: 
> 20:   Program:   Visualization Toolkit
> 21:   Module:    vtkPolyDataVS.glsl
> 22: 
> 23:   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
> 24:   All rights reserved.
> 25:   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
> 26: 
> 27:      This software is distributed WITHOUT ANY WARRANTY; without even
> 28:      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
> 29:      PURPOSE.  See the above copyright notice for more information.
> 30: 
> 31: =========================================================================*/
> 32: 
> 33: attribute vec4 vertexMC;
> 34: 
> 35: // frag position in VC
> 36: //VTK::PositionVC::Dec
> 37: 
> 38: // optional normal declaration
> 39: //VTK::Normal::Dec
> 40: 
> 41: // extra lighting parameters
> 42: //VTK::Light::Dec
> 43: 
> 44: // Texture coordinates
> 45: attribute vec3 vecsMC;
> 46: varying vec3 tcoordVCVSOutput;
> 47: 
> 48: 
> 49: // material property values
> 50: attribute vec4 scalarColor;
> 51: varying vec4 vertexColorVSOutput;
> 52: 
> 53: // clipping plane vars
> 54: //VTK::Clip::Dec
> 55: 
> 56: // camera and actor matrix values
> 57: uniform mat4 MCDCMatrix;
> 58: 
> 59: // Apple Bug
> 60: //VTK::PrimID::Dec
> 61: 
> 62: // Value raster
> 63: //VTK::ValuePass::Dec
> 64: 
> 65: void main()
> 66: {
> 67:   vertexColorVSOutput =  scalarColor;
> 68: 
> 69:   //VTK::Normal::Impl
> 70: 
> 71:   tcoordVCVSOutput = vecsMC;
> 72: 
> 73:   //VTK::Clip::Impl
> 74: 
> 75:   //VTK::PrimID::Impl
> 76: 
> 77:     gl_Position = MCDCMatrix * vertexMC;
> 78: 
> 79: 
> 80:   //VTK::ValuePass::Impl
> 81: 
> 82:   //VTK::Light::Impl
> 83: }
> 84: 
> 
> 
> ERROR: In /home/buildslave/dashboards/buildbot/paraview-pvbinsdash-linux-shared-release_superbuild/build/superbuild/paraview/src/VTK/Rendering/OpenGL2/vtkShaderProgram.cxx, line 409
> vtkShaderProgram (0x8220580):

@martink may know more.

Is there any more to that error? There should be a bit more text at the end after vtkShaderProgram (0x8220580):

Indeed there is, here’s the full content.

> (  27.076s) [pvbatch.2       ]   vtkShaderProgram.cxx:462    ERR| vtkShaderProgram (0x111e46d0): 1: #version 150
> 2: #ifdef GL_ES
> 3: #ifdef GL_FRAGMENT_PRECISION_HIGH
> 4: precision highp float;
> 5: precision highp sampler2D;
> 6: precision highp sampler3D;
> 7: #else
> 8: precision mediump float;
> 9: precision mediump sampler2D;
> 10: precision mediump sampler3D;
> 11: #endif
> 12: #define texelFetchBuffer texelFetch
> 13: #define texture1D texture
> 14: #define texture2D texture
> 15: #define texture3D texture
> 16: #else // GL_ES
> 17: #define highp
> 18: #define mediump
> 19: #define lowp
> 20: #if __VERSION__ == 150
> 21: #define texelFetchBuffer texelFetch
> 22: #define texture1D texture
> 23: #define texture2D texture
> 24: #define texture3D texture
> 25: #endif
> 26: #endif // GL_ES
> 27: #define varying in
> 28: 
> 29: 
> 30: /*=========================================================================
> 31: 
> 32:   Program:   Visualization Toolkit
> 33:   Module:    vtkPolyDataFS.glsl
> 34: 
> 35:   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
> 36:   All rights reserved.
> 37:   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
> 38: 
> 39:      This software is distributed WITHOUT ANY WARRANTY; without even
> 40:      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
> 41:      PURPOSE.  See the above copyright notice for more information.
> 42: 
> 43: =========================================================================*/
> 44: // Template for the polydata mappers fragment shader
> 45: 
> 46: uniform int PrimitiveIDOffset;
> 47: 
> 48: 
> 49: 
> 50: // VC position of this fragment
> 51: //VTK::PositionVC::Dec
> 52: 
> 53: // Camera prop
> 54: uniform int cameraParallel;
> 55: 
> 56: 
> 57: // optional color passed in from the vertex shader, vertexColor
> 58: uniform bool OverridesColor;
> 59: uniform float ambientIntensity; // the material ambient
> 60: uniform float diffuseIntensity; // the material diffuse
> 61: uniform float opacityUniform; // the fragment opacity
> 62: uniform vec3 ambientColorUniform; // ambient color
> 63: uniform vec3 diffuseColorUniform; // diffuse color
> 64: in vec4 vertexColorVSOutput;
> 65: 
> 66: 
> 67: // optional surface normal declaration
> 68: //VTK::Normal::Dec
> 69: 
> 70: // extra lighting parameters
> 71: uniform vec3 lightColor0;
> 72:   uniform vec3 lightDirectionVC0; // normalized
> 73: uniform vec3 lightColor1;
> 74:   uniform vec3 lightDirectionVC1; // normalized
> 75: uniform vec3 lightColor2;
> 76:   uniform vec3 lightDirectionVC2; // normalized
> 77: uniform vec3 lightColor3;
> 78:   uniform vec3 lightDirectionVC3; // normalized
> 79: uniform vec3 lightColor4;
> 80:   uniform vec3 lightDirectionVC4; // normalized
> 81: 
> 82: 
> 83: // Texture maps
> 84: //VTK::TMap::Dec
> 85: 
> 86: // Texture coordinates
> 87: uniform int uMaskOnSurface;
> 88: uniform mat3 normalMatrix;
> 89: in vec3 tcoordVCVSOutput;
> 90: 
> 91: // picking support
> 92: //VTK::Picking::Dec
> 93: 
> 94: // Depth Peeling Support
> 95: //VTK::DepthPeeling::Dec
> 96: 
> 97: // clipping plane vars
> 98: //VTK::Clip::Dec
> 99: 
> 100: // the output of this shader
> 101: out vec4 fragOutput0;
> 102: out vec4 fragOutput1;
> 103: out vec4 fragOutput2;
> 104: 
> 105: 
> 106: // Apple Bug
> 107: //VTK::PrimID::Dec
> 108: 
> 109: // handle coincident offsets
> 110: uniform float cCValue;
> 111: 
> 112: // Value raster
> 113: //VTK::ValuePass::Dec
> 114: 
> 115: void main()
> 116: {
> 117:   // VC position of this fragment. This should not branch/return/discard.
> 118:   //VTK::PositionVC::Impl
> 119: 
> 120:   // Place any calls that require uniform flow (e.g. dFdx) here.
> 121:   //VTK::UniformFlow::Impl
> 122: 
> 123:   // Set gl_FragDepth here (gl_FragCoord.z by default)
> 124:   gl_FragDepth = gl_FragCoord.z + cCValue;
> 125: 
> 126: 
> 127:   // Early depth peeling abort:
> 128:   //VTK::DepthPeeling::PreColor
> 129: 
> 130:   // Apple Bug
> 131:   //VTK::PrimID::Impl
> 132: 
> 133:   //VTK::Clip::Impl
> 134: 
> 135:   //VTK::ValuePass::Impl
> 136: 
> 137:     vec3 ambientColor = ambientIntensity * vertexColorVSOutput.rgb;
> 138:   vec3 diffuseColor = diffuseIntensity * vertexColorVSOutput.rgb;
> 139:   float opacity = opacityUniform * vertexColorVSOutput.a;
> 140:   if (OverridesColor) {
> 141:     ambientColor = ambientColorUniform * ambientIntensity;
> 142:     diffuseColor = diffuseColorUniform * diffuseIntensity; }
> 143: 
> 144: 
> 145:   // Generate the normal if we are not passed in one
> 146:   //VTK::Normal::Impl
> 147: 
> 148:     fragOutput0 = vec4(ambientColor + diffuseColor, opacity);
> 149:   //VTK::Light::Impl
> 150: 
> 151: 
> 152:     vec3 tcoordLIC = normalMatrix * tcoordVCVSOutput;
> 153:   vec3 normN = normalize(normalVCVSOutput);
> 154:   float k = dot(tcoordLIC, normN);
> 155:   tcoordLIC = (tcoordLIC - k*normN);
> 156:   fragOutput1 = vec4(tcoordLIC.x, tcoordLIC.y, 0.0 , gl_FragCoord.z);
> 157:   if (uMaskOnSurface == 0)
> 158:     {
> 159:     fragOutput2 = vec4(tcoordVCVSOutput, gl_FragCoord.z);
> 160:     }
> 161:   else
> 162:     {
> 163:     fragOutput2 = vec4(tcoordLIC.x, tcoordLIC.y, 0.0 , gl_FragCoord.z);
> 164:     }
> 165: 
> 166: 
> 167:   if (fragOutput0.a <= 0.0)
> 168:     {
> 169:     discard;
> 170:     }
> 171: 
> 172:   //VTK::DepthPeeling::Impl
> 173: 
> 174:   //VTK::Picking::Impl
> 175: 
> 176:   // handle coincident offsets
> 177:   //VTK::Coincident::Impl
> 178: }
> 
> (  27.135s) [pvbatch.3       ]   vtkShaderProgram.cxx:462    ERR| vtkShaderProgram (0x1087c210): 1: #version 150
> 2: #ifdef GL_ES
> 3: #ifdef GL_FRAGMENT_PRECISION_HIGH
> 4: precision highp float;
> 5: precision highp sampler2D;
> 6: precision highp sampler3D;
> 7: #else
> 8: precision mediump float;
> 9: precision mediump sampler2D;
> 10: precision mediump sampler3D;
> 11: #endif
> 12: #define texelFetchBuffer texelFetch
> 13: #define texture1D texture
> 14: #define texture2D texture
> 15: #define texture3D texture
> 16: #else // GL_ES
> 17: #define highp
> 18: #define mediump
> 19: #define lowp
> 20: #if __VERSION__ == 150
> 21: #define texelFetchBuffer texelFetch
> 22: #define texture1D texture
> 23: #define texture2D texture
> 24: #define texture3D texture
> 25: #endif
> 26: #endif // GL_ES
> 27: #define varying in
> 28: 
> 29: 
> 30: /*=========================================================================
> 31: 
> 32:   Program:   Visualization Toolkit
> 33:   Module:    vtkPolyDataFS.glsl
> 34: 
> 35:   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
> 36:   All rights reserved.
> 37:   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
> 38: 
> 39:      This software is distributed WITHOUT ANY WARRANTY; without even
> 40:      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
> 41:      PURPOSE.  See the above copyright notice for more information.
> 42: 
> 43: =========================================================================*/
> 44: // Template for the polydata mappers fragment shader
> 45: 
> 46: uniform int PrimitiveIDOffset;
> 47: 
> 48: 
> 49: 
> 50: // VC position of this fragment
> 51: //VTK::PositionVC::Dec
> 52: 
> 53: // Camera prop
> 54: uniform int cameraParallel;
> 55: 
> 56: 
> 57: // optional color passed in from the vertex shader, vertexColor
> 58: uniform bool OverridesColor;
> 59: uniform float ambientIntensity; // the material ambient
> 60: uniform float diffuseIntensity; // the material diffuse
> 61: uniform float opacityUniform; // the fragment opacity
> 62: uniform vec3 ambientColorUniform; // ambient color
> 63: uniform vec3 diffuseColorUniform; // diffuse color
> 64: in vec4 vertexColorVSOutput;
> 65: 
> 66: 
> 67: // optional surface normal declaration
> 68: //VTK::Normal::Dec
> 69: 
> 70: // extra lighting parameters
> 71: uniform vec3 lightColor0;
> 72:   uniform vec3 lightDirectionVC0; // normalized
> 73: uniform vec3 lightColor1;
> 74:   uniform vec3 lightDirectionVC1; // normalized
> 75: uniform vec3 lightColor2;
> 76:   uniform vec3 lightDirectionVC2; // normalized
> 77: uniform vec3 lightColor3;
> 78:   uniform vec3 lightDirectionVC3; // normalized
> 79: uniform vec3 lightColor4;
> 80:   uniform vec3 lightDirectionVC4; // normalized
> 81: 
> 82: 
> 83: // Texture maps
> 84: //VTK::TMap::Dec
> 85: 
> 86: // Texture coordinates
> 87: uniform int uMaskOnSurface;
> 88: uniform mat3 normalMatrix;
> 89: in vec3 tcoordVCVSOutput;
> 90: 
> 91: // picking support
> 92: //VTK::Picking::Dec
> 93: 
> 94: // Depth Peeling Support
> 95: //VTK::DepthPeeling::Dec
> 96: 
> 97: // clipping plane vars
> 98: //VTK::Clip::Dec
> 99: 
> 100: // the output of this shader
> 101: out vec4 fragOutput0;
> 102: out vec4 fragOutput1;
> 103: out vec4 fragOutput2;
> 104: 
> 105: 
> 106: // Apple Bug
> 107: //VTK::PrimID::Dec
> 108: 
> 109: // handle coincident offsets
> 110: uniform float cCValue;
> 111: 
> 112: // Value raster
> 113: //VTK::ValuePass::Dec
> 114: 
> 115: void main()
> 116: {
> 117:   // VC position of this fragment. This should not branch/return/discard.
> 118:   //VTK::PositionVC::Impl
> 119: 
> 120:   // Place any calls that require uniform flow (e.g. dFdx) here.
> 121:   //VTK::UniformFlow::Impl
> 122: 
> 123:   // Set gl_FragDepth here (gl_FragCoord.z by default)
> 124:   gl_FragDepth = gl_FragCoord.z + cCValue;
> 125: 
> 126: 
> 127:   // Early depth peeling abort:
> 128:   //VTK::DepthPeeling::PreColor
> 129: 
> 130:   // Apple Bug
> 131:   //VTK::PrimID::Impl
> 132: 
> 133:   //VTK::Clip::Impl
> 134: 
> 135:   //VTK::ValuePass::Impl
> 136: 
> 137:     vec3 ambientColor = ambientIntensity * vertexColorVSOutput.rgb;
> 138:   vec3 diffuseColor = diffuseIntensity * vertexColorVSOutput.rgb;
> 139:   float opacity = opacityUniform * vertexColorVSOutput.a;
> 140:   if (OverridesColor) {
> 141:     ambientColor = ambientColorUniform * ambientIntensity;
> 142:     diffuseColor = diffuseColorUniform * diffuseIntensity; }
> 143: 
> 144: 
> 145:   // Generate the normal if we are not passed in one
> 146:   //VTK::Normal::Impl
> 147: 
> 148:     fragOutput0 = vec4(ambientColor + diffuseColor, opacity);
> 149:   //VTK::Light::Impl
> 150: 
> 151: 
> 152:     vec3 tcoordLIC = normalMatrix * tcoordVCVSOutput;
> 153:   vec3 normN = normalize(normalVCVSOutput);
> 154:   float k = dot(tcoordLIC, normN);
> 155:   tcoordLIC = (tcoordLIC - k*normN);
> 156:   fragOutput1 = vec4(tcoordLIC.x, tcoordLIC.y, 0.0 , gl_FragCoord.z);
> 157:   if (uMaskOnSurface == 0)
> 158:     {
> 159:     fragOutput2 = vec4(tcoordVCVSOutput, gl_FragCoord.z);
> 160:     }
> 161:   else
> 162:     {
> 163:     fragOutput2 = vec4(tcoordLIC.x, tcoordLIC.y, 0.0 , gl_FragCoord.z);
> 164:     }
> 165: 
> 166: 
> 167:   if (fragOutput0.a <= 0.0)
> 168:     {
> 169:     discard;
> 170:     }
> 171: 
> 172:   //VTK::DepthPeeling::Impl
> 173: 
> 174:   //VTK::Picking::Impl
> 175: 
> 176:   // handle coincident offsets
> 177:   //VTK::Coincident::Impl
> 178: }
> 
> (  27.135s) [pvbatch.3       ]   vtkShaderProgram.cxx:463    ERR| vtkShaderProgram (0x1087c210): 0(153) : error C1008: undefined variable "normalVCVSOutp
> ut"
> 
> (  27.076s) [pvbatch.2       ]   vtkShaderProgram.cxx:463    ERR| vtkShaderProgram (0x111e46d0): 0(153) : error C1008: undefined variable "normalVCVSOutp
> ut"
> 

So I know your question was about suppressing errors (I have no clue how to do that, @utkarsh.ayachit might know) But looking at the error I’m thinking you are using LIC on something that is not lighted. Not lighted could be data that doesn’t have point normals in it AND contains some points or lines. When the points or lines are rendered without normals the shader code for LIC fails as it needs a normal for it’s computations and there isn’t one. It is a bug in the LIC code (feel free to add an issue to VTK) but you could maybe work around it by not trying to LIC on points and lines. Maybe there is a filter in PV to extract just the 2D elements you could use.

Thanks! In the absence of a way to turn off the warnings, that’s very helpful advice on how to prevent them from occurring in the first place :slight_smile:

Thank you @martink for the suggestion! I was also stuck with the same issue while using LIC. paraview ver.5.8.0.

With ParaView 5.8, you can add the following to your script to turn off all messages:

from vtkmodules.vtkCommonCore import vtkLogger
vtkLogger.SetStderrVerbosity(vtkLogger.VERBOSITY_OFF)

This should work in pvpython, but it has limitations in pvbatch since it needs to be executed on each rank while pvbatch only executes the Python code on the root node. For that, you’ll need to put this in a dummy programmable source as follows:

# create a new 'Programmable Source'
programmableSource1 = ProgrammableSource()
programmableSource1.Script = """
    from vtkmodules.vtkCommonCore import vtkLogger
    vtkLogger.SetStderrVerbosity(vtkLogger.VERBOSITY_OFF)"""
programmableSource1.UpdatePipeline()
Delete(programmableSource1)
del programmableSource1

With ParaView 5.9, you can simply use the --verbosity=OFF command line argument as follows:

> ./bin/pvpython --verbosity=OFF ... script.py
3 Likes

Looks like a good Tips and Tricks entry :slight_smile:

I am using the programmable source fix in 5.7 and it works great, thanks so much for your post!