简体   繁体   中英

Cheap Multi-Threading Trick in Python

I have an ANN (artificial neural network) that I have to train with many parameters in python. I heard of a cheap/ quick way to "multi_thread" in python. I realize this isn't the cleanest way to do this (there are libraries dedicated to this, but It's to quickly test and develop networks). However, I wanted to check the validity of this trick with Stack Overflow

I open 4 CMDs (I have a 4 core processor) and run the same program on each of the CMDs as python my_program.py param1 param2 . The only difference is that in each of the CMDs, I change the parameters so they are training differently. They then save their trained networks to the disk.

Is this method of opening 4 CMDs really using the 4 cores I have on my computer and in a sense Multi-Threading?

It should work as you think, and is a perfectly valid way of making full use of a multi-core machine.

Assuming the mention of "CMD"s means you're on Windows: check the Windows Task Manager's view of CPU usage. It should show all 4 cores fully in use when you have 4 processes running, assuming those processes are compute bound (rather than waiting on disk or network IO).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM