deepjavalibrary / deepjavalibrary/djl

DJL fails to load `torch_cuda.dll` UnsatisfiedLinkError on Windows 11 CUDA12.9

Open
#3,740 2 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Java
Stars
4.9k
Forks
759
Avg merge
16h 15m
Merged PRs (30d)
15

Description

## Description
DJL crashes when it's trying to load `torch_cuda.dll` on Windows 11. Oddly this works on Ubuntu 24.04.

I suspect it might have something to do with the CUDA environment, but I am not sure where to start given error message.

### Expected Behavior
The library loads.

### Error Message

```text
2025-07-22 09:12:25,546 [main] DEBUG ai.djl.engine.Engine - Registering EngineProvider: PyTorch 2025-07-22 09:12:25,552 [main] DEBUG ai.djl.engine.Engine - Found default engine: PyTorch 2025-07-22 09:12:30,575 [main] DEBUG ai.djl.pytorch.jni.LibUtils - Using cache dir: C:\Users\IDIES\.djl.ai\pytorch\2.5.1-cu124-win-x86_64 2025-07-22 09:12:30,577 [main] INFO ai.djl.pytorch.jni.LibUtils - Downloading https://publish.djl.ai/pytorch/2.5.1/cu124/win-x86_64/native/lib/zlibwapi.dll.gz ...
2025-07-22 09:12:30,598 [main] INFO ai.djl.pytorch.jni.LibUtils - Downloading https://publish.djl.ai/pytorch/2.5.1/cu124/win-x86_64/native/lib/cupti64_2024.1.0.dll.gz ...
2025-07-22 09:12:30,677 [main] INFO ai.djl.pytorch.jni.LibUtils - Downloading https://publish.djl.ai/pytorch/2.5.1/cu124/win-x86_64/native/lib/cudnn_ops64_9.dll.gz ...
2025-07-22 09:12:33,724 [main] INFO ai.djl.pytorch.jni.LibUtils - Downloading https://publish.djl.ai/pytorch/2.5.1/cu124/win-x86_64/native/lib/cudnn_cnn64_9.dll.gz ...
2025-07-22 09:12:33,867 [main] INFO ai.djl.pytorch.jni.LibUtils - Downloading https://publish.djl.ai/pytorch/2.5.1/cu124/win-x86_64/native/lib/torch.dll.gz ...
2025-07-22 09:12:33,883 [main] INFO ai.djl.pytorch.jni.LibUtils - Downloading https://publish.djl.ai/pytorch/2.5.1/cu124/win-x86_64/native/lib/cufftw64_11.dll.gz ...
2025-07-22 09:12:33,899 [main] INFO ai.djl.pytorch.jni.LibUtils - Downloading https://publish.djl.ai/pytorch/2.5.1/cu124/win-x86_64/native/lib/nvrtc64_120_0.dll.gz ...
2025-07-22 09:12:34,677 [main] INFO ai.djl.pytorch.jni.LibUtils - Downloading https://publish.djl.ai/pytorch/2.5.1/cu124/win-x86_64/native/lib/cusolverMg64_11.dll.gz ...
2025-07-22 09:12:36,496 [main] INFO ai.djl.pytorch.jni.LibUtils - Downloading https://publish.djl.ai/pytorch/2.5.1/cu124/win-x86_64/native/lib/torch_cuda.dll.gz ...
2025-07-22 09:12:57,664 [main] INFO ai.djl.pytorch.jni.LibUtils - Downloading https://publish.djl.ai/pytorch/2.5.1/cu124/win-x86_64/native/lib/cufft64_11.dll.gz ...
2025-07-22 09:13:04,739 [main] INFO ai.djl.pytorch.jni.LibUtils - Downloading https://publish.djl.ai/pytorch/2.5.1/cu124/win-x86_64/native/lib/cublas64_12.dll.gz ...
2025-07-22 09:13:07,214 [main] INFO ai.djl.pytorch.jni.LibUtils - Downloading https://publish.djl.ai/pytorch/2.5.1/cu124/win-x86_64/native/lib/cudnn_graph64_9.dll.gz ...
2025-07-22 09:13:07,283 [main] INFO ai.djl.pytorch.jni.LibUtils - Downloading https://publish.djl.ai/pytorch/2.5.1/cu124/win-x86_64/native/lib/uv.dll.gz ...
2025-07-22 09:13:07,302 [main] INFO ai.djl.pytorch.jni.LibUtils - Downloading https://publish.djl.ai/pytorch/2.5.1/cu124/win-x86_64/native/lib/caffe2_nvrtc.dll.gz ...
2025-07-22 09:13:07,309 [main] INFO ai.djl.pytorch.jni.LibUtils - Downloading https://publish.djl.ai/pytorch/2.5.1/cu124/win-x86_64/native/lib/torch_cpu.dll.gz ...
2025-07-22 09:13:10,234 [main] INFO ai.djl.pytorch.jni.LibUtils - Downloading https://publish.djl.ai/pytorch/2.5.1/cu124/win-x86_64/native/lib/c10.dll.gz ...
2025-07-22 09:13:10,271 [main] INFO ai.djl.pytorch.jni.LibUtils - Downloading https://publish.djl.ai/pytorch/2.5.1/cu124/win-x86_64/native/lib/cudnn_adv64_9.dll.gz ...
2025-07-22 09:13:16,271 [main] INFO ai.djl.pytorch.jni.LibUtils - Downloading https://publish.djl.ai/pytorch/2.5.1/cu124/win-x86_64/native/lib/c10_cuda.dll.gz ...
2025-07-22 09:13:16,287 [main] INFO ai.djl.pytorch.jni.LibUtils - Downloading https://publish.djl.ai/pytorch/2.5.1/cu124/win-x86_64/native/lib/cudart64_12.dll.gz ...
2025-07-22 09:13:16,312 [main] INFO ai.djl.pytorch.jni.LibUtils - Downloading https://publish.djl.ai/pytorch/2.5.1/cu124/win-x86_64/native/lib/fbgemm.dll.gz ...
2025-07-22 09:13:16,350 [main] INFO ai.djl.pytorch.jni.LibUtils - Downloading https://publish.djl.ai/pytorch/2.5.1/cu124/win-x86_64/native/lib/curand64_10.dll.gz ...
2025-07-22 09:13:17,993 [main] INFO ai.djl.pytorch.jni.LibUtils - Downloading https://publish.djl.ai/pytorch/2.5.1/cu124/win-x86_64/native/lib/cudnn_engines_runtime_compiled64_9.dll.gz ...
2025-07-22 09:13:18,168 [main] INFO ai.djl.pytorch.jni.LibUtils - Downloading https://publish.djl.ai/pytorch/2.5.1/cu124/win-x86_64/native/lib/nvrtc-builtins64_124.dll.gz ...
2025-07-22 09:13:18,247 [main] INFO ai.djl.pytorch.jni.LibUtils - Downloading https://publish.djl.ai/pytorch/2.5.1/cu124/win-x86_64/native/lib/cudnn_heuristic64_9.dll.gz ...
2025-07-22 09:13:19,471 [main] INFO ai.djl.pytorch.jni.LibUtils - Downloading https://publish.djl.ai/pytorch/2.5.1/cu124/win-x86_64/native/lib/libiomp5md.dll.gz ...
2025-07-22 09:13:19,521 [main] INFO ai.djl.pytorch.jni.LibUtils - Downloading https://publish.djl.ai/pytorch/2.5.1/cu124/win-x86_64/native/lib/cusolver64_11.dll.gz ...
2025-07-22 09:13:22,168 [main] INFO ai.djl.pytorch.jni.LibUtils - Downloading https://publish.djl.ai/pytorch/2.5.1/cu124/win-x86_64/native/lib/cudnn64_9.dll.gz ...
2025-07-22 09:13:22,200 [main] INFO ai.djl.pytorch.jni.LibUtils - Downloading https://publish.djl.ai/pytorch/2.5.1/cu124/win-x86_64/native/lib/cublasLt64_12.dll.gz ...
2025-07-22 09:13:33,240 [main] INFO ai.djl.pytorch.jni.LibUtils - Downloading https://publish.djl.ai/pytorch/2.5.1/cu124/win-x86_64/native/lib/cudnn_engines_precompiled64_9.dll.gz ...
2025-07-22 09:13:47,240 [main] INFO ai.djl.pytorch.jni.LibUtils - Downloading https://publish.djl.ai/pytorch/2.5.1/cu124/win-x86_64/native/lib/nvToolsExt64_1.dll.gz ...
2025-07-22 09:13:47,334 [main] INFO ai.djl.pytorch.jni.LibUtils - Downloading https://publish.djl.ai/pytorch/2.5.1/cu124/win-x86_64/native/lib/nvJitLink_120_0.dll.gz ...
2025-07-22 09:13:48,146 [main] INFO ai.djl.pytorch.jni.LibUtils - Downloading https://publish.djl.ai/pytorch/2.5.1/cu124/win-x86_64/native/lib/cusparse64_12.dll.gz ...
2025-07-22 09:13:55,615 [main] INFO ai.djl.pytorch.jni.LibUtils - Downloading https://publish.djl.ai/pytorch/2.5.1/cu124/win-x86_64/native/lib/asmjit.dll.gz ...
2025-07-22 09:13:55,777 [main] INFO ai.djl.pytorch.jni.LibUtils - Downloading https://publish.djl.ai/pytorch/2.5.1/cu124/win-x86_64/native/lib/libiompstubs5md.dll.gz ...
2025-07-22 09:13:55,871 [main] DEBUG ai.djl.pytorch.jni.LibUtils - Loading native library: C:\Users\IDIES\.djl.ai\pytorch\2.5.1-cu124-win-x86_64\asmjit.dll
2025-07-22 09:13:55,887 [main] DEBUG ai.djl.pytorch.jni.LibUtils - Loading native library: C:\Users\IDIES\.djl.ai\pytorch\2.5.1-cu124-win-x86_64\c10.dll
2025-07-22 09:13:55,887 [main] DEBUG ai.djl.pytorch.jni.LibUtils - Loading native library: C:\Users\IDIES\.djl.ai\pytorch\2.5.1-cu124-win-x86_64\cublas64_12.dll
2025-07-22 09:13:56,093 [main] DEBUG ai.djl.pytorch.jni.LibUtils - Loading native library: C:\Users\IDIES\.djl.ai\pytorch\2.5.1-cu124-win-x86_64\cublasLt64_12.dll
2025-07-22 09:13:56,330 [main] DEBUG ai.djl.pytorch.jni.LibUtils - Loading native library: C:\Users\IDIES\.djl.ai\pytorch\2.5.1-cu124-win-x86_64\cudart64_12.dll
2025-07-22 09:13:56,334 [main] DEBUG ai.djl.pytorch.jni.LibUtils - Loading native library: C:\Users\IDIES\.djl.ai\pytorch\2.5.1-cu124-win-x86_64\cufft64_11.dll
2025-07-22 09:13:56,365 [main] DEBUG ai.djl.pytorch.jni.LibUtils - Loading native library: C:\Users\IDIES\.djl.ai\pytorch\2.5.1-cu124-win-x86_64\cufftw64_11.dll
2025-07-22 09:13:56,379 [main] DEBUG ai.djl.pytorch.jni.LibUtils - Loading native library: C:\Users\IDIES\.djl.ai\pytorch\2.5.1-cu124-win-x86_64\cupti64_2024.1.0.dll
2025-07-22 09:13:56,379 [main] DEBUG ai.djl.pytorch.jni.LibUtils - Loading native library: C:\Users\IDIES\.djl.ai\pytorch\2.5.1-cu124-win-x86_64\curand64_10.dll
2025-07-22 09:13:56,379 [main] DEBUG ai.djl.pytorch.jni.LibUtils - Loading native library: C:\Users\IDIES\.djl.ai\pytorch\2.5.1-cu124-win-x86_64\cusolver64_11.dll
2025-07-22 09:13:56,411 [main] DEBUG ai.djl.pytorch.jni.LibUtils - Loading native library: C:\Users\IDIES\.djl.ai\pytorch\2.5.1-cu124-win-x86_64\cusolverMg64_11.dll
2025-07-22 09:13:56,411 [main] DEBUG ai.djl.pytorch.jni.LibUtils - Loading native library: C:\Users\IDIES\.djl.ai\pytorch\2.5.1-cu124-win-x86_64\cusparse64_12.dll
2025-07-22 09:13:56,626 [main] DEBUG ai.djl.pytorch.jni.LibUtils - Loading native library: C:\Users\IDIES\.djl.ai\pytorch\2.5.1-cu124-win-x86_64\libiomp5md.dll
2025-07-22 09:13:56,626 [main] DEBUG ai.djl.pytorch.jni.LibUtils - Loading native library: C:\Users\IDIES\.djl.ai\pytorch\2.5.1-cu124-win-x86_64\libiompstubs5md.dll
2025-07-22 09:13:56,626 [main] DEBUG ai.djl.pytorch.jni.LibUtils - Loading native library: C:\Users\IDIES\.djl.ai\pytorch\2.5.1-cu124-win-x86_64\nvJitLink_120_0.dll
2025-07-22 09:13:56,646 [main] DEBUG ai.djl.pytorch.jni.LibUtils - Loading native library: C:\Users\IDIES\.djl.ai\pytorch\2.5.1-cu124-win-x86_64\nvrtc-builtins64_124.dll
2025-07-22 09:13:56,646 [main] DEBUG ai.djl.pytorch.jni.LibUtils - Loading native library: C:\Users\IDIES\.djl.ai\pytorch\2.5.1-cu124-win-x86_64\nvrtc64_120_0.dll
2025-07-22 09:13:56,662 [main] DEBUG ai.djl.pytorch.jni.LibUtils - Loading native library: C:\Users\IDIES\.djl.ai\pytorch\2.5.1-cu124-win-x86_64\nvToolsExt64_1.dll
2025-07-22 09:13:56,662 [main] DEBUG ai.djl.pytorch.jni.LibUtils - Loading native library: C:\Users\IDIES\.djl.ai\pytorch\2.5.1-cu124-win-x86_64\uv.dll
2025-07-22 09:13:56,662 [main] DEBUG ai.djl.pytorch.jni.LibUtils - Loading native library: C:\Users\IDIES\.djl.ai\pytorch\2.5.1-cu124-win-x86_64\zlibwapi.dll
2025-07-22 09:13:56,662 [main] DEBUG ai.djl.pytorch.jni.LibUtils - Loading native library: C:\Users\IDIES\.djl.ai\pytorch\2.5.1-cu124-win-x86_64\fbgemm.dll
2025-07-22 09:13:56,678 [main] DEBUG ai.djl.pytorch.jni.LibUtils - Loading native library: C:\Users\IDIES\.djl.ai\pytorch\2.5.1-cu124-win-x86_64\caffe2_nvrtc.dll
2025-07-22 09:13:56,685 [main] DEBUG ai.djl.pytorch.jni.LibUtils - Loading native library: C:\Users\IDIES\.djl.ai\pytorch\2.5.1-cu124-win-x86_64\torch_cpu.dll
2025-07-22 09:13:57,178 [main] DEBUG ai.djl.pytorch.jni.LibUtils - Loading native library: C:\Users\IDIES\.djl.ai\pytorch\2.5.1-cu124-win-x86_64\c10_cuda.dll
2025-07-22 09:13:57,183 [main] DEBUG ai.djl.pytorch.jni.LibUtils - Loading native library: C:\Users\IDIES\.djl.ai\pytorch\2.5.1-cu124-win-x86_64\torch_cuda.dll
Error occurred while getting engine instance: Failed to load PyTorch native library
ai.djl.engine.EngineException: Failed to load PyTorch native library
at ai.djl.pytorch.engine.PtEngine.newInstance(PtEngine.java:90)
at ai.djl.pytorch.engine.PtEngineProvider.getEngine(PtEngineProvider.java:41)
at ai.djl.engine.Engine.getEngine(Engine.java:190)
at ai.djl.engine.Engine.getInstance(Engine.java:145)
at test.App.main(App.java:15)
Caused by: java.lang.UnsatisfiedLinkError: C:\Users\IDIES\.djl.ai\pytorch\2.5.1-cu124-win-x86_64\torch_cuda.dll: Can't find dependent libraries
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1824)
at java.lang.Runtime.load0(Runtime.java:809)
at java.lang.System.load(System.java:1086)
at ai.djl.pytorch.jni.LibUtils.loadNativeLibrary(LibUtils.java:379)
at ai.djl.pytorch.jni.LibUtils.loadLibTorch(LibUtils.java:195)
at ai.djl.pytorch.jni.LibUtils.loadLibrary(LibUtils.java:82)
at ai.djl.pytorch.engine.PtEngine.newInstance(PtEngine.java:53)
... 4 more
```

## How to Reproduce?

This all runs on Java 8.

`App.java`
```java
package test;

import ai.djl.Device;
import ai.djl.engine.Engine;

/**
* Hello world!
*
*/
public class App
{
public static void main( String[] args )
{
try {
Engine engine = Engine.getInstance();
System.out.println("Using engine: " + engine.getEngineName());
Device[] devices = engine.getDevices();
for (Device device : devices) {
System.out.println("Device ID: " + device.getDeviceId() + ", Type: " + device.getDeviceType());
}
} catch (Exception e) {
System.err.println("Error occurred while getting engine instance: " + e.getMessage());
e.printStackTrace();
}
}
}
```

`pom.xml`
```xml

4.0.0
test
my-java-app
jar
1.0-SNAPSHOT
my-java-app
http://maven.apache.org


junit
junit
3.8.1
test


ai.djl
api
0.32.0


ai.djl.pytorch
pytorch-engine
0.32.0
runtime



ch.qos.reload4j
reload4j
1.2.26



org.slf4j
slf4j-reload4j
2.0.17
compile




org.apache.maven.plugins
maven-shade-plugin
3.6.0


generate-plugin-jar
package

shade




flfm_plugin
false
false



test.App







```

### Steps to reproduce
(Paste the commands you ran that produced the error.)

1. `mvn clean package`
2. `java.exe -jar .\target\flfm_plugin.jar`

## What have you tried to solve it?

1. I have tried different versions of CUDNN both 8 and 9

## Environment Info

```nvidia-smi```

```text
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 576.57 Driver Version: 576.57 CUDA Version: 12.9 |
|-----------------------------------------+------------------------+----------------------+
| GPU Name Driver-Model | Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|=========================================+========================+======================|
| 0 Quadro P4000 WDDM | 00000000:17:00.0 Off | N/A |
| 46% 34C P8 6W / 105W | 0MiB / 8192MiB | 0% Default |
| | | N/A |
+-----------------------------------------+------------------------+----------------------+
| 1 Quadro P4000 WDDM | 00000000:73:00.0 Off | N/A |
| 46% 30C P8 7W / 105W | 484MiB / 8192MiB | 3% Default |
| | | N/A |
+-----------------------------------------+------------------------+----------------------+
| 2 Quadro RTX 6000 WDDM | 00000000:D5:00.0 Off | Off |
| 33% 27C P8 17W / 260W | 0MiB / 24576MiB | 0% Default |
| | | N/A |
+-----------------------------------------+------------------------+----------------------+
```

java.exe -version
```text
java version "1.8.0_152"
Java(TM) SE Runtime Environment (build 1.8.0_152-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.152-b16, mixed mode)
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.