Number of CPU cores as argument
lucgeo opened this issue · 4 comments
Hello,
I noticed that "run_example.sh" uses all the cores of the machine. I looked through the code, but it doesn't seem very obvious to me how I could give as a parameter the maximum number of cores that will be used for "VBx/predict.py" and "VBx/vbhmm.py".
I'm interested in this to evaluate the processing time related to the available hardware resources.
So, is there a way to set the number of CPUs that will be used?
Thanks!
Hello,
I believe the code runs both predict.py and vbhmm.py on single cores when you run in CPU. But, to enforce the code to run on a specific core, you could try something like taskset --cpu-list 0 ./run_example.sh
I hope this helps but let me know if I did not understand the question properly.
Hi,
Thanks for your answer! Yes, your solution helps, that's what I'm looking for. But I was hoping that I can do that directly from the source code.
In "htop" it looks like all the cores are busy when I run on CPU only.
I actually tried looking at htop before answering and I could see that only one CPU was used. If I did not run it with taskset, then, if the job lasted long enough, it would be moved around (which is expected as the OS tries to utilize the CPUs evenly).
Perhaps, you have other tasks running that consume a significant amount of CPU and that is why you see many cores been utilized? I tried it out without running other heavy tasks and observed a single core with ~100% utilization (the one running the example).
I understand that it would be convenient to have something in the code to limit the number of cores but it is not our priority so I am afraid I will not be able to implement that. However, if you want to work on that, feel free to create a pull request, it might be useful for other users as well :)
I am closing the issue but feel free to reopen if necessary.