SimonW:




 HMEIatJHU:

What is the best practice for setting OMP_NUM_THREADS? # physical cores or logical cores? or neither?


I usually try with different values between those two numbers. But I am not really an expert…


I tried many options and found smaller values tend to give good performance in my case.



 SimonW:




 HMEIatJHU:

Where is the best place to set it? I have two options:
2.1) set env vars OMP_NUM_THREADS when submitting jobs to cluster
2.2) set via torch.set_num_threads()
Not sure which way is better and why. Can you


Use torch.set_num_threads. PyTorch uses OMP, MKL, and a native thread pool (as well as TBB maybe). The function takes care of all of them. Not sure if the env flag will set all of them.


Thanks for the advice!