Closed shafeef901 closed 1 year ago
In the end, you have to tune them for the best results. Bigger the num_envs
, the higher FPS you will get. But too big num_envs
will eventually slow down the training in terms of performance vs training time. I also found the optimal num_threads
to be double the number of cores as well. This is proably due to hyperthreading but I am not sure.
Excuse me, I have a trivial question. If I have 8 core, , each capable of running 2 threads, I should set num_thread = 16 to maximize performance?
And this should mean that I can parallelize up to 16 environments. However, if I set num_envs=50, since it can only parallelize a maximum of 16 threads, it will launch the first 16 environments first, then the next 16, then the next, and finally the last 2. Is that correct?
I mean, it serialized the environment that cannot parallelize. I'm not entirely certain if I'm stating things correctly
"I should set num_thread = 16 to maximize performance?": This is often true but you have to tweak the number +-10% to get the best performance "And this should mean that I can parallelize up to 16 environments. However, if I set num_envs=50, since it can only parallelize a maximum of 16 threads, it will launch the first 16 environments first, then the next 16, then the next, and finally the last 2. Is that correct?": This is almost true. The only incorrect part is that the threads do not wait for each other. They don't work in a batch. If one thread finishes first, it will automatically grab the next job.
Thank you for the fast reply
What would be the optimal combination of the number of environments and the number of threads while using raisimGymTorch? My computer has 20 cores and I've tried num_envs=20 and num_threads=20. However, it's slower than using higher num_threads (30/40). Do you have any suggestions on this? FYI, I am using RaiSim for RL using torch and gym.