問(wèn)題描述
我正在為 NIST FRVT 編寫(xiě)代碼.NIST 希望程序以最多 2 個(gè)線程運(yùn)行(只有 CPU,沒(méi)有 GPU).我在我的代碼中使用 TensorFlow,但它總是產(chǎn)生超過(guò) 2 個(gè)線程.我嘗試了這個(gè)解決方案.它減少了線程數(shù),但沒(méi)有達(dá)到 2
I am writing code for NIST FRVT. NIST wants the program to run at max 2 threads(Only CPU, No GPU). I am using TensorFlow in my code but it always spawns much more than 2 threads. I tried this solution. It decreased the number of threads, but not up to 2
我收到此警告
[警告] 我們檢測(cè)到您的軟件在模板創(chuàng)建期間可能正在線程化或使用其他多處理技術(shù).檢測(cè)到的線程數(shù)為 9,應(yīng)該為 2.根據(jù) API 文檔,實(shí)現(xiàn)必須運(yùn)行單線程.在測(cè)試環(huán)境中,線程沒(méi)有優(yōu)勢(shì),因?yàn)?NIST 會(huì)在多個(gè)刀片和多個(gè)進(jìn)程之間分配工作負(fù)載.我們強(qiáng)烈建議您在提交前解決此問(wèn)題.
[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 正在通過(guò) top -H -b -n1 | 計(jì)算線程數(shù)grep validate11 |wc -l
有沒(méi)有辦法強(qiáng)制 TensorFlow 使用最多 2 個(gè)線程?
Is there any way to force TensorFlow to use at max 2 threads?
是否有可以在 2 個(gè)線程上運(yùn)行的 TensorFlow 版本?
Is there any TensorFlow version that will run on 2 threads?
(這是因?yàn)門(mén)ensorFlow,我通過(guò)從代碼中刪除TensorFlow部分來(lái)檢查)
(It is because of TensorFlow, I checked by removing TensorFlow part from the code)
tensorflow 1.8.0 版
tensorflow version 1.8.0
opencv 3.4.1 版
opencv version 3.4.1
g++ 4.8.5 版
g++ version 4.8.5
g++ -std=c++11
g++ -std=c++11
推薦答案
參考以下來(lái)源,似乎無(wú)法在 1 或 2 個(gè)線程上運(yùn)行 TensorFlow.
With reference to the following sources, it looks like there is no possibility to run TensorFlow on 1 or 2 threads.
- https://github.com/tensorflow/tensorflow/issues/33627
- https://github.com/tensorflow/tensorflow/issues/42510
- https://github.com/theislab/batchglm/issues/27
- 使用腳本變量 OMP_NUM_THREADS在程序源文件中
- 使用 C 更改 Tensorflow 推理的線程數(shù)API
我提交了具有超過(guò) 6 個(gè)線程的 NIST-FRVT 實(shí)現(xiàn),NIST 接受了這一點(diǎn).6 個(gè)線程中只有 1 個(gè)在運(yùn)行,其余線程處于睡眠模式.
I submitted my implementation of NIST-FRVT having more than 6 threads, and NIST accepted that. Only 1 out of 6 threads were running and the rest of the threads were in sleeping mode.
這篇關(guān)于如何阻止 TensorFlow 使用多線程的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!