[GH-ISSUE #10257] Docker container loses GPU access after running for a while on Ubuntu 24.04 #6731

Closed
opened 2026-04-12 18:29:26 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @TimLai666 on GitHub (Apr 13, 2025).
Original GitHub issue: https://github.com/ollama/ollama/issues/10257

What is the issue?

Description:
I'm running Ollama (v0.6.5) inside a Docker container with GPU access configured. Everything works fine initially, and the container successfully uses the GPU. However, after some time (usually a few hours), the container seems to lose access to the GPU and falls back to using the CPU automatically. This behavior happens without any restart or change on my end.

System Information:

  • OS: Ubuntu 24.04 (host)
  • Docker version: (output of docker version)
  • NVIDIA Driver version: (output of nvidia-smi)
  • Ollama version: v0.6.5
  • NVIDIA Container Toolkit: Installed (nvidia-container-toolkit)

docker-compose.yml:

services:
  ollama:
    image: ollama/ollama:latest
    container_name: ollama
    hostname: ollama
    volumes:
      - /mnt/ssd1/ollama/.ollama:/root/.ollama
    ports:
      - "11434:11434"
    networks:
      - ollama-net
    restart: always
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: all
              capabilities: [gpu]

networks:
  ollama-net:
    external: true

Symptoms:

  • Ollama starts normally and utilizes the GPU.
  • After some hours of usage or idling, it stops recognizing the GPU.
  • nvidia-smi on the host still shows GPU is healthy and available.
  • Inside the container, Ollama logs suggest fallback to CPU (e.g., no CUDA layers loaded).
  • Restarting the container temporarily restores GPU access.

Steps to Reproduce:

  1. Run the Ollama container using the above docker-compose.yml.
  2. Confirm GPU is in use via logs or system usage.
  3. Wait several hours (usage pattern doesn’t seem to matter).
  4. Observe that Ollama no longer uses the GPU.

Expected Behavior:
Ollama should continue using the GPU as long as the container is running and the host GPU is healthy.

Additional Notes:

  • This may be related to Docker resource isolation or a driver/runtime issue.
  • Open to suggestions on how to debug this further.

Relevant log output


OS

Linux

GPU

Nvidia

CPU

AMD

Ollama version

0.6.5

Originally created by @TimLai666 on GitHub (Apr 13, 2025). Original GitHub issue: https://github.com/ollama/ollama/issues/10257 ### What is the issue? **Description:** I'm running Ollama (`v0.6.5`) inside a Docker container with GPU access configured. Everything works fine initially, and the container successfully uses the GPU. However, after some time (usually a few hours), the container seems to lose access to the GPU and falls back to using the CPU automatically. This behavior happens without any restart or change on my end. **System Information:** - **OS:** Ubuntu 24.04 (host) - **Docker version:** (output of `docker version`) - **NVIDIA Driver version:** (output of `nvidia-smi`) - **Ollama version:** `v0.6.5` - **NVIDIA Container Toolkit:** Installed (`nvidia-container-toolkit`) **docker-compose.yml:** ```yaml services: ollama: image: ollama/ollama:latest container_name: ollama hostname: ollama volumes: - /mnt/ssd1/ollama/.ollama:/root/.ollama ports: - "11434:11434" networks: - ollama-net restart: always deploy: resources: reservations: devices: - driver: nvidia count: all capabilities: [gpu] networks: ollama-net: external: true ``` **Symptoms:** - Ollama starts normally and utilizes the GPU. - After some hours of usage or idling, it stops recognizing the GPU. - `nvidia-smi` on the host still shows GPU is healthy and available. - Inside the container, Ollama logs suggest fallback to CPU (e.g., no CUDA layers loaded). - Restarting the container temporarily restores GPU access. **Steps to Reproduce:** 1. Run the Ollama container using the above `docker-compose.yml`. 2. Confirm GPU is in use via logs or system usage. 3. Wait several hours (usage pattern doesn’t seem to matter). 4. Observe that Ollama no longer uses the GPU. **Expected Behavior:** Ollama should continue using the GPU as long as the container is running and the host GPU is healthy. **Additional Notes:** - This may be related to Docker resource isolation or a driver/runtime issue. - Open to suggestions on how to debug this further. ### Relevant log output ```shell ``` ### OS Linux ### GPU Nvidia ### CPU AMD ### Ollama version 0.6.5
GiteaMirror added the bug label 2026-04-12 18:29:26 -05:00
Author
Owner
<!-- gh-comment-id:2799935570 --> @rick-github commented on GitHub (Apr 13, 2025): https://github.com/ollama/ollama/blob/main/docs/troubleshooting.md#linux-docker
Author
Owner

@TimLai666 commented on GitHub (Apr 13, 2025):

https://github.com/ollama/ollama/blob/main/docs/troubleshooting.md#linux-docker

Thanks!

<!-- gh-comment-id:2799939644 --> @TimLai666 commented on GitHub (Apr 13, 2025): > https://github.com/ollama/ollama/blob/main/docs/troubleshooting.md#linux-docker Thanks!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#6731