c++ - 如何阻止 TensorFlow 多线程

标签 c++ multithreading tensorflow c++11

我正在为 NIST FRVT 编写代码。 NIST 希望程序最多运行 2 个线程(只有 CPU,没有 GPU)。 我在我的代码中使用了 TensorFlow,但它总是产生 2 个以上的线程。 I tried this solution. It decreased the number of threads, but not up to 2

我收到这个警告

[WARNING] We've detected that your software may be threading or using other multiprocessing techniques during template creation. The number of threads detected was 9 and it should be 2. Per the API document, implementations must run single-threaded. In the test environment, there is no advantage to threading, because NIST will distribute workload across multiple blades and multiple processes. We highly recommend that you fix this issue prior to submission.

NIST 通过 top -H -b -n1 | 计算线程grep 验证 11 | wc -l

有没有办法强制 TensorFlow 使用最多 2 个线程?

是否有可以在 2 个线程上运行的 TensorFlow 版本?

(因为是TensorFlow,我通过去掉TensorFlow的部分代码来检查)

tensorflow 版本 1.8.0

opencv 版本 3.4.1

g++ 版本 4.8.5

g++ -std=c++11

最佳答案

引用以下资料,似乎不可能在 1 或 2 个线程上运行 TensorFlow。

我提交了具有 6 个以上线程的 NIST-FRVT 实现,NIST 接受了。 6 个线程中只有 1 个在运行,其余线程处于 sleep 模式。

关于c++ - 如何阻止 TensorFlow 多线程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60206113/

相关文章:

c++ - 使用 boost.python 构建 Python 扩展时出错

c++ - 我应该创建多少个线程?

python - 使用 np.tensordot 的矩阵的 Khatri 乘积

python - R 的 Keras 和 Python 的 Keras 之间的差异——准确性错误?

c++ - 如何在不同内核之间正确共享运行时创建的多态数据?嵌入式C++

c++ - 在 OpenGL 中以固定速度沿贝塞尔曲线移动对象

c# - 我可以同时以一种以上的语言使用 OpenGL 吗?

java - Swing 多线程。我的 GUI 卡住了

Python如何停止线程操作

python - tensorflow 中没有完全连接的层