JCUDA - ImageJ compatability issue

I am writing a plugin for ImageJ/Fiji with part of the computations being performed on GPU through JCUDA calls to .ptx files. I’m developing the plugin in Eclipse where I start by creating a instance of imageJ and then calling the plugin for the newly created version to speed up development:

final ij.ImageJ ij = new ij.ImageJ();
setVisible(true);			

clazz = SMLocalizer_.class;
url = clazz.getResource("/" + clazz.getName().replace('.', '/') + ".class").toString();
pluginsDir = url.substring("file:".length(), url.length() - clazz.getName().length() - ".class".length());
setProperty("plugins.dir", pluginsDir);				
runPlugIn(clazz.getName(), "");```

When calling using JCUDA through this instance everything works as expected but when I build a .jar file and transfer the plugin to ImageJ and attempt to run the same code the software crashes. Using CPU version of the code through the same plugin works as expected.
I've transfered copies of the native libraries to the main directory and the jcuda .jar (including jcudaUtils) to ImageJ\plugins\jars. 

I'm stuck on finding the cause for this crash and would very much appriciate any assistance in getting this working.

The error log produced when ImageJ crashes is:

long log
[spoiler]


> # A fatal error has been detected by the Java Runtime Environment:
> #
> #  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x000007fee4a33cff, pid=7828, tid=0x0000000000000eac
> #
> # JRE version: Java(TM) SE Runtime Environment (8.0_112-b15) (build 1.8.0_112-b15)
> # Java VM: Java HotSpot(TM) 64-Bit Server VM (25.112-b15 mixed mode windows-amd64 compressed oops)
> # Problematic frame:
> # C  [nvcuda.dll+0x143cff]
> #
> # Failed to write core dump. Minidumps are not enabled by default on client versions of Windows

> ---------------  T H R E A D  ---------------

> Current thread (0x000000003b0ac800):  JavaThread "AWT-EventQueue-0" [_thread_in_native, id=3756, stack(0x000000003e0b0000,0x000000003e2b0000)]

> siginfo: ExceptionCode=0xc0000005, reading address 0xffffffffffffffff

> Registers:
> RAX=0x0000000000000000, RBX=0xcccccccccccccccc, RCX=0x0000000041a67bf0, RDX=0x0000000000000000
> RSP=0x000000003e2ac950, RBP=0x000000003e2aca29, RSI=0x0000000000000000, RDI=0x000000003e2ac9c8
> R8 =0x0000000000000000, R9 =0x0000000000000000, R10=0x000000000000000c, R11=0x0000000041a67c70
> R12=0x0000000000000000, R13=0x000000003d71bce8, R14=0x000000003e2acab8, R15=0x000000003b0ac800
> RIP=0x000007fee4a33cff, EFLAGS=0x0000000000010286

> Top of Stack: (sp=0x000000003e2ac950)
> 0x000000003e2ac950:   000000003e2ac9c8 cccccccccccccccc
> 0x000000003e2ac960:   000000000000000c 0000000000000000
> 0x000000003e2ac970:   000000003e2acab8 000007fee4910dbe
> 0x000000003e2ac980:   0000000041a67c70 cccccccccccccccc
> 0x000000003e2ac990:   0000000041a67c70 0000000000000000
> 0x000000003e2ac9a0:   0000000041a67c70 000007fee4a99c80
> 0x000000003e2ac9b0:   000000003d71bce8 cccccccccccccccc
> 0x000000003e2ac9c0:   000000003b0ac800 0000000000000000
> 0x000000003e2ac9d0:   0000000041a67c70 000007fee645bb7e
> 0x000000003e2ac9e0:   0000000000000000 000007fee645f1b9
> 0x000000003e2ac9f0:   000000003d71bce8 000000003e2acb80
> 0x000000003e2aca00:   0000000000200021 000000003e2aca20
> 0x000000003e2aca10:   0000000041a67c70 cccccccccccccccc
> 0x000000003e2aca20:   000000003e2aca80 000007fee645e9d6
> 0x000000003e2aca30:   000000003b0ac9f8 000000003abc3ba0
> 0x000000003e2aca40:   0000000000000000 000000010000000b 

> Instructions: (pc=0x000007fee4a33cff)
> 0x000007fee4a33cdf:   ec ff 85 c0 75 2f 48 85 db 75 15 b8 90 01 00 00
> 0x000007fee4a33cef:   48 8b 5c 24 30 48 8b 74 24 38 48 83 c4 20 5f c3
> 0x000007fee4a33cff:   48 8b 5b 18 8b d6 48 8b cb e8 de 0f ec ff 85 c0
> 0x000007fee4a33d0f:   75 03 48 89 1f 48 8b 5c 24 30 48 8b 74 24 38 48 


> Register to memory mapping:

> RAX=0x0000000000000000 is an unknown value
> RBX=0xcccccccccccccccc is an unknown value
> RCX=0x0000000041a67bf0 is an unknown value
> RDX=0x0000000000000000 is an unknown value
> RSP=0x000000003e2ac950 is pointing into the stack for thread: 0x000000003b0ac800
> RBP=0x000000003e2aca29 is pointing into the stack for thread: 0x000000003b0ac800
> RSI=0x0000000000000000 is an unknown value
> RDI=0x000000003e2ac9c8 is pointing into the stack for thread: 0x000000003b0ac800
> R8 =0x0000000000000000 is an unknown value
> R9 =0x0000000000000000 is an unknown value
> R10=0x000000000000000c is an unknown value
> R11=0x0000000041a67c70 is an unknown value
> R12=0x0000000000000000 is an unknown value
> R13={method} {0x000000003d71bcf0} 'cuModuleGetFunctionNative' '(Ljcuda/driver/CUfunction;Ljcuda/driver/CUmodule;Ljava/lang/String;)I' in 'jcuda/driver/JCudaDriver'
> R14=0x000000003e2acab8 is pointing into the stack for thread: 0x000000003b0ac800
> R15=0x000000003b0ac800 is a thread


> Stack: [0x000000003e0b0000,0x000000003e2b0000],  sp=0x000000003e2ac950,  free space=2034k
> Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
> C  [nvcuda.dll+0x143cff]
> C  [nvcuda.dll+0x20dbe]
> C  [nvcuda.dll+0x1a9c80]
> C  [JCudaDriver-0.8.0RC-windows-x86_64.dll+0x7249]  Java_jcuda_driver_JCudaDriver_cuModuleGetFunctionNative+0x119
> C  0x0000000002dd5c94

> Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
> j  jcuda.driver.JCudaDriver.cuModuleGetFunctionNative(Ljcuda/driver/CUfunction;Ljcuda/driver/CUmodule;Ljava/lang/String;)I+0
> j  jcuda.driver.JCudaDriver.cuModuleGetFunction(Ljcuda/driver/CUfunction;Ljcuda/driver/CUmodule;Ljava/lang/String;)I+3
> j  localizeAndFit.run([I[D[I[I[I[II)Ljava/util/ArrayList;+853
> j  SMLocalizerGUI.localize_FitActionPerformed(Ljava/awt/event/ActionEvent;)V+89
> j  SMLocalizerGUI.access$29(LSMLocalizerGUI;Ljava/awt/event/ActionEvent;)V+2
> j  SMLocalizerGUI$30.actionPerformed(Ljava/awt/event/ActionEvent;)V+5
> j  javax.swing.AbstractButton.fireActionPerformed(Ljava/awt/event/ActionEvent;)V+83
> j  javax.swing.AbstractButton$Handler.actionPerformed(Ljava/awt/event/ActionEvent;)V+5
> j  javax.swing.DefaultButtonModel.fireActionPerformed(Ljava/awt/event/ActionEvent;)V+34
> j  javax.swing.DefaultButtonModel.setPressed(Z)V+117
> j  javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Ljava/awt/event/MouseEvent;)V+35
> j  java.awt.AWTEventMulticaster.mouseReleased(Ljava/awt/event/MouseEvent;)V+8
> j  java.awt.Component.processMouseEvent(Ljava/awt/event/MouseEvent;)V+64
> j  javax.swing.JComponent.processMouseEvent(Ljava/awt/event/MouseEvent;)V+23
> J 4022 C1 java.awt.Component.processEvent(Ljava/awt/AWTEvent;)V (220 bytes) @ 0x0000000003896844 [0x0000000003896320+0x524]
> J 4037 C1 java.awt.Container.processEvent(Ljava/awt/AWTEvent;)V (22 bytes) @ 0x00000000038a408c [0x00000000038a3d60+0x32c]
> J 3878 C1 java.awt.Component.dispatchEventImpl(Ljava/awt/AWTEvent;)V (883 bytes) @ 0x000000000380ce1c [0x00000000038076e0+0x573c]
> J 3877 C1 java.awt.Container.dispatchEventImpl(Ljava/awt/AWTEvent;)V (129 bytes) @ 0x0000000003240e4c [0x0000000003240d00+0x14c]
> J 3880 C1 java.awt.Component.dispatchEvent(Ljava/awt/AWTEvent;)V (6 bytes) @ 0x000000000305c884 [0x000000000305c780+0x104]
> j  java.awt.LightweightDispatcher.retargetMouseEvent(Ljava/awt/Component;ILjava/awt/event/MouseEvent;)V+327
> J 4252 C1 java.awt.LightweightDispatcher.processMouseEvent(Ljava/awt/event/MouseEvent;)Z (286 bytes) @ 0x0000000003947b04 [0x00000000039463c0+0x1744]
> J 3998 C1 java.awt.LightweightDispatcher.dispatchEvent(Ljava/awt/AWTEvent;)Z (73 bytes) @ 0x0000000003869c3c [0x0000000003869800+0x43c]
> J 3877 C1 java.awt.Container.dispatchEventImpl(Ljava/awt/AWTEvent;)V (129 bytes) @ 0x0000000003240dec [0x0000000003240d00+0xec]
> J 3993 C1 java.awt.Window.dispatchEventImpl(Ljava/awt/AWTEvent;)V (23 bytes) @ 0x000000000386cb24 [0x000000000386c540+0x5e4]
> J 3571 C1 java.awt.EventQueue.dispatchEventImpl(Ljava/awt/AWTEvent;Ljava/lang/Object;)V (149 bytes) @ 0x000000000374b97c [0x000000000374a040+0x193c]
> J 3569 C1 java.awt.EventQueue$3.run()Ljava/lang/Void; (60 bytes) @ 0x0000000003748edc [0x0000000003748cc0+0x21c]
> J 3568 C1 java.awt.EventQueue$3.run()Ljava/lang/Object; (5 bytes) @ 0x000000000374368c [0x0000000003743600+0x8c]
> v  ~StubRoutines::call_stub
> J 1434  java.security.AccessController.doPrivileged(Ljava/security/PrivilegedAction;Ljava/security/AccessControlContext;)Ljava/lang/Object; (0 bytes) @ 0x00000000032d8fa6 [0x00000000032d8f40+0x66]
> J 3856 C1 java.awt.EventQueue$4.run()Ljava/lang/Object; (5 bytes) @ 0x00000000031ad0f4 [0x00000000031accc0+0x434]
> v  ~StubRoutines::call_stub
> J 1434  java.security.AccessController.doPrivileged(Ljava/security/PrivilegedAction;Ljava/security/AccessControlContext;)Ljava/lang/Object; (0 bytes) @ 0x00000000032d8fa6 [0x00000000032d8f40+0x66]
> J 2918 C1 java.awt.EventQueue.dispatchEvent(Ljava/awt/AWTEvent;)V (80 bytes) @ 0x00000000031fecfc [0x00000000031fde40+0xebc]
> J 2923 C1 java.awt.EventDispatchThread.pumpOneEventForFilters(I)V (295 bytes) @ 0x0000000002f9fe94 [0x0000000002f9e1c0+0x1cd4]
> j  java.awt.EventDispatchThread.pumpEventsForFilter(ILjava/awt/Conditional;Ljava/awt/EventFilter;)V+35
> j  java.awt.EventDispatchThread.pumpEventsForHierarchy(ILjava/awt/Conditional;Ljava/awt/Component;)V+11
> j  java.awt.EventDispatchThread.pumpEvents(ILjava/awt/Conditional;)V+4
> j  java.awt.EventDispatchThread.pumpEvents(Ljava/awt/Conditional;)V+3
> j  java.awt.EventDispatchThread.run()V+9
> v  ~StubRoutines::call_stub

> ---------------  P R O C E S S  ---------------

> Java Threads: ( => current thread )
>   0x000000003b83f800 JavaThread "TimerQueue" daemon [_thread_blocked, id=5512, stack(0x000000003d010000,0x000000003d210000)]
>   0x00000000395df000 JavaThread "zSelector" [_thread_blocked, id=7996, stack(0x000000003d410000,0x000000003d610000)]
>   0x000000000231d000 JavaThread "DestroyJavaVM" [_thread_blocked, id=1480, stack(0x0000000000030000,0x0000000000230000)]
>   0x000000003b0cf800 JavaThread "Image Fetcher 0" daemon [_thread_blocked, id=6796, stack(0x000000003eab0000,0x000000003ecb0000)]
>   0x000000003a284800 JavaThread "SciJava-5395143d-Thread-1" [_thread_blocked, id=7244, stack(0x000000003e8b0000,0x000000003eab0000)]
>   0x000000003abd8000 JavaThread "SciJava-5395143d-Thread-0" [_thread_blocked, id=7908, stack(0x000000003e4b0000,0x000000003e6b0000)]
> =>0x000000003b0ac800 JavaThread "AWT-EventQueue-0" [_thread_in_native, id=3756, stack(0x000000003e0b0000,0x000000003e2b0000)]
>   0x0000000037a41800 JavaThread "AWT-Windows" daemon [_thread_in_native, id=328, stack(0x0000000039050000,0x0000000039250000)]
>   0x000000003a679800 JavaThread "AWT-Shutdown" [_thread_blocked, id=1068, stack(0x0000000038e50000,0x0000000039050000)]
>   0x000000003865d800 JavaThread "Java2D Disposer" daemon [_thread_blocked, id=3492, stack(0x0000000038c50000,0x0000000038e50000)]
>   0x000000003483b000 JavaThread "Service Thread" daemon [_thread_blocked, id=2336, stack(0x0000000036c80000,0x0000000036e80000)]
>   0x00000000347d9000 JavaThread "C1 CompilerThread3" daemon [_thread_blocked, id=7608, stack(0x0000000036a80000,0x0000000036c80000)]
>   0x00000000347b0800 JavaThread "C2 CompilerThread2" daemon [_thread_blocked, id=2640, stack(0x0000000036880000,0x0000000036a80000)]
>   0x00000000347af800 JavaThread "C2 CompilerThread1" daemon [_thread_blocked, id=3680, stack(0x0000000036680000,0x0000000036880000)]
>   0x00000000347a9800 JavaThread "C2 CompilerThread0" daemon [_thread_blocked, id=6752, stack(0x0000000036480000,0x0000000036680000)]
>   0x00000000347a6000 JavaThread "Attach Listener" daemon [_thread_blocked, id=6656, stack(0x0000000036280000,0x0000000036480000)]
>   0x000000003479b000 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=6528, stack(0x0000000036080000,0x0000000036280000)]
>   0x000000003479a000 JavaThread "Surrogate Locker Thread (Concurrent GC)" daemon [_thread_blocked, id=8144, stack(0x0000000035e80000,0x0000000036080000)]
>   0x0000000034780000 JavaThread "Finalizer" daemon [_thread_blocked, id=1220, stack(0x0000000035c80000,0x0000000035e80000)]
>   0x0000000034739800 JavaThread "Reference Handler" daemon [_thread_blocked, id=6676, stack(0x0000000035a80000,0x0000000035c80000)]

> Other Threads:
>   0x0000000034732800 VMThread [stack: 0x0000000035880000,0x0000000035a80000] [id=2664]
>   0x000000003481e800 WatcherThread [stack: 0x0000000036e80000,0x0000000037080000] [id=8120]

> VM state:not at safepoint (normal execution)

> VM Mutex/Monitor currently owned by a thread: None


> Heap:
>  par new generation   total 157248K, used 110978K [0x00000001c0200000, 0x00000001caca0000, 0x00000001e9b90000)
>   eden space 139776K,  66% used [0x00000001c0200000, 0x00000001c5d50948, 0x00000001c8a80000)
>   from space 17472K, 100% used [0x00000001c8a80000, 0x00000001c9b90000, 0x00000001c9b90000)
>   to   space 17472K,   0% used [0x00000001c9b90000, 0x00000001c9b90000, 0x00000001caca0000)
>  concurrent mark-sweep generation total 349568K, used 28924K [0x00000001e9b90000, 0x00000001ff0f0000, 0x00000007c0000000)
>  Metaspace       used 34239K, capacity 34470K, committed 34908K, reserved 1079296K
>   class space    used 4594K, capacity 4670K, committed 4772K, reserved 1048576K

> Card table byte_map: [0x0000000013180000,0x0000000016180000] byte_map_base: 0x000000001237f000

> Marking Bits: (CMSBitMap*) 0x00000000024d7318
>  Bits: [0x00000000198c0000, 0x0000000030e51c00)

> Mod Union Table: (CMSBitMap*) 0x00000000024d73d8
>  Bits: [0x0000000030e60000, 0x0000000031436470)

> Polling page: 0x00000000003c0000

> CodeCache: size=245760Kb used=11995Kb max_used=12020Kb free=233764Kb
>  bounds [0x0000000002dc0000, 0x0000000003990000, 0x0000000011dc0000]
>  total_blobs=4385 nmethods=3778 adapters=517
>  compilation: enabled

> Compilation events (10 events):
> Event: 16.627 Thread 0x00000000347d9000 nmethod 4294 0x0000000003974810 code [0x0000000003974960, 0x0000000003974b30]
> Event: 16.628 Thread 0x00000000347af800 nmethod 4292 0x0000000003977910 code [0x0000000003977a60, 0x0000000003977bb8]
> Event: 16.631 Thread 0x00000000347a9800 4295   !   4       java.net.URL::<init> (543 bytes)
> Event: 16.634 Thread 0x00000000347b0800 4296 % !   4       java.util.concurrent.ConcurrentHashMap::transfer @ 99 (832 bytes)
> Event: 16.635 Thread 0x00000000347af800 4297       4       java.util.jar.Attributes$Name::hashCode (24 bytes)
> Event: 16.640 Thread 0x00000000347af800 nmethod 4297 0x0000000003975750 code [0x00000000039758a0, 0x0000000003975b78]
> Event: 16.649 Thread 0x00000000347b0800 nmethod 4296% 0x0000000003977f50 code [0x00000000039780e0, 0x0000000003978ee8]
> Event: 16.698 Thread 0x00000000347af800 4298   !   4       java.util.zip.Inflater::inflate (113 bytes)
> Event: 16.700 Thread 0x00000000347af800 nmethod 4298 0x0000000003979750 code [0x00000000039798a0, 0x0000000003979d48]
> Event: 16.741 Thread 0x00000000347a9800 nmethod 4295 0x0000000003982050 code [0x0000000003982440, 0x0000000003985ac0]

> GC Heap History (4 events):
> Event: 1.309 GC heap before
> {Heap before GC invocations=0 (full 0):
>  par new generation   total 157248K, used 139776K [0x00000001c0200000, 0x00000001caca0000, 0x00000001e9b90000)
>   eden space 139776K, 100% used [0x00000001c0200000, 0x00000001c8a80000, 0x00000001c8a80000)
>   from space 17472K,   0% used [0x00000001c8a80000, 0x00000001c8a80000, 0x00000001c9b90000)
>   to   space 17472K,   0% used [0x00000001c9b90000, 0x00000001c9b90000, 0x00000001caca0000)
>  concurrent mark-sweep generation total 349568K, used 0K [0x00000001e9b90000, 0x00000001ff0f0000, 0x00000007c0000000)
>  Metaspace       used 11589K, capacity 11730K, committed 11776K, reserved 1058816K
>   class space    used 1699K, capacity 1755K, committed 1792K, reserved 1048576K
> Event: 1.356 GC heap after
> Heap after GC invocations=1 (full 0):
>  par new generation   total 157248K, used 17472K [0x00000001c0200000, 0x00000001caca0000, 0x00000001e9b90000)
>   eden space 139776K,   0% used [0x00000001c0200000, 0x00000001c0200000, 0x00000001c8a80000)
>   from space 17472K, 100% used [0x00000001c9b90000, 0x00000001caca0000, 0x00000001caca0000)
>   to   space 17472K,   0% used [0x00000001c8a80000, 0x00000001c8a80000, 0x00000001c9b90000)
>  concurrent mark-sweep generation total 349568K, used 11527K [0x00000001e9b90000, 0x00000001ff0f0000, 0x00000007c0000000)
>  Metaspace       used 11589K, capacity 11730K, committed 11776K, reserved 1058816K
>   class space    used 1699K, capacity 1755K, committed 1792K, reserved 1048576K
> }
> Event: 2.343 GC heap before
> {Heap before GC invocations=1 (full 0):
>  par new generation   total 157248K, used 157248K [0x00000001c0200000, 0x00000001caca0000, 0x00000001e9b90000)
>   eden space 139776K, 100% used [0x00000001c0200000, 0x00000001c8a80000, 0x00000001c8a80000)
>   from space 17472K, 100% used [0x00000001c9b90000, 0x00000001caca0000, 0x00000001caca0000)
>   to   space 17472K,   0% used [0x00000001c8a80000, 0x00000001c8a80000, 0x00000001c9b90000)
>  concurrent mark-sweep generation total 349568K, used 11527K [0x00000001e9b90000, 0x00000001ff0f0000, 0x00000007c0000000)
>  Metaspace       used 21342K, capacity 21652K, committed 21960K, reserved 1069056K
>   class space    used 2877K, capacity 2965K, committed 3020K, reserved 1048576K
> Event: 2.383 GC heap after
> Heap after GC invocations=2 (full 0):
>  par new generation   total 157248K, used 17472K [0x00000001c0200000, 0x00000001caca0000, 0x00000001e9b90000)
>   eden space 139776K,   0% used [0x00000001c0200000, 0x00000001c0200000, 0x00000001c8a80000)
>   from space 17472K, 100% used [0x00000001c8a80000, 0x00000001c9b90000, 0x00000001c9b90000)
>   to   space 17472K,   0% used [0x00000001c9b90000, 0x00000001c9b90000, 0x00000001caca0000)
>  concurrent mark-sweep generation total 349568K, used 28924K [0x00000001e9b90000, 0x00000001ff0f0000, 0x00000007c0000000)
>  Metaspace       used 21342K, capacity 21652K, committed 21960K, reserved 1069056K
>   class space    used 2877K, capacity 2965K, committed 3020K, reserved 1048576K
> }

> Deoptimization events (10 events):
> Event: 9.482 Thread 0x000000003b0ac800 Uncommon trap: reason=class_check action=maybe_recompile pc=0x0000000002f31194 method=javax.swing.UIDefaults.getFromHashtable(Ljava/lang/Object;)Ljava/lang/Object; @ 122
> Event: 9.484 Thread 0x000000003b0ac800 Uncommon trap: reason=class_check action=maybe_recompile pc=0x0000000002f31194 method=javax.swing.UIDefaults.getFromHashtable(Ljava/lang/Object;)Ljava/lang/Object; @ 122
> Event: 9.500 Thread 0x000000003b0ac800 Uncommon trap: reason=unstable_if action=reinterpret pc=0x0000000003747134 method=sun.awt.SunToolkit.getAppContext(Ljava/lang/Object;)Lsun/awt/AppContext; @ 4
> Event: 9.500 Thread 0x000000003b0ac800 Uncommon trap: reason=unstable_if action=reinterpret pc=0x0000000002fcff28 method=sun.awt.SunToolkit.getAppContext(Ljava/lang/Object;)Lsun/awt/AppContext; @ 4
> Event: 9.534 Thread 0x000000003b0ac800 Uncommon trap: reason=unstable_if action=reinterpret pc=0x000000000319750c method=javax.swing.JComponent.getClientProperty(Ljava/lang/Object;)Ljava/lang/Object; @ 16
> Event: 13.737 Thread 0x00000000397b0800 Uncommon trap: reason=intrinsic action=make_not_entrant pc=0x00000000038e9c38 method=GaussSolver.Fit()LParticle; @ 1087
> Event: 13.826 Thread 0x000000003b0cf800 Uncommon trap: reason=bimorphic action=maybe_recompile pc=0x0000000002fab2cc method=java.io.BufferedInputStream.read([BII)I @ 101
> Event: 13.826 Thread 0x000000003b0cf800 Uncommon trap: reason=bimorphic action=maybe_recompile pc=0x0000000002fab2cc method=java.io.BufferedInputStream.read([BII)I @ 101
> Event: 13.826 Thread 0x000000003b0cf800 Uncommon trap: reason=bimorphic action=maybe_recompile pc=0x0000000002fab2cc method=java.io.BufferedInputStream.read([BII)I @ 101
> Event: 13.827 Thread 0x000000003b0cf800 Uncommon trap: reason=bimorphic action=maybe_recompile pc=0x0000000002fab2cc method=java.io.BufferedInputStream.read([BII)I @ 101

> Internal exceptions (10 events):
> Event: 9.103 Thread 0x000000003768a000 Exception <a 'java/lang/ClassNotFoundException': ToolBar> (0x00000001c36a9058) thrown at [C:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u112\7884\hotspot\src\share\vm\classfile\systemDictionary.cpp, line 210]
> Event: 9.103 Thread 0x000000003768a000 Exception <a 'java/lang/ClassNotFoundException': ToggleButton> (0x00000001c36a9608) thrown at [C:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u112\7884\hotspot\src\share\vm\classfile\systemDictionary.cpp, line 210]
> Event: 9.103 Thread 0x000000003768a000 Exception <a 'java/lang/ClassNotFoundException': javax/swing/JToolBarSeparator> (0x00000001c36a9a68) thrown at [C:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u112\7884\hotspot\src\share\vm\classfile\systemDictionary.cpp, line 210]
> Event: 9.103 Thread 0x000000003768a000 Exception <a 'java/lang/ClassNotFoundException': ToolBarSeparator> (0x00000001c36a9f00) thrown at [C:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u112\7884\hotspot\src\share\vm\classfile\systemDictionary.cpp, line 210]
> Event: 9.103 Thread 0x000000003768a000 Exception <a 'java/lang/ClassNotFoundException': ToolTip> (0x00000001c36aa640) thrown at [C:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u112\7884\hotspot\src\share\vm\classfile\systemDictionary.cpp, line 210]
> Event: 9.104 Thread 0x000000003768a000 Exception <a 'java/lang/ClassNotFoundException': Tree> (0x00000001c36ab228) thrown at [C:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u112\7884\hotspot\src\share\vm\classfile\systemDictionary.cpp, line 210]
> Event: 9.104 Thread 0x000000003768a000 Exception <a 'java/lang/ClassNotFoundException': Tree> (0x00000001c36ab968) thrown at [C:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u112\7884\hotspot\src\share\vm\classfile\systemDictionary.cpp, line 210]
> Event: 9.104 Thread 0x000000003768a000 Exception <a 'java/lang/ClassNotFoundException': javax/swing/JTreeCell> (0x00000001c36abce8) thrown at [C:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u112\7884\hotspot\src\share\vm\classfile\systemDictionary.cpp, line 210]
> Event: 9.104 Thread 0x000000003768a000 Exception <a 'java/lang/ClassNotFoundException': TreeCell> (0x00000001c36ac170) thrown at [C:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u112\7884\hotspot\src\share\vm\classfile\systemDictionary.cpp, line 210]
> Event: 9.104 Thread 0x000000003768a000 Exception <a 'java/lang/ClassNotFoundException': RootPane> (0x00000001c36ac9e8) thrown at [C:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u112\7884\hotspot\src\share\vm\classfile\systemDictionary.cpp, line 210]

> Events (10 events):
> Event: 16.699 loading class jcuda/driver/CUDA_TEXTURE_DESC
> Event: 16.699 loading class jcuda/driver/CUDA_TEXTURE_DESC done
> Event: 16.699 loading class jcuda/driver/CUoccupancyB2DSize
> Event: 16.699 loading class jcuda/driver/CUoccupancyB2DSize done
> Event: 16.766 loading class jcuda/driver/CUcontext
> Event: 16.766 loading class jcuda/driver/CUcontext done
> Event: 16.919 loading class jcuda/driver/CUmodule
> Event: 16.919 loading class jcuda/driver/CUmodule done
> Event: 16.919 loading class jcuda/driver/CUfunction
> Event: 16.919 loading class jcuda/driver/CUfunction done


> Dynamic libraries:
> 0x0000000000400000 - 0x0000000000462000 	C:\Users\...\Documents\ImageJ.app\ImageJ-win64.exe
> 0x0000000077410000 - 0x00000000775ba000 	C:\Windows\SYSTEM32
> tdll.dll
> 0x00000000772f0000 - 0x000000007740f000 	C:\Windows\system32\kernel32.dll
> 0x000007fefd160000 - 0x000007fefd1ca000 	C:\Windows\system32\KERNELBASE.dll
> 0x0000000074e40000 - 0x0000000074ec7000 	C:\Windows\System32\SYSFER.DLL
> 0x000007fefd770000 - 0x000007fefd84b000 	C:\Windows\system32\ADVAPI32.dll
> 0x000007feff150000 - 0x000007feff1ef000 	C:\Windows\system32\msvcrt.dll
> 0x000007fefda30000 - 0x000007fefda4f000 	C:\Windows\SYSTEM32\sechost.dll
> 0x000007fefda60000 - 0x000007fefdb8d000 	C:\Windows\system32\RPCRT4.dll
> 0x00000000771f0000 - 0x00000000772ea000 	C:\Windows\system32\USER32.dll
> 0x000007fefddc0000 - 0x000007fefde27000 	C:\Windows\system32\GDI32.dll
> 0x000007fefda50000 - 0x000007fefda5e000 	C:\Windows\system32\LPK.dll
> 0x000007fefdb90000 - 0x000007fefdc5a000 	C:\Windows\system32\USP10.dll
> 0x000007feff420000 - 0x000007feff44e000 	C:\Windows\system32\IMM32.DLL
> 0x000007fefdc60000 - 0x000007fefdd69000 	C:\Windows\system32\MSCTF.dll
> 0x000000006bd30000 - 0x000000006bd69000 	C:\Program Files\Java\jdk1.8.0_112\jre\bin\splashscreen.dll
> 0x0000000071b80000 - 0x0000000071c52000 	C:\Windows\system32\MSVCR100.dll
> 0x000007fefb680000 - 0x000007fefb6d6000 	C:\Windows\system32\uxtheme.dll
> 0x0000000052230000 - 0x0000000052aca000 	C:\Program Files\Java\jdk1.8.0_112\jre\bin\server\jvm.dll
> 0x000007fef8a90000 - 0x000007fef8a99000 	C:\Windows\system32\WSOCK32.dll
> 0x000007fefdd70000 - 0x000007fefddbd000 	C:\Windows\system32\WS2_32.dll
> 0x000007fefd6e0000 - 0x000007fefd6e8000 	C:\Windows\system32\NSI.dll
> 0x000007fefafe0000 - 0x000007fefb01b000 	C:\Windows\system32\WINMM.dll
> 0x000007fefc1c0000 - 0x000007fefc1cc000 	C:\Windows\system32\VERSION.dll
> 0x00000000775e0000 - 0x00000000775e7000 	C:\Windows\system32\PSAPI.DLL
> 0x000000006c720000 - 0x000000006c72f000 	C:\Program Files\Java\jdk1.8.0_112\jre\bin\verify.dll
> 0x000000006bd80000 - 0x000000006bda9000 	C:\Program Files\Java\jdk1.8.0_112\jre\bin\java.dll
> 0x000000006bd10000 - 0x000000006bd26000 	C:\Program Files\Java\jdk1.8.0_112\jre\bin\zip.dll
> 0x000007feff210000 - 0x000007feff413000 	C:\Windows\system32\ole32.dll
> 0x000007fefcfe0000 - 0x000007fefcfef000 	C:\Windows\system32\CRYPTBASE.dll
> 0x000007fefded0000 - 0x000007fefec5a000 	C:\Windows\system32\SHELL32.dll
> 0x000007fefd6f0000 - 0x000007fefd761000 	C:\Windows\system32\SHLWAPI.dll
> 0x000007fefd150000 - 0x000007fefd15f000 	C:\Windows\system32\profapi.dll
> 0x000007fefd600000 - 0x000007fefd6da000 	C:\Windows\system32\OLEAUT32.DLL
> 0x0000000065320000 - 0x00000000654b8000 	C:\Program Files\Java\jdk1.8.0_112\jre\bin\awt.dll
> 0x000007fefb2b0000 - 0x000007fefb2c8000 	C:\Windows\system32\DWMAPI.DLL
> 0x000007feee8a0000 - 0x000007feee9bd000 	C:\Windows\system32\opengl32.dll
> 0x000007fef1e90000 - 0x000007fef1ebd000 	C:\Windows\system32\GLU32.dll
> 0x000007feebbb0000 - 0x000007feebca1000 	C:\Windows\system32\DDRAW.dll
> 0x000007fefaaf0000 - 0x000007fefaaf8000 	C:\Windows\system32\DCIMAN32.dll
> 0x000007fefd850000 - 0x000007fefda27000 	C:\Windows\system32\SETUPAPI.dll
> 0x000007fefd220000 - 0x000007fefd256000 	C:\Windows\system32\CFGMGR32.dll
> 0x000007fefd350000 - 0x000007fefd36a000 	C:\Windows\system32\DEVOBJ.dll
> 0x000007fef98d0000 - 0x000007fef9970000 	C:\Windows\WinSxS\amd64_microsoft.windows.common-controls_6595b64144ccf1df_5.82.7601.18837_none_a4d981ff711297b6\COMCTL32.dll
> 0x000000006bcc0000 - 0x000000006bd07000 	C:\Program Files\Java\jdk1.8.0_112\jre\bin\fontmanager.dll
> 0x000000006bca0000 - 0x000000006bcba000 	C:\Program Files\Java\jdk1.8.0_112\jre\bin
> et.dll
> 0x000007fefc920000 - 0x000007fefc975000 	C:\Windows\system32\mswsock.dll
> 0x000007fefc910000 - 0x000007fefc917000 	C:\Windows\System32\wship6.dll
> 0x000000006bc80000 - 0x000000006bc91000 	C:\Program Files\Java\jdk1.8.0_112\jre\bin
> io.dll
> 0x00000000650e0000 - 0x0000000065122000 	C:\Program Files\Java\jdk1.8.0_112\jre\bin	2k.dll
> 0x000007fefd560000 - 0x000007fefd5f9000 	C:\Windows\system32\CLBCatQ.DLL
> 0x000007fefbb30000 - 0x000007fefbd24000 	C:\Windows\WinSxS\amd64_microsoft.windows.common-controls_6595b64144ccf1df_6.0.7601.18837_none_fa3b1e3d17594757\comctl32.dll
> 0x000007fefb100000 - 0x000007fefb261000 	C:\Windows\system32\WindowsCodecs.dll
> 0x000007fefcf80000 - 0x000007fefcfd7000 	C:\Windows\system32\apphelp.dll
> 0x000007fef3170000 - 0x000007fef3385000 	C:\PROGRA~1\MICROS~1\Office16\GROOVEEX.DLL
> 0x000007fef3530000 - 0x000007fef3547000 	C:\Windows\system32\VCRUNTIME140.dll
> 0x000007fef3520000 - 0x000007fef3524000 	C:\Windows\system32\api-ms-win-crt-runtime-l1-1-0.dll
> 0x000007fef3420000 - 0x000007fef3514000 	C:\Windows\system32\ucrtbase.DLL
> 0x000007fef3410000 - 0x000007fef3413000 	C:\Windows\system32\api-ms-win-core-timezone-l1-1-0.dll
> 0x000007fef3400000 - 0x000007fef3403000 	C:\Windows\system32\api-ms-win-core-file-l2-1-0.dll
> 0x000007fef33f0000 - 0x000007fef33f3000 	C:\Windows\system32\api-ms-win-core-localization-l1-2-0.dll
> 0x000007fef33e0000 - 0x000007fef33e3000 	C:\Windows\system32\api-ms-win-core-synch-l1-2-0.dll
> 0x000007fef33d0000 - 0x000007fef33d3000 	C:\Windows\system32\api-ms-win-core-processthreads-l1-1-1.dll
> 0x000007fef33c0000 - 0x000007fef33c3000 	C:\Windows\system32\api-ms-win-core-file-l1-2-0.dll
> 0x000007fef33b0000 - 0x000007fef33b4000 	C:\Windows\system32\api-ms-win-crt-string-l1-1-0.dll
> 0x000007fef33a0000 - 0x000007fef33a3000 	C:\Windows\system32\api-ms-win-crt-heap-l1-1-0.dll
> 0x000007fef3390000 - 0x000007fef3394000 	C:\Windows\system32\api-ms-win-crt-stdio-l1-1-0.dll
> 0x000007fef3160000 - 0x000007fef3164000 	C:\Windows\system32\api-ms-win-crt-convert-l1-1-0.dll
> 0x000007fef30c0000 - 0x000007fef315e000 	C:\Windows\system32\MSVCP140.dll
> 0x000007fef30b0000 - 0x000007fef30b3000 	C:\Windows\system32\api-ms-win-crt-locale-l1-1-0.dll
> 0x000007fef30a0000 - 0x000007fef30a5000 	C:\Windows\system32\api-ms-win-crt-math-l1-1-0.dll
> 0x000007fef3090000 - 0x000007fef3095000 	C:\Windows\system32\api-ms-win-crt-multibyte-l1-1-0.dll
> 0x000007fef3080000 - 0x000007fef3083000 	C:\Windows\system32\api-ms-win-crt-time-l1-1-0.dll
> 0x000007fef3070000 - 0x000007fef3073000 	C:\Windows\system32\api-ms-win-crt-filesystem-l1-1-0.dll
> 0x000007fef3060000 - 0x000007fef3063000 	C:\Windows\system32\api-ms-win-crt-environment-l1-1-0.dll
> 0x000007fef3050000 - 0x000007fef3053000 	C:\Windows\system32\api-ms-win-crt-utility-l1-1-0.dll
> 0x000007fef6d50000 - 0x000007fef706e000 	C:\Windows\system32\msi.dll
> 0x000007feefbf0000 - 0x000007fef046e000 	C:\PROGRA~1\MICROS~1\Office16\1033\GrooveIntlResource.dll
> 0x000007fef2530000 - 0x000007fef2574000 	C:\Users\...\AppData\Roaming\Dropbox\bin\DropboxExt64.3.0.dll
> 0x0000000067f50000 - 0x0000000067f7a000 	C:\Program Files\Java\jdk1.8.0_112\jre\bin\dcpr.dll
> 0x000007fefcb70000 - 0x000007fefcb88000 	C:\Windows\system32\CRYPTSP.dll
> 0x000007fefc660000 - 0x000007fefc6a7000 	C:\Windows\system32\rsaenh.dll
> 0x000007fefd090000 - 0x000007fefd0a4000 	C:\Windows\system32\RpcRtRemote.dll
> 0x000007fee6530000 - 0x000007fee6670000 	C:\Users\...\Documents\ImageJ.app\JCudaRuntime-0.8.0RC-windows-x86_64.dll
> 0x000007fee6440000 - 0x000007fee6525000 	C:\Users\...\Documents\ImageJ.app\JCudaDriver-0.8.0RC-windows-x86_64.dll
> 0x000007fee48f0000 - 0x000007fee52c9000 	C:\Windows\system32
> vcuda.dll
> 0x000007fee6d10000 - 0x000007fee6dbc000 	C:\Windows\system32
> vfatbinaryLoader.dll
> 0x000007fef9aa0000 - 0x000007fef9e8c000 	C:\Windows\system32
> vapi64.dll
> 0x000007fefd1d0000 - 0x000007fefd20b000 	C:\Windows\system32\WINTRUST.dll
> 0x000007fefd390000 - 0x000007fefd4fd000 	C:\Windows\system32\CRYPT32.dll
> 0x000007fefd140000 - 0x000007fefd14f000 	C:\Windows\system32\MSASN1.dll
> 0x000007fef50b0000 - 0x000007fef51d5000 	C:\Windows\system32\dbghelp.dll


[/spoiler]

First of all, it’s good that you got it running so far. Just yesterday I added a note at jcuda.org - ImageJ Plugin HowTo saying
This section has to be reviewed. Some information that is found here may not be up to date.
I had created this ImageJ test years ago, but haven’t worked actively with it since then. In any case, if your problem persists, this could be a chance to update this section as well.

Regarding the actual problem: The crash seems to come from somewhere deeply inside the nvcuda.dll, and the last JCuda call before that was cuModuleGetFunction.

The code that you provided so far may not directly be relevant, but looks like there are some potential reasons for the error.

Most importantly: Are you sure that the path strings that are assembled there are correct, and that it can really load the CUmodule?

If you haven’t done so: The first thing before initializing the driver API with cuInit should be to call
JCudaDriver.setExceptionsEnabled(true);
to eagerly detect errors. I suspect that it might not be able to load the module, and that this might eventually cause this crash.

If this does not help, we could try to narrow down the search space. I could try to set up an ImageJ plugin with the latest versions, and, if necessary, you could provide some more of your code, if it turns out to be relevant to reproduce the error.

Hi,

The cuModuleGetFunction command was indeed where the code failed. It looks like, contrary to what I assumed, that the plugin.jar does not contain the .ptx files I thought it did. Moving the .ptx to the main directory of ImageJ solves the issue.

This solution is far from optimal though as it will clutter the main directory with alot of extra files (and makes using the ImageJ update mechanisms rather tricky).

So for the updating of the ImageJ section I’d suggest adding the note on .ptx file placement. I don’t currently know if it will run with the new library build that was introduced this fall, I’ve built my own libraries in .dll format rather then the new `.jar``` native libraries.

Do you have any suggestion on how to make eclipse include the .ptx files in a way that ImageJ will later on find them? Simply creating a project .jar including them does not seem to have worked.

First, regarding the update of the ImageJ section and the general information about the .CU/.PTX placement: I’ll have to review the whole section. Again, this section was mainly intended as a rough guideline, based solely on a „proof of concept“ that I created.

These have also been my first steps with ImageJ, so I’m not sure about the „ImageJ update mechanisms“ that you mentioned - I’ll have to read more about this.


Regarding the main question:

I’m not entirely sure what was the „root cause“ of the problem that you experienced. Also because it is not clear how you tried to load the PTX file.

Based on a guess, I have to mention that it is not possible to directly load the PTX: You cannot say
cuModuleLoad...(..., somethingThatIsContainedInTheJar);.

But it is definitely is possible to include a PTX file in a JAR, load the PTX from the JAR into memory, and then create a CUmodule from this data. This is also done in the „jcuda-vec“ library:

So the steps should be:

(Due to some recent changes, the cuModuleLoadDataEx call could be simplified a bit, but this would only be a minor change, and in its given form, it should work in any case)

If you encounter any problems (or have further feedback regarding the update of the ImageJ-HowTo), please let me know.

Regarding ImageJ, it allows for pushing updates to plugins by adding the plugin through a repository so that whenever an update becomes availble ImageJ automatically syncs it to newest version (alternatively manually install the plugin).

My initial call to load the .ptx looks like this:

				cuInit(0);
				CUdevice device = new CUdevice();
				cuDeviceGet(device, 0);
				CUcontext context = new CUcontext();
				cuCtxCreate(context, 0, device);
				// Load the PTX that contains the kernel.
				CUmodule module = new CUmodule();
				cuModuleLoad(module, "medianFilter.ptx");
				// Obtain a handle to the kernel function.
				CUfunction function = new CUfunction();
				cuModuleGetFunction(function, module, "medianKernel");```

I'll look into the load the PTX through first packaging it into a Jar as you suggest, thank you for the suggestion.

I'd be happy to discuss the ImageJ-HowTo with you should you want any input.

Ok, that was my guess:
cuModuleLoad(module, "medianFilter.ptx");
This will only work when the PTX file is found “locally”, in the file system. And the question of what “locally” means can be particularly difficult when all this is loaded from a JAR that is a plugin to an application …

As a generic, flexible, “easily deployable” solution, I’d suggest putting the PTX into the JAR, as described above. (In the current ImageJ-HowTO, the .CU file is compiled at runtime - this is even less generic, but again, was mainly inteded as a proof of concept).

Regarding the update mechanism that you mentioned… this sounds a bit “dangerous”, because you hardly ever know which CUDA version the client will have installed. Although the Driver API should be the most flexible in this regard (so that you can use the JCuda Driver API 0.7.5 even when CUDA 8.0 is installed), this does not apply to the runtime libraries, and not in the reverse direction (i.e. using an ImageJ-Plugin with JCuda 0.8.0 may not work on a CUDA 7.5 system), so one should always have an eye on that.