Tensorflow c++ API 失败设置 gpu/cpu 编号:SetDefaultDevice 错误:具有相同优
Tensorflow c++ api failed set gpu/cpu number: SetDefaultDevice error: Duplicate registration of device factory for type GPU with the same priority 210
我正在加载一个三角张量流模型并运行它。当我尝试设置 GPU 编号时,会引发错误。
F 张量流/核心/common_runtime/device_factory.cc:77] 复制 具有相同优先级 210 的 GPU 类型的设备工厂注册
我使用的代码是这样的:
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 编号。
我从源代码重建张量流并使用新的 libtensorflow_cc.so 和头文件。然后这个问题就消失了。
我认为这是由我的 libtensorflow_cc.so 和头文件不是同一版本引起的。
相关文章:
- 警告处理为错误这里有什么问题
- "error: no matching function for call to"构造函数错误
- boost::进程间消息队列引发错误
- C++,OpenCV,尝试显示图像时"OpenCV(4.3.0) Error: Assertion failed (size.width>0 && size.height>0)"此错误
- 有关插入适配器的错误。[错误]请求从 'back_insert_iterator<vector<>>' 类型转换为非标量类型
- QT在错误的班级中寻找空位
- vector.resize()中的分配错误
- 代码在main()中运行,但在函数中出现错误
- 释放错误后堆使用
- (C++)分析树以计算返回错误值的简单算术表达式
- Project Euler问题4的错误解决方案
- 我的字符计数代码计算错误.为什么
- 从"int*"强制转换为"unsigned int"会丢失精度错误
- 尝试导入pybind-opencv模块时出现libgtk错误
- CMake项目Boost库错误:Boost/config/compiler/gcc.hpp:165:10:致命错误:cs
- 在某些循环内使用vector.push_back时出现分段错误
- MSVC多行宏编译器错误
- 静态数据成员的问题-修复链接错误会导致编译器错误
- 为什么在运行时没有向我们提供有关分段错误的更多信息?
- 错误:未在此范围内声明'reverse'