java tensorflow and maven version is org.tensorflow:libtensorflow:1.15.0 after session.runner.run() for many times, the memory grow higher and higher then oom
未关闭
还没有人认领这个 Issue。
- 主要语言
- Java
- 星标
- 928
- 派生
- 227
- PR 合并指标
- 30 天内没有已合并 PR
描述
my test code with language scala ,this is one predict, we will predict 100 QPS for a docker
val config = ConfigProto.newBuilder
.putDeviceCount("CPU", Runtime.getRuntime.availableProcessors)
.setInterOpParallelismThreads(8)
.setIntraOpParallelismThreads(8)
.setOperationTimeoutInMs(3000)
.build
val options = RunOptions.newBuilder
.setTimeoutInMs(5000)
.build
val modelBundle = SavedModelBundle
.loader(s"$path")
.withTags("serve")
.withConfigProto(config.toByteArray)
.withRunOptions(options.toByteArray)
.load
val kernel = modelBundle.session
val data = Map("tensor1" -> Seq(0.1f,0.122f),……)
val runner = kernel.runner()
val inputTensorList: util.ArrayList[Tensor[java.lang.Float]] = new util.ArrayList[Tensor[java.lang.Float]]()
data.map{
case (tensorName, featureId) => {
val dataInput:FloatBuffer = FloatBuffer.allocate(featureId.size)
featureId.foreach(featureValue => {
dataInput.put(featureValue)
})
dataInput.asInstanceOf[Buffer].flip()
val tensorShape:Array[Long] = Array(1,featureId.size)
val tensor = Tensor.create(tensorShape,dataInput)
runner.feed(tensorName,tensor)
inputTensorList.add(tensor)
}
}
for(i <- 0 until 2 ){
runner.fetch("StatefulPartitionedCall",i)
}
val output = runner.run.asScala
val scores:Array[Float] = output.map(ten => {
val tensorData: Array[Array[Float]] = ten.copyTo(Array.ofDim[Float](ten.shape()(0).toInt, ten.shape()(1).toInt))
tensorData(0).head
}).toArray
inputTensorList.asScala.foreach(_.close())
output.foreach(_.close())
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先,使用 SavedModelBundle、session.runner()、runner.run() 以及 issue 中所示的重复 100-QPS 预测模式,重现报告的工作负载。在监控内存的同时,跟踪传入输入张量和返回输出张量的所有权及关闭情况;当重复预测不再使内存持续增长直至 OOM 时,即视为完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- java, tensorflow
- 领域
- machine-learning
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 需要澄清
- 新手友好度
- 25/100