# Constrain memory consumption durning compilation in brian2cuda

**URL:** <https://brian.discourse.group/t/constrain-memory-consumption-durning-compilation-in-brian2cuda/798>\
**Category:** Support\
**Tags:** brian2cuda\
**Created:** [5 October 2022 19:38 UTC](https://brian.discourse.group/t/constrain-memory-consumption-durning-compilation-in-brian2cuda/798 "2022-10-05T19:38:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![DavidKing2020](https://avatars.discourse-cdn.com/v4/letter/d/e0b2c6/32.png) [@DavidKing2020](https://brian.discourse.group/u/DavidKing2020)\
**Post date:** [5 October 2022 19:38 UTC](https://brian.discourse.group/t/constrain-memory-consumption-durning-compilation-in-brian2cuda/798/1 "2022-10-05T19:38:11Z")

</div>

My code compile and runs well in cpp\_standalone mode. When running in brian2cuda, it somehow consumed all the memory (25GB) during cuda compilation. The job was run in jupyter notebook and the  
the kernel restarted because of the memory exhaustion. Is it possible to manually constraint the number of process used for cuda compilation? Attached please find a screenshot showing this issue.

 ![image](https://global.discourse-cdn.com/free1/uploads/brian/original/1X/9706a19b98dfc700e4517826947e2c0b504b6911.png)

---

<div class="post-metadata">

**Author:** ![mstimberg](https://yyz2.discourse-cdn.com/free1/user_avatar/brian.discourse.group/mstimberg/32/11_2.png) [@mstimberg](https://brian.discourse.group/u/mstimberg)\
**Post date:** [6 October 2022 08:49 UTC](https://brian.discourse.group/t/constrain-memory-consumption-durning-compilation-in-brian2cuda/798/2 "2022-10-06T08:49:05Z")

</div>

Uh, this looks indeed bad. Is it a model with a very large number of objects and/or runs?  
Either way, the make command uses `-j` for maximal parallelization by default. You can reduce the number by specifying a number of processes in the `devices.cpp_standalaone.extra_make_args_unix` preference:

```python
prefs['devices.cpp_standalone.extra_make_args_unix'] = ['-j8']

```

---

<div class="post-metadata">

**Author:** ![DavidKing2020](https://avatars.discourse-cdn.com/v4/letter/d/e0b2c6/32.png) [@DavidKing2020](https://brian.discourse.group/u/DavidKing2020)\
**Post date:** [6 October 2022 21:37 UTC](https://brian.discourse.group/t/constrain-memory-consumption-durning-compilation-in-brian2cuda/798/3 "2022-10-06T21:37:55Z")

</div>

Thanks Marcel. This is indeed the case. add the suggested command solved the problem.
