<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Hemkesh</title>
    <description>The latest articles on DEV Community by Hemkesh (@hemkesh2021dotcom).</description>
    <link>https://dev.to/hemkesh2021dotcom</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3989202%2Fcf128d60-77b0-44be-857b-a30fc5f74c11.png</url>
      <title>DEV Community: Hemkesh</title>
      <link>https://dev.to/hemkesh2021dotcom</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/hemkesh2021dotcom"/>
    <language>en</language>
    <item>
      <title>Why cudaMalloc fails on NVIDIA Jetson Orin Nano Super — and the one flag that fixes it</title>
      <dc:creator>Hemkesh</dc:creator>
      <pubDate>Wed, 17 Jun 2026 13:57:24 +0000</pubDate>
      <link>https://dev.to/hemkesh2021dotcom/why-cudamalloc-fails-on-nvidia-jetson-orin-nano-super-and-the-one-flag-that-fixes-it-1b0n</link>
      <guid>https://dev.to/hemkesh2021dotcom/why-cudamalloc-fails-on-nvidia-jetson-orin-nano-super-and-the-one-flag-that-fixes-it-1b0n</guid>
      <description>&lt;h1&gt;
  
  
  Why cudaMalloc fails on NVIDIA Jetson Orin Nano Super — and the one flag that fixes it
&lt;/h1&gt;

&lt;p&gt;If you've tried running a GGUF model via llama.cpp on a Jetson Orin Nano Super and hit this error:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;NvMapMemAllocInternalTagged: error 12
cudaMalloc failed: out of memory
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;...while tegrastats shows the GPU idle and several GB of RAM free — this post is for you.&lt;/p&gt;

&lt;h2&gt;
  
  
  The hardware context
&lt;/h2&gt;

&lt;p&gt;The Jetson Orin Nano Super (8 GB) uses unified memory. There is no separate VRAM pool — the CPU and GPU share one physical 8 GB block. This is how all Jetson Orin-series SoCs work, and it's what makes them cost-effective for edge AI.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why stock llama.cpp fails
&lt;/h2&gt;

&lt;p&gt;When llama.cpp allocates GPU tensor buffers, it calls &lt;code&gt;cudaMalloc&lt;/code&gt;. On a discrete GPU, &lt;code&gt;cudaMalloc&lt;/code&gt; carves out memory from a dedicated VRAM pool. On the Orin Nano Super, that dedicated pool doesn't exist — the allocator hits the NvMap interface, which rejects the request with error 12 (ENOMEM) even though the unified pool has plenty of space.&lt;/p&gt;

&lt;p&gt;The result: the model fails to load with a misleading out-of-memory error despite free RAM.&lt;/p&gt;

&lt;h2&gt;
  
  
  The fix
&lt;/h2&gt;

&lt;p&gt;Set &lt;code&gt;GGML_CUDA_ENABLE_UNIFIED_MEMORY=1&lt;/code&gt; as an environment variable when you launch the server. This is a &lt;strong&gt;runtime flag, not a build option&lt;/strong&gt; — in llama.cpp's CUDA backend it switches GPU allocations from &lt;code&gt;cudaMalloc&lt;/code&gt; to &lt;code&gt;cudaMallocManaged&lt;/code&gt;, which works with the unified pool.&lt;/p&gt;

&lt;p&gt;First, build llama.cpp with CUDA for the Orin's compute capability (sm_87):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/ggml-org/llama.cpp
&lt;span class="nb"&gt;cd &lt;/span&gt;llama.cpp
cmake &lt;span class="nt"&gt;-B&lt;/span&gt; build &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-DGGML_CUDA&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;ON &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-DCMAKE_CUDA_ARCHITECTURES&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;87
cmake &lt;span class="nt"&gt;--build&lt;/span&gt; build &lt;span class="nt"&gt;--config&lt;/span&gt; Release &lt;span class="nt"&gt;-j&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;nproc&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then enable unified memory at launch by setting the environment variable:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;GGML_CUDA_ENABLE_UNIFIED_MEMORY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;1 ./build/bin/llama-server &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-m&lt;/span&gt; LFM2-VL-1.6B-Q4_0.gguf &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;--mmproj&lt;/span&gt; mmproj-LFM2-VL-1.6B-Q8_0.gguf &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;--n-gpu-layers&lt;/span&gt; 999
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's it. The model loads and runs fully GPU-accelerated.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I was building
&lt;/h2&gt;

&lt;p&gt;I ran into this while building SENTINEL — a self-hosted AI surveillance system for my B.Tech minor project. It runs YOLOv8n + TensorRT for person detection, DeepFace for face recognition, and LFM2-VL 1.6B for scene understanding — all on the Jetson, zero cloud dependency.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Full project and complete BUILD.md:&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://github.com/hemkesh2021-dotcom/Sentinel_Surveillance" rel="noopener noreferrer"&gt;https://github.com/hemkesh2021-dotcom/Sentinel_Surveillance&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hope this saves someone a few hours of debugging.&lt;/p&gt;

</description>
      <category>jetson</category>
      <category>nvidia</category>
      <category>cpp</category>
      <category>edgeai</category>
    </item>
  </channel>
</rss>
