Clij NegativeArraySizeException or ArrayIndexOutOfBounds exceptions when using a large stack

When trying to re-slice a 10.5GB ome.tiff I get the following error:

(Fiji Is Just) ImageJ 2.0.0-rc-69/1.52n; Java 1.8.0_172 [64-bit]; Linux 4.15.0-51-generic; 6343MB of 82834MB (7%)
 
java.lang.NegativeArraySizeException
	at net.haesleinhuepf.clij.converters.implementations.ImagePlusToClearCLBufferConverter.convert(ImagePlusToClearCLBufferConverter.java:107)
	at net.haesleinhuepf.clij.converters.implementations.ImagePlusToClearCLBufferConverter.convert(ImagePlusToClearCLBufferConverter.java:26)
	at net.haesleinhuepf.clij.CLIJ.convert(CLIJ.java:402)
	at net.haesleinhuepf.clij.CLIJ.push(CLIJ.java:356)
	at net.haesleinhuepf.clij.macro.CLIJHandler.pushToGPU(CLIJHandler.java:214)
	at net.haesleinhuepf.clij.macro.AbstractCLIJPlugin.run(AbstractCLIJPlugin.java:297)
	at ij.plugin.filter.PlugInFilterRunner.processOneImage(PlugInFilterRunner.java:266)
	at ij.plugin.filter.PlugInFilterRunner.<init>(PlugInFilterRunner.java:114)
	at ij.IJ.runUserPlugIn(IJ.java:231)
	at ij.IJ.runPlugIn(IJ.java:193)
	at ij.Executer.runCommand(Executer.java:137)
	at ij.Executer.run(Executer.java:63)
	at java.lang.Thread.run(Thread.java:748)

When trying to make a MIP I get this:

(Fiji Is Just) ImageJ 2.0.0-rc-69/1.52n; Java 1.8.0_172 [64-bit]; Linux 4.15.0-51-generic; 7553MB of 82834MB (9%)
 
java.lang.ArrayIndexOutOfBoundsException
	at java.lang.System.arraycopy(Native Method)
	at net.haesleinhuepf.clij.converters.implementations.ImagePlusToClearCLBufferConverter.convert(ImagePlusToClearCLBufferConverter.java:115)
	at net.haesleinhuepf.clij.converters.implementations.ImagePlusToClearCLBufferConverter.convert(ImagePlusToClearCLBufferConverter.java:26)
	at net.haesleinhuepf.clij.CLIJ.convert(CLIJ.java:402)
	at net.haesleinhuepf.clij.CLIJ.push(CLIJ.java:356)
	at net.haesleinhuepf.clij.macro.CLIJHandler.pushToGPU(CLIJHandler.java:214)
	at net.haesleinhuepf.clij.macro.AbstractCLIJPlugin.run(AbstractCLIJPlugin.java:297)
	at ij.plugin.filter.PlugInFilterRunner.processOneImage(PlugInFilterRunner.java:266)
	at ij.plugin.filter.PlugInFilterRunner.<init>(PlugInFilterRunner.java:114)
	at ij.IJ.runUserPlugIn(IJ.java:231)
	at ij.IJ.runPlugIn(IJ.java:193)
	at ij.Executer.runCommand(Executer.java:137)
	at ij.Executer.run(Executer.java:63)
	at java.lang.Thread.run(Thread.java:748)

I would expect to get “out of memory” type of error if that was the problem. GPU is 1080Ti.

Also, I noticed there is no option to set the destination for these results (even though CLIJ says that’s a required parameter…)

Hey @Useless,

thanks for reporting this issue. Unfortunately, image transfer to the GPU is limited to what a Java array can carry at the moment. For 8-bit images, this means an upper limit of 2 GB, for 32-bit images it’s 8 GB.

However, there is a workaround, you can allocate an image of larger size in the GPU and send images slice by slice to the GPU. I also recently added Ext.CLIJ_pushCurrentSlice(image); to the API for exactly this purpose. Example code for allocating big images lives here.

Furthermore, GPU-acceleration in general only pays off if you run whole workflows on the GPU. It might not make much sense if you just do a maximum projection on the GPU, just because pushing the image to the GPU and pulling the result back takes time. :wink:

Regarding the set destination-option: Dialogs usually don’t ask for destination images, because they are created when using CLIJ via dialogs. You can only specify the name of the destination image name when calling the macro extensions. I will update the documentation with regard to this. Thanks for pointing me to that!

Let me know if this works!

Cheers,
Robert

Thank you for your reply, I will try this when I get around to it! Good work on implementing GPU acceleration!

1 Like