【发布时间】:2019-10-31 10:39:43
【问题描述】:
我正在尝试使用 cpp tflite API 来查询开发板上的模型。该代码已使用 USB 棒进行了测试,并且可以正常工作,但是,在开发板上,我在此行出现错误:
model_interpreter_ = coral::BuildEdgeTpuInterpreter(*model_, this->edgetpu_context_.get());
这是错误:
INFO: Initialized TensorFlow Lite runtime.
ERROR: Failed to retrieve TPU context.
ERROR: Node number 0 (edgetpu-custom-op) failed to prepare.
使用 python API 可以正常工作。
开发板上是否支持 tflite cpp API?
在开发板上我有最新版本(12-1) 这就是我为构建 tflite lib 所做的:
在本地为 arm64 构建 tflite(使用构建通用脚本,不像 here 描述的那样)我使用了分支 v.2.0。 *原因是开发板上缺少虚拟内存和磁盘空间。
在开发板上安装了 flatbuffer。
编辑: 我能够从开发板上的 tensorflow 分支 v2.0 构建 tflite,更新为链接到本地构建的 lib ,仍然得到相同的错误......
编辑 2: 我能够使用 tflite 编译形式 tf-r1.15 重现相同的行为。我还尝试按照@Nam Vu 的建议添加可用 tpus 数量的打印。所以这里是一个代码sn-p:
cout << "check num available tpus\n";
cout << available_tpus.size() << "\n";
cout << "get edge session\n";
this->edgetpu_context_ = edgetpu::EdgeTpuManager::GetSingleton()->OpenDevice();
cout << "check num available tpus again:\n";
cout << available_tpus.size() << "\n";
cout << "get model buffer\n";
this->model_ = tflite::FlatBufferModel::BuildFromFile(model_path.c_str());
cout << "build model interpeter\n";
this->model_interpreter_ = coral::BuildEdgeTpuInterpreter(*model_, this->edgetpu_context_.get());
导致:
Hello
check num available tpus
3689348814741910324
get edge session
check num available tpus again:
3689348814741910324
get model buffer
build model interpeter
Segmentation fault
【问题讨论】:
标签: tensorflow tensorflow-lite tpu google-coral