# The flag of javacpp not work

**URL:** <https://community.konduit.ai/t/the-flag-of-javacpp-not-work/2037>\
**Category:** SameDiff\
**Created:** [September 30, 2022, 1:00am UTC](https://community.konduit.ai/t/the-flag-of-javacpp-not-work/2037 "2022-09-30T01:00:42Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![SidneyLann](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/sidneylann/32/367_2.png) [@SidneyLann](https://community.konduit.ai/u/SidneyLann)\
**Post date:** [September 30, 2022, 1:00am UTC](https://community.konduit.ai/t/the-flag-of-javacpp-not-work/2037/1 "2022-09-30T01:00:42Z")

</div>

-Dorg.bytedeco.javacpp.maxbytes=11024m -Dorg.bytedeco.javacpp.maxphysicalbytes=11024m

 ![image](https://canada1.discourse-cdn.com/flex035/uploads/konduit/original/1X/24477dd9b05233ee57e8ebeebe57b6011b566702.png)  
 ![image](https://canada1.discourse-cdn.com/flex035/uploads/konduit/original/1X/b44c6a72e7b297e0a157d83cc3e2083c088e01f3.png)

The memory of gpu not release or the setting not work?

---

<div class="post-metadata">

**Author:** ![agibsonccc](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/agibsonccc/32/697_2.png) [@agibsonccc](https://community.konduit.ai/u/agibsonccc)\
**Post date:** [September 30, 2022, 3:37am UTC](https://community.konduit.ai/t/the-flag-of-javacpp-not-work/2037/2 "2022-09-30T03:37:51Z")

</div>

@SidneyLann set the GC interval using: Nd4j.getMemoryManager().setOccasionalGcFrequency(50000);

or call System.gc() in places where memory runs high. One place I would recommend is right after the model is loaded.

---

<div class="post-metadata">

**Author:** ![SidneyLann](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/sidneylann/32/367_2.png) [@SidneyLann](https://community.konduit.ai/u/SidneyLann)\
**Post date:** [September 30, 2022, 6:03am UTC](https://community.konduit.ai/t/the-flag-of-javacpp-not-work/2037/3 "2022-09-30T06:03:35Z")

</div>

No help, still consume all gpu RAM and shutdown the pc after 50~70 epochs.

---

<div class="post-metadata">

**Author:** ![agibsonccc](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/agibsonccc/32/697_2.png) [@agibsonccc](https://community.konduit.ai/u/agibsonccc)\
**Post date:** [September 30, 2022, 6:10am UTC](https://community.konduit.ai/t/the-flag-of-javacpp-not-work/2037/4 "2022-09-30T06:10:55Z")

</div>

@SidneyLann what GPU are you trying to run on? At some point your GPU just can’t handle the workload and you need to shrink your batch size or something.

---

<div class="post-metadata">

**Author:** ![SidneyLann](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/sidneylann/32/367_2.png) [@SidneyLann](https://community.konduit.ai/u/SidneyLann)\
**Post date:** [September 30, 2022, 7:02am UTC](https://community.konduit.ai/t/the-flag-of-javacpp-not-work/2037/5 "2022-09-30T07:02:10Z")

</div>

Using i3080. May not related to batch size, because it can be trained 50+ epochs. After 20+ epochs, still remains 5G gpu RAM. gpu RAM may not be released or cache is used.

---

<div class="post-metadata">

**Author:** ![agibsonccc](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/agibsonccc/32/697_2.png) [@agibsonccc](https://community.konduit.ai/u/agibsonccc)\
**Post date:** [September 30, 2022, 7:16am UTC](https://community.konduit.ai/t/the-flag-of-javacpp-not-work/2037/6 "2022-09-30T07:16:16Z")

</div>

@SidneyLann are you running with the latest snapshots or M2.1? Recently I changed the cache up to address another issue and I wonder if that might help the situation a bit. Could you clarify a bit more about the scenario? Please don’t make me guess.

I need to know exactly when it runs out of memory, what does/doesn’t work and what you’ve tested so far. I would also like to know if you’re measuring anything at all.

---

<div class="post-metadata">

**Author:** ![SidneyLann](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/sidneylann/32/367_2.png) [@SidneyLann](https://community.konduit.ai/u/SidneyLann)\
**Post date:** [September 30, 2022, 8:26am UTC](https://community.konduit.ai/t/the-flag-of-javacpp-not-work/2037/7 "2022-09-30T08:26:08Z")

</div>

Using M2.1, SNAPSHOT can’t run, because Cannot invoke “java.lang.Class.newInstance()” because “memoryManagerClazz” is null.

It can run more than 50+ epochs, so It’s hard to tell what happen.
