CrossQ icon indicating copy to clipboard operation
CrossQ copied to clipboard

Fix JAX allocating too much memory and remove unnecessary import.

Open JankowskiChristopher opened this issue 10 months ago • 0 comments

Hello, Setting the flag:

os.environ['XLA_PYTHON_CLIENT_PREALLOCATE'] = 'false'

did not correctly impact JAX, as it was done after the import. Therefore JAX allocated ~80% of memory of the GPU. When I moved this line of code to the beginning the usage of memory dropped to ~15% (Tested on Nvidia Titan V, HalfCheetah-v4 environment).

Also the import:

from stable_baselines3.common.callbacks import EvalCallback,

Is not used as EvalCallback is imported from sbx.sac.actor_critic_evaluation_callback. It is safer to delete this unnecessary import as it can clash with the other and also some programs e.g. isort when sorting the imports change the order and EvalCallback is then imported from stable_baselines3 instead of sbx.sac.actor_critic_evaluation_callback (that happened in my case when I sorted the imports.)

JankowskiChristopher avatar Apr 08 '24 22:04 JankowskiChristopher