Ollama cannot use GPU in Docker on QNAP (RTX 3090, CUDA init fails)

Support has stopped responding to my ticket. The ticket is open from 11.4. The last answer is from 12.6.

Tony Yeh
2026-06-12 13:22

hi

Thank you for your patience.

Our development team is still actively working on this issue and may require some additional time

I will keep you updated as soon as there is any feedback or progress from our development team.

Thank you for your understanding.

An update here. Someone earlier in the thread said that QuTS Hero 6.0 made a difference but my first attempt at this wasn’t successful. (it still defaulted to CPU). But a little help from Google Gemini and I have a YAML that works for me.

Hardware: QNAP TVS-h1688x

QuTS Hero: 6.0.0.3500

GPU: Nvidia RTX 3060 (12 GB VRAM)

Docker: Container Station

My objective was to run Ollama on my 1688x with an OpenWebUI front end. I asked Google Gemini to write an appropriate YAML that would work with QNAP Container Station taking into account the RTX 3060. This was the first attempt an remember, this version DID NOT WORK with the GPU.

version: ‘3.8’

services:

ollama:

image: ollama/ollama:latest

container_name: ollama

volumes:

- /share/Container/ollama:/root/.ollama

ports:

- “11434:11434”

deploy:

resources:

reservations:

devices:

- driver: nvidia

count: 1

capabilities: [gpu]

restart: unless-stopped

networks:

- ai-network

open-webui:

image: ghcr.io/open-webui/open-webui:main

container_name: open-webui

ports:

- “3000:8080”

volumes:

- /share/Container/open-webui:/app/backend/data

environment:

- OLLAMA_BASE_URL=http://ollama:11434

depends_on:

- ollama

restart: unless-stopped

networks:

- ai-network

networks:

ai-network:

driver: bridge

Continued next reply…

Again, the previous YAML failed to use the GPU. After asking Gemini to rework the issue, it came back with the following YAML that did work with the GPU: (I deleted the OpenWebUI YAML for redundancy since it didn’t change)

version: “3.8”

services:

ollama:

image: ollama/ollama:latest

container_name: ollama

restart: unless-stopped

ports:

- “11434:11434”

volumes:

- /share/Container/ollama:/root/.ollama

environment:

- OLLAMA_HOST=0.0.0.0

- OLLAMA_KEEP_ALIVE=24h

deploy:

resources:

reservations:

devices:

- driver: nvidia

count: all

capabilities: [gpu]

I have no idea if this will solve the issue with QTS 5.9.0, but it may be worth a shot. The big difference are the environment variables (OLLAMA_HOST and OLLAMA_KEEP_ALIVE).

i haven’t really noticed a similar issue as mentioned in this thread. I might be missing it since I dont use open-web AI/ ollama app all the time. I have it running and it will unload the llm, then next time i use it it loads it.

  • I am using an approved nvidia card for my NAS model.
  • I am using https://oi.adhome.top/?model=nemotron-3-nano%3A4b for the LLM. it lightweight and runs well for chat.
  • i have gotten some OOM killers occasionally, and resolved that with stopping the app and restarting it. I never had to shutdown the NAS.
  • I also share the card with jellyfin and immich apps.

App compose file to deploy

#4 CPU | 6144 MB RAM
services:
  open-webui:
    image: ghcr.io/open-webui/open-webui:cuda
    container_name: oi
    stdin_open: true 
    tty: true
    pull_policy: always
    networks:
      - backendApps
    restart: unless-stopped
    stop_grace_period: 30s # allow enough time to shut down the various services
    volumes:
      - /share/open-webui:/app/backend/data
    ports:
      - 3010:8080
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: all
              capabilities:
                - gpu
  ollama:
    volumes:
      - /share/ollama:/root/.ollama
    container_name: ollama
    pull_policy: always
    tty: true
    networks:
      - backendApps
    restart: unless-stopped
    image: docker.io/ollama/ollama:latest
    ports:
      - 11434:11434
    environment:
      - OLLAMA_KEEP_ALIVE=24h
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: all 
              capabilities: [gpu]

     
networks:     
  backendApps:
    external: true

Details on hardware/OS

Hello,

I think the difference comes from this: OLLAMA_KEEP_ALIVE=24h

Frequently unloading and reloading the models seems to cause problems. When the loading process takes a long time, the problem seems less frequent. Personally, I’m currently testing with 5 hours, and after that time, I still have the loading issue—mainly because the model exceeds the GPU’s RAM, and instead of switching to a CPU/GPU hybrid mode, it switches to CPU-only mode. Or it unloads the model to switch to another one.

The problem isn’t limited to Open WebUI; it was also present in Qsirch and RAG.

I think this has been mentioned in other posts, but newer Nvidia drivers fix some issues like this.

I did try a larger model that exceeded the 12 gigs of VRAM in my card. It did slow things down but Resource Manager did show that the card was being used at about 80% VRAM usage and GPU usage versus smaller numbers with a smaller model. It was still much faster than when I first did it and it was defaulting to CPU only (which on a 10th gen Xeon was extremely slow).

(Deleted last post to prevent confusion, since that was not the solution)

I found out that CUDA context held by ANY process prevents this bug. So, I created this simple Docker container with Codex: Qnap CUDA holder (GitHub)

Check driver path and your host path, run it, then wait for holding CUDA context log message. In my case, I’m now using GPU without problem for over a week. (Recommend rebooting and run this right after; it does not ‘fix’ already failing GPU).

Hope this helps.

Something else to know when trying to use Nvidia GPU’s for AI workloads. I have an outstanding ticket open on this with QNAP.

NVIDIA GPU initialization fails after ~1-3 day uptime — ZFS ARC pins physical memory; no contiguous 512KB blocks remain (TVS-AIh1688ATX, QuTS hero h6.0.1.3564)

On a TVS-AIh1688ATX (192 GB ECC RAM, NVIDIA RTX PRO 4000 Blackwell, driver 575.64.05, BIOS QA008AR14), the NVIDIA kernel driver becomes unable to initialize a CUDA context after roughly one to three days of uptime with Arc Ram Usage set at 70%. dmesg shows NVRM “Out of memory [NV_ERR_NO_MEMORY]” from _memdescAllocInternal while allocating its MMU fault buffer with ~44 GB of RAM free and the GPU otherwise healthy. You can slow the decline of contiguous blocks by lowering Arc Ram Usage, but a reboot is the only recovery mechanism currently available.

This is not an out-of-memory condition. It is physical memory fragmentation: /proc/buddyinfo captured at the moment of failure shows the 188 GB normal zone with zero free blocks at 128 KB and above. I bracketed the driver’s requirement empirically after forced compaction restored 18,000+ free 128 KB blocks and 69 256 KB blocks; initialization still failed identically, so the driver needs a contiguous region of at least 512 KB, and this system cannot produce one.

I eliminated every recovery short of reboot, all captured: stopping the GPU consumer, vm.compact_memory (rebuilds up to 256 KB, hard wall at 512 KB), and a full drop_caches followed by compaction (no further progress). The pages blocking every remaining 512 KB region are therefore unmovable, unreclaimable kernel memory on this system, ZFS ARC (~127 GB). Only a reboot recovers. Under a RAM-heavy workload, the failure reproduces in under 24 hours; under a lighter load, within days. Reproduction is reliable.

The hardware is healthy: the GPU initializes perfectly on every fresh boot and memory passes MemTest86. What I’m asking for is a supported way on QuTS hero to cap ZFS ARC (or reserve a contiguity pool) so ~96–128 GB stays compaction-friendly or acknowledgement and tracking if no such tunable exists.

For clearification: That’s most likely driver bug originating from Nvidia driver 575.64(.05), which QNAP utilizes currently. Even if QNAP manages RAM space poorly, GPU driver should successfully initialize CUDA if there’s enough RAM capacity, regardless of memory fragmentation, in normal use. I guess Nvidia driver 575.64 coded too tight restriction to the memory or mistakingly skip fallback route for memory allocation.

However, during any process holding CUDA context, the bug is gone - since memory does not needed to re-allocated. That’s why I made simple container to do so. (It’s one post above) I’m now using CUDA after over a week from my last reboot now.

I had information that the driver bug would be fixed in version 5.2.11 and it seems that is indeed the case now NVIDIA GPU Runtime 6.2.3.0580. Since yesterday’s update, everything has been working as it should. The drive didn’t last more than a few hours. In 6.x beta, this bug is still there.

Hi,

By following the following modification: Getting GPU-Accelerated PaddlePaddle Working in Docker on QNAP NAS , my system has been running very well for several weeks. I put an unloading after 8 hours of my inference, but whether it’s the reloading or the change of inference, I no longer note any problem.