Exception messages- java- when using Clij2

Hello,
I am trying to use Clij2 filtering functions on stacks (either as xml or as tiff files). If I recall correctly it has worked once without problem, but since then I keep otaining the following exception messages:

(Fiji Is Just) ImageJ 2.1.0/1.53c; Java 1.8.0_172 [64-bit]; Windows 10 10.0; 6188MB of 12035MB (51%)

net.haesleinhuepf.clij.clearcl.exceptions.OpenCLException: OpenCL error: -4 → CL_MEM_OBJECT_ALLOCATION_FAILURE
at net.haesleinhuepf.clij.clearcl.backend.BackendUtils.checkOpenCLError(BackendUtils.java:346)
at net.haesleinhuepf.clij.clearcl.backend.jocl.ClearCLBackendJOCL.lambda$enqueueWriteToBuffer$25(ClearCLBackendJOCL.java:813)
at net.haesleinhuepf.clij.clearcl.backend.BackendUtils.checkExceptions(BackendUtils.java:171)
at net.haesleinhuepf.clij.clearcl.backend.jocl.ClearCLBackendJOCL.enqueueWriteToBuffer(ClearCLBackendJOCL.java:811)
at net.haesleinhuepf.clij.clearcl.ClearCLBuffer.readFrom(ClearCLBuffer.java:511)
at net.haesleinhuepf.clij.clearcl.ClearCLBuffer.readFrom(ClearCLBuffer.java:477)
at net.haesleinhuepf.clij.converters.implementations.ImagePlusToClearCLBufferConverter.convert(ImagePlusToClearCLBufferConverter.java:126)
at net.haesleinhuepf.clij.converters.implementations.ImagePlusToClearCLBufferConverter.convert(ImagePlusToClearCLBufferConverter.java:24)
at net.haesleinhuepf.clij.CLIJ.convert(CLIJ.java:475)
at net.haesleinhuepf.clij.CLIJ.push(CLIJ.java:406)
at net.haesleinhuepf.clij.macro.CLIJHandler.pushToGPU(CLIJHandler.java:267)
at net.haesleinhuepf.clij.macro.AbstractCLIJPlugin.run(AbstractCLIJPlugin.java:415)
at ij.plugin.filter.PlugInFilterRunner.processOneImage(PlugInFilterRunner.java:265)
at ij.plugin.filter.PlugInFilterRunner.(PlugInFilterRunner.java:114)
at ij.IJ.runUserPlugIn(IJ.java:237)
at ij.IJ.runPlugIn(IJ.java:198)
at ij.Executer.runCommand(Executer.java:150)
at ij.Executer.run(Executer.java:65)
at java.lang.Thread.run(Thread.java:748)

Is there anything I can do to improve this?
Thank you!
Best,
Prisca

1 Like

Hi @prisca ,

it sounds like you’re hitting some kind of memory limitations.

Can you give us some details on what operations are you calling, how large is the image you’re processing and which GPU you are using? Furthermore, the output of this macro might be helpful for debugging.

Best,
Robert

Hi Robert,

The operation called is a Median 3D box filter
the image is 1.3 or 1.8 GB
I am on a laptop with a Quadro P520
Your macro gives the following output:

Available CL backends:

  • net.haesleinhuepf.clij.clearcl.backend.jocl.ClearCLBackendJOCL@b00b1a7
    Functional backend:net.haesleinhuepf.clij.clearcl.backend.jocl.ClearCLBackendJOCL@148f7e2a
    Best backend:net.haesleinhuepf.clij.clearcl.backend.jocl.ClearCLBackendJOCL@6d31e630
    Used CL backend: net.haesleinhuepf.clij.clearcl.backend.jocl.ClearCLBackendJOCL@4b5f11f9
    ClearCL: ClearCLBase [mClearCLBackendInterface=net.haesleinhuepf.clij.clearcl.backend.jocl.ClearCLBackendJOCL@4b5f11f9, mPeerPointer=null]
    Number of platforms:2
    [0] NVIDIA CUDA
    Number of devices: 1
    Available devices:
    [0] Quadro P520
    NumberOfComputeUnits: 3
    Clock frequency: 1493
    Version: 1.2
    Extensions: cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_fp64 cl_khr_byte_addressable_store cl_khr_icd cl_khr_gl_sharing cl_nv_compiler_options cl_nv_device_attribute_query cl_nv_pragma_unroll cl_nv_d3d10_sharing cl_khr_d3d10_sharing cl_nv_d3d11_sharing cl_nv_copy_opts cl_khr_gl_event cl_nv_create_buffer cl_khr_int64_base_atomics cl_khr_int64_extended_atomics cl_kernel_attribute_nv
    GlobalMemorySizeInBytes: 2147483648
    LocalMemorySizeInBytes: 49152
    MaxMemoryAllocationSizeInBytes: 536870912
    MaxWorkGroupSize: 1024
    Compatible image types: [SignedNormalizedInt8, SignedNormalizedInt16, UnsignedNormalizedInt8, UnsignedNormalizedInt16, SignedInt8, SignedInt16, SignedInt32, UnsignedInt8, UnsignedInt16, UnsignedInt32, HalfFloat, Float]
    [1] Intel® OpenCL HD Graphics
    Number of devices: 1
    Available devices:
    [0] Intel® UHD Graphics
    NumberOfComputeUnits: 24
    Clock frequency: 1150
    Version: 3.0
    Extensions: cl_khr_byte_addressable_store cl_khr_fp16 cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_icd cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_intel_subgroups cl_intel_required_subgroup_size cl_intel_subgroups_short cl_khr_spir cl_intel_accelerator cl_intel_driver_diagnostics cl_khr_priority_hints cl_khr_throttle_hints cl_khr_create_command_queue cl_intel_subgroups_char cl_intel_subgroups_long cl_khr_il_program cl_intel_mem_force_host_memory cl_khr_fp64 cl_khr_subgroups cl_intel_spirv_device_side_avc_motion_estimation cl_intel_spirv_media_block_io cl_intel_spirv_subgroups cl_khr_spirv_no_integer_wrap_decoration cl_intel_unified_shared_memory_preview cl_khr_mipmap_image cl_khr_mipmap_image_writes cl_intel_planar_yuv cl_intel_packed_yuv cl_intel_motion_estimation cl_intel_device_side_avc_motion_estimation cl_intel_advanced_motion_estimation cl_khr_int64_base_atomics cl_khr_int64_extended_atomics cl_khr_image2d_from_buffer cl_khr_depth_images cl_intel_media_block_io cl_khr_3d_image_writes cl_khr_gl_sharing cl_khr_gl_depth_images cl_khr_gl_event cl_khr_gl_msaa_sharing cl_intel_dx9_media_sharing cl_khr_dx9_media_sharing cl_khr_d3d10_sharing cl_khr_d3d11_sharing cl_intel_d3d11_nv12_media_sharing cl_intel_unified_sharing cl_intel_simultaneous_sharing
    GlobalMemorySizeInBytes: 6767439872
    LocalMemorySizeInBytes: 65536
    MaxMemoryAllocationSizeInBytes: 3383719936
    MaxWorkGroupSize: 256
    Compatible image types: [SignedNormalizedInt8, SignedNormalizedInt16, UnsignedNormalizedInt8, UnsignedNormalizedInt16, SignedInt8, SignedInt16, SignedInt32, UnsignedInt8, UnsignedInt16, UnsignedInt32, HalfFloat, Float]
    Best GPU device for images: Quadro P520
    Best largest GPU device: Quadro P520

Exception: java.lang.NullPointerException

Thanks!
prisca

Hey @prisca ,

thanks for executing this script. Let’s take a closer look:

You have two GPUs in your computer:

with 2 GB of memory and a maximum image size of about 0.5 GB:

Furthermore:

With access to 6 GB of memory and a maximum image size of 3GB:

Thus, if you choose the Intel GPU in clij dialogs

or initialize the GPU in macros using the Intel GPU, your macros should work again:

run("CLIJ2 Macro Extensions", "cl_device=Intel");

Read more about memory management in the clij basics tutorial

Let me know if this helps!

Best,
Robert

Hi Robert,
Thanks a lot! I will follow your suggestions.
Best,
Prisca