线上服务每次预测都新建session开销会过大吗
JenkinsY94 opened this issue · 3 comments
JenkinsY94 commented
tensorflow-predictor-cpp/src/simple_model.cc
这个文件中每次调用预测时都会初始化session,预测完成后close。如果作为线上服务,session只在最开始加载时初始化,预测的速度是否更快?
formath commented
As a service, session should be initialized only once.
JenkinsY94 commented
Thanks for your comment.
currently I initialize the session only when loading a new model.
But when it comes to update a new model, it seems that the old session would lead to memory leak because it is unreferenced anymore.(BTW I use the java API provided by TF)
Is there any good idea to avoid this?
formath commented
In C++, delete session pointer. In Java, have a garbage collection.