multithreading

Keras/TF CPU creating too many threads

孤街醉人 提交于 2021-01-01 04:29:21
问题 Even after setting tf.config.threading.set_inter_op_parallelism_threads(1) and tf.config.threading.set_intra_op_parallelism_threads(1) Keras with Tensorflow CPU (running a simple CNN model fit) on a linux machine is creating too many threads. Whatever I try it seems to be creating 94 threads while going through the fitting epochs. Have tried playing with tf.compat.v1.ConfigProto settings but nothing helps. How do I limit the number of threads? 回答1: This is why tensorflow created many threads.

Keras/TF CPU creating too many threads

﹥>﹥吖頭↗ 提交于 2021-01-01 04:21:55
问题 Even after setting tf.config.threading.set_inter_op_parallelism_threads(1) and tf.config.threading.set_intra_op_parallelism_threads(1) Keras with Tensorflow CPU (running a simple CNN model fit) on a linux machine is creating too many threads. Whatever I try it seems to be creating 94 threads while going through the fitting epochs. Have tried playing with tf.compat.v1.ConfigProto settings but nothing helps. How do I limit the number of threads? 回答1: This is why tensorflow created many threads.

QThread will not exit

牧云@^-^@ 提交于 2020-12-31 05:53:25
问题 When I close my application, the thread is still running even though it should have ended. The following code will simply hang on the workerThread->wait(); line. Main Thread #include "mainwindow.h" #include "ui_mainwindow.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); workerThread = new QThread(); worker = new Worker(); worker->moveToThread(workerThread); connect(this, SIGNAL(ThreadStopSignal()), worker, SLOT(ThreadStopSlot()));

QThread will not exit

廉价感情. 提交于 2020-12-31 05:53:11
问题 When I close my application, the thread is still running even though it should have ended. The following code will simply hang on the workerThread->wait(); line. Main Thread #include "mainwindow.h" #include "ui_mainwindow.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); workerThread = new QThread(); worker = new Worker(); worker->moveToThread(workerThread); connect(this, SIGNAL(ThreadStopSignal()), worker, SLOT(ThreadStopSlot()));

QThread will not exit

旧城冷巷雨未停 提交于 2020-12-31 05:52:12
问题 When I close my application, the thread is still running even though it should have ended. The following code will simply hang on the workerThread->wait(); line. Main Thread #include "mainwindow.h" #include "ui_mainwindow.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); workerThread = new QThread(); worker = new Worker(); worker->moveToThread(workerThread); connect(this, SIGNAL(ThreadStopSignal()), worker, SLOT(ThreadStopSlot()));

Why is the python thread count 2 at the beginning?

拈花ヽ惹草 提交于 2020-12-30 09:41:26
问题 import threading print threading.activeCount() output: 2 When this code is saved into a file and run. How could it be 2 when it's the main thread? Does python run another thread by default in addition to the main thread when we run a foo.py file? 回答1: Psychic debugging: You're not running in a plain Python interpreter. The plain Python interpreter doesn't launch extra threads (unless you have a weird PYTHONSTARTUP file), but other interpreters would. For example: ipython launches an extra

Why is the python thread count 2 at the beginning?

别来无恙 提交于 2020-12-30 09:38:17
问题 import threading print threading.activeCount() output: 2 When this code is saved into a file and run. How could it be 2 when it's the main thread? Does python run another thread by default in addition to the main thread when we run a foo.py file? 回答1: Psychic debugging: You're not running in a plain Python interpreter. The plain Python interpreter doesn't launch extra threads (unless you have a weird PYTHONSTARTUP file), but other interpreters would. For example: ipython launches an extra

Why sometimes Task is significantly slower than Thread?

无人久伴 提交于 2020-12-29 19:46:20
问题 I'm making a WPF application using MVVM pattern. I found sometimes Task is significantly slower than Thread. For example, in a test ViewModel: public void DoSomething() { Stopwatch stopwatch = Stopwatch.StartNew(); new Thread(() => { Debug.Print(string.Format("Elapsed: {0}", stopwatch.ElapsedMilliseconds)); }).Start(); } The output usually is Elapsed: 0 . It cost 0 millisecond. But if I replace Thread with Task . It could cost 5000~15000 milliseconds. I tried to reproduce this in another WPF

Why sometimes Task is significantly slower than Thread?

╄→гoц情女王★ 提交于 2020-12-29 19:38:32
问题 I'm making a WPF application using MVVM pattern. I found sometimes Task is significantly slower than Thread. For example, in a test ViewModel: public void DoSomething() { Stopwatch stopwatch = Stopwatch.StartNew(); new Thread(() => { Debug.Print(string.Format("Elapsed: {0}", stopwatch.ElapsedMilliseconds)); }).Start(); } The output usually is Elapsed: 0 . It cost 0 millisecond. But if I replace Thread with Task . It could cost 5000~15000 milliseconds. I tried to reproduce this in another WPF

Why sometimes Task is significantly slower than Thread?

十年热恋 提交于 2020-12-29 19:35:12
问题 I'm making a WPF application using MVVM pattern. I found sometimes Task is significantly slower than Thread. For example, in a test ViewModel: public void DoSomething() { Stopwatch stopwatch = Stopwatch.StartNew(); new Thread(() => { Debug.Print(string.Format("Elapsed: {0}", stopwatch.ElapsedMilliseconds)); }).Start(); } The output usually is Elapsed: 0 . It cost 0 millisecond. But if I replace Thread with Task . It could cost 5000~15000 milliseconds. I tried to reproduce this in another WPF