Closed endlesshh closed 3 years ago
This is expected behavior.
The NDList created in Translator will be destroyed right after the .predict(). We usually don't recommend to return NDList from translator, because you need explicitly close the NDList after you finished using it.
You have a few options here:
NDList.detach()
function before you return it. But you must make sure you close the NDList manually, otherwise, you will cause memory leak.I got it ,Thanks a lot
Description
I use the first-order-model to predict,they have tow models kp_detector and generator, fisrt I user have save the model named kp_detector.pt , when i load the file and predict,it return the error. (use PyTorch as default_engine,just cup not cudart)
Expected Behavior
renturn the jacobian
Error Message
Exception in thread "main" java.lang.IllegalStateException: Native resource has been release already. at ai.djl.util.NativeResource.getHandle(NativeResource.java:51) at ai.djl.pytorch.jni.JniUtils.getShape(JniUtils.java:1318) at ai.djl.pytorch.engine.PtNDArray.getShape(PtNDArray.java:131) at ai.djl.ndarray.NDList.toString(NDList.java:284) at java.lang.String.valueOf(String.java:2994) at java.io.PrintStream.println(PrintStream.java:821)
How to Reproduce?
Translator<Image, NDList>
Environment Info
DJL 0.11.0 version