VTK ray cast volume mapper, how to disable usage of GPU?

I have observed a strange behavior of VTK.
Same program run on computer with GPU is much slower than computer only have CPU.
applied:
volume_mapper = vtk.vtkGPUVolumeRayCastMapper()

On computer1(only have CPU) : takes 1 second to finish rendering
On computer2 (Nvidia GPU1080): takes 10 seconds to finish rendering

If change to

volume_mapper = vtk.vtkFixedPointVolumeRayCastMapper()

On computer1(only have CPU) : takes 1 second to finish rendering
On computer2 (Nvidia GPU1080): takes 3 seconds to finish rendering

My question is for a computer with GPU, how can I disable VTK to use GPU?
Thanks in advance.

If your GPU does not have enough memory to store your entire data set in its dedicated memory then vtkGPUVolumeRaycastMapper will be probably slower than vtkFixedPointVolumeRayCastMapper.

1 Like

Thanks @lassoan !

The question is, even I run the rendering on a multi-GPU machine which has 32G memory, the speed is same (very low). And the data is not big (512512120 bytes) at all.
One strange thing is when the rendering is running:
On computer1(only have CPU) : memory monitoring showing memory usage increased by 800M
On computer2 (Nvidia GPU1080): memory monitoring showing memory usage almost no change

What could be the reason? Seems the GPU memory is not used by the rendering at all.

Volume rendering of a 512 x 512 x 120 volume on an NVidia GeForce 1080 using vtkGPUVolumeRaycastMapper should not take 10sec, but approximately 0.01sec. Maybe something is wrong with the graphics driver or some system configuration. What operating system do you use? Does volume rendering in 3D Slicer work well in 3D Slicer? What is the scalar type of the volume (short, float, double…)?

vtkFixedPointVolumeRaycastMapper precomputes gradients and space leap volume, while vtkGPUVolumeRaycastMapper computes these on-the-fly. So, it is normal that the CPU mapper uses more memory. 800MB seems too much, though. If send a link to your source code then we can have a quick glance to see if there is anything suspicious.

Thanks @lassoan
OS is Ubuntu 16.04
3D Slicer works fine
Didn’t find a way to check the scalar type of volume, guess it is float

Hi @lassoan
What can I do to increase the image quality when using vtk as server side rendering?

The overall appearance is mainly determined by the transfer functions and lighting. You can decrease the sampling distances and increase the render window size to show finer details.

1 Like

Thanks @lassoan