問題描述
我正在為 NIST FRVT 編寫代碼.NIST 希望程序以最多 2 個線程運行(只有 CPU,沒有 GPU).我在我的代碼中使用 TensorFlow,但它總是產生超過 2 個線程.我嘗試了這個解決方案.它減少了線程數,但沒有達到 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
我收到此警告
[警告] 我們檢測到您的軟件在模板創建期間可能正在線程化或使用其他多處理技術.檢測到的線程數為 9,應該為 2.根據 API 文檔,實現必須運行單線程.在測試環境中,線程沒有優勢,因為 NIST 會在多個刀片和多個進程之間分配工作負載.我們強烈建議您在提交前解決此問題.
[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 validate11 |wc -l
有沒有辦法強制 TensorFlow 使用最多 2 個線程?
Is there any way to force TensorFlow to use at max 2 threads?
是否有可以在 2 個線程上運行的 TensorFlow 版本?
Is there any TensorFlow version that will run on 2 threads?
(這是因為TensorFlow,我通過從代碼中刪除TensorFlow部分來檢查)
(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
推薦答案
參考以下來源,似乎無法在 1 或 2 個線程上運行 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 推理的線程數API
我提交了具有超過 6 個線程的 NIST-FRVT 實現,NIST 接受了這一點.6 個線程中只有 1 個在運行,其余線程處于睡眠模式.
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.
這篇關于如何阻止 TensorFlow 使用多線程的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!