Potential memory leak in Isaac Gym

Creating and destroying a sim repeatedly in a loop causes a memory leak:

for i in range(10):
    sim = gym.create_sim(...)
    gym.destroy_sim(sim)

printing nvidia-smi shows a steady increase of GPU memory allocation.

is there a proper way of disposing the sim after each loop? this is useful if we need to run multiple experiments / trials with differing configurations

4 Likes

Interesting! it would also be useful when we need to retrain an agent several times.

Doing this, I inevitably ended up with a segmentation fault. Does this happen for you as well, e.g. if you increase the number of reinitialisations?

Otherwise, my issue could be related to the viewer, as key mappings would also get messed up on reinitialisation.

Eventually, I gave up and ran different configurations via an iteration of os.system calls to a script with different arguments. This could work for your case, as well.

see nvidia comment in this thread. :(

2 Likes

Same situation - I also ended up with a segmentation fault.

I was benchmarking the simulation performance with varying numbers of environments, and noticed the memory leak after calling gym.destroy_sim(sim). I also ended up just calling the same script multiple times with different arguments.

(I’m using Preview 4)