【问题标题】:Tensorflow c++ api failed set gpu/cpu number: SetDefaultDevice error: Duplicate registration of device factory for type GPU with the same priority 210Tensorflow c++ api failed set gpu/cpu number: SetDefaultDevice error: Duplicate registration of device factory for type GPU with the same priority 210
【发布时间】:2018-03-29 14:10:34
【问题描述】:

我正在加载一个 Trianed TensorFlow 模型并运行它。当我尝试设置 gpu 编号时,出现错误。

F tensorflow/core/common_runtime/device_factory.cc:77] 重复 为具有相同优先级的 GPU 类型注册设备工厂 210

我使用的代码是这样的:

tensorflow::GraphDef graph_def;
tensorflow::Status graphLoadedStatus = ReadBinaryProto(tensorflow::Env::Default(),model_path, &graph_def);
if (!graphLoadedStatus.ok()) {
    std::cerr <<"Model path : " << graphLoadedStatus.ToString() << std::endl;
    return graphLoadedStatus;
}

// set device to be on gpu
tensorflow::graph::SetDefaultDevice("/gpu:3", &graph_def);

谷歌一下,除了tensoeflow的源代码没有结果:https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/common_runtime/device_factory.cc

有人遇到过吗?或者tf的贡献者能给我一些线索吗?

好像是优先级的问题,所以我尝试用root运行,但是没有用。

顺便说一句,我正在使用 C++。如果我使用python,我可以正确设置gpu编号。

【问题讨论】:

    标签: c++ tensorflow


    【解决方案1】:

    我从源代码重建 tensorflow 并使用新的 libtensorflow_cc.so 和头文件。然后这个问题就消失了。

    我认为这是由于我的 libtensorflow_cc.so 和头文件版本不同造成的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-03-30
      • 2021-12-20
      • 1970-01-01
      • 2018-11-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多