Clij 2D blur leading to arrayindexoutofboundsexception


I wanted to test clij to see if it can speed up some GUI-based pre-processing in FIJI, namely filtering large images with a gaussian before passing them to other software.

I have a large (5326x3798x1960) image, which I want to filter in 2D, and this works fine, if a bit slowly via process -> filters -> Gaussian Blur. If I try Plugins -> ImageJ on GPU (CLIJ) -> Filter -> Blur 2D on GPU, I get the error:

(Fiji Is Just) ImageJ 2.0.0-rc-69/1.52n; Java 1.8.0_172 [64-bit]; Linux 4.15.0-48-generic; 77950MB of 350000MB (22%)
	at java.lang.System.arraycopy(Native Method)
	at net.haesleinhuepf.clij.converters.implementations.ImagePlusToClearCLBufferConverter.convert(
	at net.haesleinhuepf.clij.converters.implementations.ImagePlusToClearCLBufferConverter.convert(
	at net.haesleinhuepf.clij.CLIJ.convert(
	at net.haesleinhuepf.clij.macro.CLIJHandler.pushToGPU(
	at ij.plugin.filter.PlugInFilterRunner.processOneImage(
	at ij.plugin.filter.PlugInFilterRunner.<init>(
	at ij.IJ.runUserPlugIn(
	at ij.IJ.runPlugIn(
	at ij.Executer.runCommand(

I had assumed, that as this was a 2D operation, it would send the image plane by plane (or in batches) to the GPU, so it would be able to handle such a large image (although copying to the GPU might negate any speedup.

Are 2D filters on an image of this size possible?


cc: @haesleinhuepf

5326 x 3798 x 1960 16bit stack, 73.8GB, (in memory).
Ubuntu 18.04, FIJI version in the error message, CLIJ was updated today.
384GB RAM (350GB assigned to FIJI), 160GB free at the time of test.
OpenCL device - NVIDIA TITAN RTX (24GB)

1 Like

Hi @adamltyson,

huh. That’s a quite big image. If you process it slice by slice, it will work. But you need to do the slice-by-slice-thingy yourself in a small macro. Congrats to the amazing GPU btw :wink:

Another point is: If you push image data to the GPU in order to do a single operation, it might not be very fast as you pay increased processing time with CPU-GPU transfer time. Exploiting GPUs is worthwhile if you have several processing steps, repetitive tasks (e.g. slice by slice processing) and big images (you definitely have that). Read more here:

A bit more technical details: CLIJ does support processing big images in the GPU (I often work with 5-10 GB blocks on older Nvidia Titans). However, when working with ImageJ, the images must be transferred to the GPU in smaller blocks (up to what a Java array can carry). I wrote an example macro for that such a transfer/operation: This example also shows you how to debug memory consumption within the GPU. That might help if you try to push it towards its boundaries. Big images on Nvidia cards also sometime cause so called time-outs if you run really heavy stuff on them. I wrote a little paragraph about that in the troubleshooting section:

Good luck with that! Let me know how it goes!