# Memory leak with PPO and GNN custom model

**URL:** <https://discuss.ray.io/t/memory-leak-with-ppo-and-gnn-custom-model/3537>\
**Category:** RLlib\
**Created:** [September 15, 2021, 9:54pm UTC](https://discuss.ray.io/t/memory-leak-with-ppo-and-gnn-custom-model/3537 "2021-09-15T21:54:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![TheExGenesis](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/theexgenesis/32/1502_2.png) [@TheExGenesis](https://discuss.ray.io/u/TheExGenesis)\
**Post date:** [September 15, 2021, 9:54pm UTC](https://discuss.ray.io/t/memory-leak-with-ppo-and-gnn-custom-model/3537/1 "2021-09-15T21:54:07Z")

</div>

Hi, it’s the title says.

My environment is pretty fast and light. But when it comes to training, I run `trainer.train()` once - it takes 5m and it barely makes it, I run it again and the whole thing crashes.

I tested the model in a supervised training loop and it didn’t leak memory. It’s not the environment because I was generating data directly from it.  
I tested the same code with a dummy model and it still crashed, so I’m convinced it’s something about RLLIB’s training loop.

I wonder if there’s a way to debug memory usage by Object. `ray memory` shows 0B use, I assume because I’m in local mode, and [ray dashboard is unusable](https://discuss.ray.io/t/dashboard-2-0-unusable/3530).

Here is the code with no local dependencies, should reproduce.

> <https://gist.github.com/TheExGenesis/d95e5939da5f70bdc037b4d504f89959>

Here’s the error trace when it finally crashes:

> <https://gist.github.com/TheExGenesis/9c09a94b3f8814578ae8980af9e33a3c>

Finally, rllib doesn’t seem to detect my gpu, even though `cuda.is_available() == True`.

---

<div class="post-metadata">

**Author:** ![mannyv](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/mannyv/32/606_2.png) [@mannyv](https://discuss.ray.io/u/mannyv)\
**Post date:** [September 16, 2021, 2:51pm UTC](https://discuss.ray.io/t/memory-leak-with-ppo-and-gnn-custom-model/3537/2 "2021-09-16T14:51:34Z")

</div>

Hi @TheExGenesis,

Perhaps this will be available to you.  
[https://docs.ray.io/en/latest/rllib-dev.html?highlight=memory#finding-memory-leaks-in-workers](https://docs.ray.io/en/latest/rllib-dev.html?highlight=memory#finding-memory-leaks-in-workers)

---

<div class="post-metadata">

**Author:** ![TheExGenesis](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/theexgenesis/32/1502_2.png) [@TheExGenesis](https://discuss.ray.io/u/TheExGenesis)\
**Post date:** [September 17, 2021, 11:07am UTC](https://discuss.ray.io/t/memory-leak-with-ppo-and-gnn-custom-model/3537/3 "2021-09-17T11:07:12Z")

</div>

I solved my problem. I was using default hyperparameters and they were too much. It worked fine using these:

```auto
"rollout_fragment_length": 10,
"train_batch_size": 100,
"sgd_minibatch_size": 10,
 "num_sgd_iter": 3,

```
