deepjavalibrary / djl

An Engine-Agnostic Deep Learning Framework in Java
https://djl.ai
Apache License 2.0
4.13k stars 656 forks source link

PtNDArray memory leak,ai.djl.pytorch.jni.PyTorchLibrary#torchIndexInit don't have matching method to delete index #2283

Closed HuLaLaGa closed 1 year ago

HuLaLaGa commented 1 year ago

Description

PtNDArray.get(NDArray index)和PtNDArray.set(NDIndex index, NDArray value) cause memory leak

Expected Behavior

(what's the expected behavior?)

Error Message

memory leak

How to Reproduce?

try (final NDManager ndManager = NDManager.newBaseManager()) { while (true) { try (NDManager manager = ndManager.newSubManager()) { NDArray a = manager.create(new int[1024 1024 1]); final NDArray eq = a.eq(1); a.get(eq); } } }

Steps to reproduce

(Paste the commands you ran that produced the error.)

What have you tried to solve it?

  1. add a method to delete index memory which created by method ai.djl.pytorch.jni.PyTorchLibrary#torchIndexInit

Environment Info

Please run the command ./gradlew debugEnv from the root directory of DJL (if necessary, clone DJL first). It will output information about your system, environment, and installation that can help us debug your issue. Paste the output of the command below:

PASTE OUTPUT HERE
frankfliu commented 1 year ago

This is duplicate of: #2281