How can i set num_workers?

i have laptop with 1 gpu , should i set num_workers= 4 as the equation i found that
num_workers=4*num_GPU ?

It really just depends on how much CPU time it takes to load data to keep the GPU busy so ultimately it depends on your particular dataset, preprocessing steps, and the relative speed of CPU and GPU in your setup. A simple way to set num_workers is to keep increasing it until your GPU utilization (e.g., in nvidia-smi) no longer increases.

How can I get it from Nvidia-smi ?
Screenshot from 2021-06-12 21-59-05
do you mean that ? i set it 4

Yes, if the GPU-util is not increasing, you don’t need to keep increasing the number of workers. You just want enough workers to keep the GPU busy.

1 Like

you mean if GPU-util is 50% i can increase number of workers ? and if it 99 i should decrease number of worker ?

If it is 99 you can try decreasing the number of workers but you don’t really need to do anything (the ideal is using the fewest number of workers to get the maximum utilization time). You can also use time.time() to track statistics like how long an epoch takes and tune how many workers you are using based off of that.

1 Like

More thanks for your time and replying