SavedModelBundle memory leak
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Java
- Star
- 928
- Fork
- 227
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
System information
- Have I written custom code (as opposed to using a stock example script provided in TensorFlow): Yes
- OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Linux Ubuntu 18.04.5 LTS
- TensorFlow installed from (source or binary): Included in java artifact
- TensorFlow version: 2.4.1
Describe the current behavior
Loading and closing SavedModelBundle in an infinite loop leads to OutOfMemoryError:
Exception in thread "main" java.lang.OutOfMemoryError: Physical memory usage is too high: physicalBytes (7828M) > maxPhysicalBytes (7828M)
at org.bytedeco.javacpp.Pointer.deallocator(Pointer.java:695)
at org.tensorflow.internal.c_api.AbstractTF_Status.newStatus(AbstractTF_Status.java:70)
at org.tensorflow.SavedModelBundle.load(SavedModelBundle.java:401)
at org.tensorflow.SavedModelBundle.access$000(SavedModelBundle.java:59)
at org.tensorflow.SavedModelBundle$Loader.load(SavedModelBundle.java:68)
at org.tensorflow.SavedModelBundle.load(SavedModelBundle.java:242)
at com.mycompany.app.App.main(App.java:13)
I use 0.3.1 version of the library. It is the only dependency:
<dependency>
<groupId>org.tensorflow</groupId>
<artifactId>tensorflow-core-platform</artifactId>
<version>0.3.1</version>
</dependency>
The memory leak is reproducible with a model from this repository:
https://github.com/tensorflow/java/tree/master/tensorflow-core/tensorflow-core-api/src/test/resources/saved_model
Describe the expected behavior
I assume that the following code should run endlessly
Code to reproduce the issue
package com.mycompany.app;
import org.tensorflow.SavedModelBundle;
import java.net.URISyntaxException;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) throws URISyntaxException {
var modelPath = Paths.get(App.class.getResource("/saved_model").toURI()).toString();
while (true) {
var model = SavedModelBundle.load(modelPath, "serve");
model.close();
}
}
}
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu với việc tái hiện trong App.main, tập trung vào các lời gọi lặp lại tới SavedModelBundle.load(modelPath, "serve") và model.close(), đồng thời sử dụng tài nguyên saved_model được nêu trong issue. Xác nhận rằng bộ nhớ tiếp tục tăng qua các lần lặp và rằng đường dẫn tải và đóng có thể hoàn tất lặp đi lặp lại mà không gây ra OutOfMemoryError.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- java, tensorflow
- Lĩnh vực
- machine-learning
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 28/100