Skip to content

Commit 595c57a

Browse files
authored
Merge pull request #418 from luxonis/update-python-docs-pages
Added "How to preserve RAM"
2 parents d96752a + 113e165 commit 595c57a

File tree

3 files changed

+58
-1
lines changed

3 files changed

+58
-1
lines changed

docs/source/index.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,9 @@ Now, pick a tutorial or code sample and start utilizing Gen2 capabilities
7878
tutorials/hello_world.rst
7979
tutorials/multiple.rst
8080
tutorials/maximize_fov.rst
81-
tutorials/dispaying_detections.rst
8281
tutorials/debugging.rst
82+
tutorials/ram_usage.rst
83+
tutorials/dispaying_detections.rst
8384

8485
.. toctree::
8586
:maxdepth: 1

docs/source/tutorials/debugging.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ Debugging DepthAI pipeline
44
Currently, tools for debugging the DepthAI pipeline are limited. We plan on creating a software that would track all messages and queues,
55
which would allow users to debug a "frozen" pipeline much easier, which is usually caused by a filled up :ref:`blocking queue <Blocking behaviour>`.
66

7+
.. _depthai_logging:
8+
79
DepthAI debugging level
810
=======================
911

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
RAM usage
2+
=========
3+
4+
All devices have 512 MiB (4 Gbit) on-board RAM, which is used for firmware (about 15MB), assets (a few KB up to 100MB+, eg. NN models), and other
5+
resources, such as message pools where messages are stored.
6+
7+
If you enable :code:`info` :ref:`logging <depthai_logging>`, you will see how RAM is used:
8+
9+
.. code-block:: bash
10+
11+
[info] Memory Usage - DDR: 41.23 / 358.82 MiB, CMX: 2.17 / 2.50 MiB,
12+
LeonOS Heap: 20.70 / 78.63 MiB, LeonRT Heap: 3.51 / 23.84 MiB
13+
14+
As you can see, RAM is split between the two LEON (CPU) cores, :code:`CMX` (used for image manipulation), and :code:`DDR` (everything else).
15+
If :code:`DDR` usage is close to the max (in this example, 358 MiB), you might get an error such as:
16+
17+
.. code-block:: bash
18+
19+
[error] Neural network executor '0' out of '2' error: OUT_OF_MEMORY
20+
21+
This means you should decrease RAM consumption, and we will take a look at a few ways on how to do this.
22+
23+
Decreasing RAM consumption
24+
##########################
25+
26+
- **Large frames**
27+
28+
If we change the resolution from 1080P to 4K in the :ref:`RGB video` example, DDR usage will increase from 41 MiB to 161 MiB. That's because
29+
4K uses 4x more RAM compared to 1080P frame. An easy way to decrease RAM consumption is to use lower resolution / smaller frames.
30+
31+
- **VideoEncoder**
32+
33+
:ref:`VideoEncoder` nodes can consume a lot of RAM, especially at high resolutions. For example, :ref:`RGB Encoding` example consumes
34+
259 MiB. If we change the resolution from 4K to 1080P, we decrease DDR consumption to only 65 MiB.
35+
36+
- **ImageManip**
37+
38+
Each :ref:`ImageManip` node will have it's own (output) pool of 4 frames (by default), so having multiple ImageManips that are manipulating
39+
high resolution frames will consume a lot of DDR RAM. You can change the pool size with :code:`manip.setNumFramesPool(4)`. By default,
40+
each pool "spot" will consume 1 MiB, even if it's a small 300x300 RGB frame (which is 270kB). Specifying the output frame size
41+
can therefore decrease the RAM as well, eg. for a 300x300 RGB frame, you can set :code:`manip.setMaxOutputFrameSize(270000)`.
42+
43+
- **XLinkIn**
44+
45+
Just like :ref:`ImageManip`, each :ref:`XLinkIn` node has it's own message pool as well. By default, each XLinkIn will consume 40 MiB, as
46+
each pool "spot" has 5 MiB reserved, and there are 8 "spots" in the pool. If you are sending 300x300 RGB frames from the host to the device,
47+
you can set :code:`xin.setMaxDataSize(270000)`, and also limit number of messages per pool :code:`xin.setNumFrames(4)`. This will decrease
48+
DDR RAM consumption from 40 MiB to about 1 MiB.
49+
50+
If you are just sending control/config from the host, you can
51+
set :code:`xin.setMaxDataSize(1)`, as :ref:`CameraControl` and :ref:`ImageManipConfig` don't have any extra data
52+
(like :ref:`NNData`/:ref:`ImgFrame`/:ref:`Buffer`).
53+
54+
.. include:: ../includes/footer-short.rst

0 commit comments

Comments
 (0)