Issue with memory allocation

I’m using kria kv260 which has 4GB of ram and when I do free -m:

total used free shared buff/cache available
Mem: 3906 327 3204 3 374 3417
Swap: 0 0 0

As you see I have 3GB free but when I try to allocate 2080MB it fails:

allocate(shape=(272629760,), dtype=np.uint64)

Error Message:

RuntimeError: Allocate failed: 4294967295

I have 272629760 items which are 64bit so (272629760 * 64) == 2080MB, But it fails to allocate.
What am I missing?

Hi @dbnyxrxp,

Welcome to the PYNQ community.

allocate needs Contiguous Memory Allocator (CMA) to work. In the KV260 the cma is configured to be around 1000M. You can check this with cat /proc/cmdline, you will see cma=1000M

If you request to allocate more than 1000M, it will fail as there is no enough contiguous memory memory available.

You may be able to change the kernel bootargs to get more cma memory.[inlineExtension]Changing-the-Kernel-bootargs-Used-By-U-Boot

For further support on CMA, I would suggest the Xilinx forums.


I changed the args but still get the same error:

root@kria:/# cat /proc/cmdline
cma=2800M earlycon root=LABEL=writable rootwait console=ttyPS1,115200 console=tty1clk_ignore_unused uio_pdrv_genirq.of_id=generic-uio xilinx_tsn_ep.st_pcp=4 cma=1000M quiet splash cma=2800M

root@kria:/# cat /etc/default/flash-kernel
LINUX_KERNEL_CMDLINE=“quiet splash cma=2800M”

Hi @dbnyxrxp,

I suggest you post your question on the Xilinx forums. Increasing CMA for the KV260 Ubuntu SD card image is outside of the scope of this forum.


Thank you, even though I still face the issue but your answer got me on the track.

1 Like