[GH-ISSUE #7296] ollama can not detect RTX GPU card #82319

Closed
opened 2026-05-09 13:42:55 -05:00 by GiteaMirror · 4 comments
Owner

Originally created by @wangqiang-kubota on GitHub (Oct 21, 2024).
Original GitHub issue: https://github.com/ollama/ollama/issues/7296

Originally assigned to: @dhiltgen on GitHub.

What is the issue?

I have one RTX 4080 installed and used ollama 0.3.14 docker version. Now ollama is working on CPU mode and GPU cannot be detected. I enter the ollama container and run the command 'nvidia-smi'

GPU information:
image

Ollama start command :
docker run -d -e CUDA_VISIBLE_DEVICES=0 -e OLLAMA_DEBUG=1 --gpus=all -v /data/models:/root/.ollama -p 11434:11434 --restart unless-stopped --name ollama ollama/ollama

Ollama start logs:
2024/10/21 13:35:53 routes.go:1158: INFO server config env="map[CUDA_VISIBLE_DEVICES:0 GPU_DEVICE_ORDINAL: HIP_VISIBLE_DEVICES: HSA_OVERRIDE_GFX_VERSION: HTTPS_PROXY: HTTP_PROXY: NO_PROXY: OLLAMA_DEBUG:true OLLAMA_FLASH_ATTENTION:false OLLAMA_GPU_OVERHEAD:0 OLLAMA_HOST:http://0.0.0.0:11434/ OLLAMA_INTEL_GPU:false OLLAMA_KEEP_ALIVE:5m0s OLLAMA_LLM_LIBRARY: OLLAMA_LOAD_TIMEOUT:5m0s OLLAMA_MAX_LOADED_MODELS:0 OLLAMA_MAX_QUEUE:512 OLLAMA_MODELS:/root/.ollama/models OLLAMA_MULTIUSER_CACHE:false OLLAMA_NOHISTORY:false OLLAMA_NOPRUNE:false OLLAMA_NUM_PARALLEL:0 OLLAMA_ORIGINS:[http://localhost/ https://localhost/ http://localhost/:* https://localhost/:* http://127.0.0.1/ https://127.0.0.1/ http://127.0.0.1/:* https://127.0.0.1/:* http://0.0.0.0/ https://0.0.0.0/ http://0.0.0.0/:* https://0.0.0.0/:* app://* file://* tauri://*] OLLAMA_SCHED_SPREAD:false OLLAMA_TMPDIR: ROCR_VISIBLE_DEVICES: http_proxy: https_proxy: no_proxy:]" time=2024-10-21T13:35:53.445Z level=INFO source=images.go:754 msg="total blobs: 10" time=2024-10-21T13:35:53.445Z level=INFO source=images.go:761 msg="total unused blobs removed: 0" time=2024-10-21T13:35:53.445Z level=INFO source=routes.go:1205 msg="Listening on [::]:11434 (version 0.3.14)" time=2024-10-21T13:35:53.445Z level=DEBUG source=common.go:294 msg="availableServers : found" file=/usr/lib/ollama/runners/cpu/ollama_llama_server time=2024-10-21T13:35:53.445Z level=DEBUG source=common.go:294 msg="availableServers : found" file=/usr/lib/ollama/runners/cpu_avx/ollama_llama_server time=2024-10-21T13:35:53.445Z level=DEBUG source=common.go:294 msg="availableServers : found" file=/usr/lib/ollama/runners/cpu_avx2/ollama_llama_server time=2024-10-21T13:35:53.445Z level=DEBUG source=common.go:294 msg="availableServers : found" file=/usr/lib/ollama/runners/cuda_v11/ollama_llama_server time=2024-10-21T13:35:53.445Z level=DEBUG source=common.go:294 msg="availableServers : found" file=/usr/lib/ollama/runners/cuda_v12/ollama_llama_server time=2024-10-21T13:35:53.445Z level=INFO source=common.go:49 msg="Dynamic LLM libraries" runners="[cuda_v11 cuda_v12 cpu cpu_avx cpu_avx2]" time=2024-10-21T13:35:53.445Z level=DEBUG source=common.go:50 msg="Override detection logic by setting OLLAMA_LLM_LIBRARY" time=2024-10-21T13:35:53.445Z level=DEBUG source=sched.go:105 msg="starting llm scheduler" time=2024-10-21T13:35:53.445Z level=INFO source=gpu.go:221 msg="looking for compatible GPUs" time=2024-10-21T13:35:53.446Z level=DEBUG source=gpu.go:94 msg="searching for GPU discovery libraries for NVIDIA" time=2024-10-21T13:35:53.446Z level=DEBUG source=gpu.go:505 msg="Searching for GPU library" name=libcuda.so* time=2024-10-21T13:35:53.446Z level=DEBUG source=gpu.go:528 msg="gpu library search" globs="[/usr/lib/ollama/libcuda.so* /usr/local/nvidia/lib/libcuda.so* /usr/local/nvidia/lib64/libcuda.so* /usr/local/cuda*/targets/*/lib/libcuda.so* /usr/lib/*-linux-gnu/nvidia/current/libcuda.so* /usr/lib/*-linux-gnu/libcuda.so* /usr/lib/wsl/lib/libcuda.so* /usr/lib/wsl/drivers/*/libcuda.so* /opt/cuda/lib*/libcuda.so* /usr/local/cuda/lib*/libcuda.so* /usr/lib*/libcuda.so* /usr/local/lib*/libcuda.so*]" time=2024-10-21T13:35:53.446Z level=DEBUG source=gpu.go:562 msg="discovered GPU libraries" paths=[/usr/lib/x86_64-linux-gnu/libcuda.so.535.171.04] cuInit err: 3 time=2024-10-21T13:35:53.452Z level=INFO source=gpu.go:616 msg="Unable to load cudart library /usr/lib/x86_64-linux-gnu/libcuda.so.535.171.04: cuda driver library init failure: 3" time=2024-10-21T13:35:53.452Z level=DEBUG source=gpu.go:505 msg="Searching for GPU library" name=libcudart.so* time=2024-10-21T13:35:53.452Z level=DEBUG source=gpu.go:528 msg="gpu library search" globs="[/usr/lib/ollama/libcudart.so* /usr/local/nvidia/lib/libcudart.so* /usr/local/nvidia/lib64/libcudart.so* /usr/lib/ollama/libcudart.so* /usr/local/cuda/lib64/libcudart.so* /usr/lib/x86_64-linux-gnu/nvidia/current/libcudart.so* /usr/lib/x86_64-linux-gnu/libcudart.so* /usr/lib/wsl/lib/libcudart.so* /usr/lib/wsl/drivers/*/libcudart.so* /opt/cuda/lib64/libcudart.so* /usr/local/cuda*/targets/aarch64-linux/lib/libcudart.so* /usr/lib/aarch64-linux-gnu/nvidia/current/libcudart.so* /usr/lib/aarch64-linux-gnu/libcudart.so* /usr/local/cuda/lib*/libcudart.so* /usr/lib*/libcudart.so* /usr/local/lib*/libcudart.so*]" time=2024-10-21T13:35:53.452Z level=DEBUG source=gpu.go:562 msg="discovered GPU libraries" paths="[/usr/lib/ollama/libcudart.so.12.4.99 /usr/lib/ollama/libcudart.so.11.3.109]" cudaSetDevice err: 3 time=2024-10-21T13:35:53.457Z level=DEBUG source=gpu.go:578 msg="Unable to load cudart library /usr/lib/ollama/libcudart.so.12.4.99: cudart init failure: 3" cudaSetDevice err: 3 time=2024-10-21T13:35:53.462Z level=DEBUG source=gpu.go:578 msg="Unable to load cudart library /usr/lib/ollama/libcudart.so.11.3.109: cudart init failure: 3" time=2024-10-21T13:35:53.462Z level=DEBUG source=amd_linux.go:416 msg="amdgpu driver not detected /sys/module/amdgpu" time=2024-10-21T13:35:53.462Z level=INFO source=gpu.go:384 msg="no compatible GPUs were discovered" time=2024-10-21T13:35:53.462Z level=INFO source=types.go:123 msg="inference compute" id=0 library=cpu variant=avx2 compute="" driver=0.0 name="" total="15.6 GiB" available="9.9 GiB"

When I run some LLM action, it always shows below information(100% CPU in processor field and the model was loaded by CPU):
image

Operation System:
image

if any more information needed please let me know. Thank you in advanced.

OS

Linux

GPU

Nvidia

CPU

Intel

Ollama version

0.3.14

Originally created by @wangqiang-kubota on GitHub (Oct 21, 2024). Original GitHub issue: https://github.com/ollama/ollama/issues/7296 Originally assigned to: @dhiltgen on GitHub. ### What is the issue? I have one RTX 4080 installed and used ollama 0.3.14 docker version. Now ollama is working on CPU mode and GPU cannot be detected. I enter the ollama container and run the command 'nvidia-smi' **GPU information:** <img width="763" alt="image" src="https://github.com/user-attachments/assets/44c1b77c-d27d-4bbf-a50e-7d961e6a5633"> **Ollama start command :** `docker run -d -e CUDA_VISIBLE_DEVICES=0 -e OLLAMA_DEBUG=1 --gpus=all -v /data/models:/root/.ollama -p 11434:11434 --restart unless-stopped --name ollama ollama/ollama` **Ollama start logs:** `2024/10/21 13:35:53 routes.go:1158: INFO server config env="map[CUDA_VISIBLE_DEVICES:0 GPU_DEVICE_ORDINAL: HIP_VISIBLE_DEVICES: HSA_OVERRIDE_GFX_VERSION: HTTPS_PROXY: HTTP_PROXY: NO_PROXY: OLLAMA_DEBUG:true OLLAMA_FLASH_ATTENTION:false OLLAMA_GPU_OVERHEAD:0 OLLAMA_HOST:http://0.0.0.0:11434/ OLLAMA_INTEL_GPU:false OLLAMA_KEEP_ALIVE:5m0s OLLAMA_LLM_LIBRARY: OLLAMA_LOAD_TIMEOUT:5m0s OLLAMA_MAX_LOADED_MODELS:0 OLLAMA_MAX_QUEUE:512 OLLAMA_MODELS:/root/.ollama/models OLLAMA_MULTIUSER_CACHE:false OLLAMA_NOHISTORY:false OLLAMA_NOPRUNE:false OLLAMA_NUM_PARALLEL:0 OLLAMA_ORIGINS:[http://localhost/ https://localhost/ http://localhost/:* https://localhost/:* http://127.0.0.1/ https://127.0.0.1/ http://127.0.0.1/:* https://127.0.0.1/:* http://0.0.0.0/ https://0.0.0.0/ http://0.0.0.0/:* https://0.0.0.0/:* app://* file://* tauri://*] OLLAMA_SCHED_SPREAD:false OLLAMA_TMPDIR: ROCR_VISIBLE_DEVICES: http_proxy: https_proxy: no_proxy:]" time=2024-10-21T13:35:53.445Z level=INFO source=images.go:754 msg="total blobs: 10" time=2024-10-21T13:35:53.445Z level=INFO source=images.go:761 msg="total unused blobs removed: 0" time=2024-10-21T13:35:53.445Z level=INFO source=routes.go:1205 msg="Listening on [::]:11434 (version 0.3.14)" time=2024-10-21T13:35:53.445Z level=DEBUG source=common.go:294 msg="availableServers : found" file=/usr/lib/ollama/runners/cpu/ollama_llama_server time=2024-10-21T13:35:53.445Z level=DEBUG source=common.go:294 msg="availableServers : found" file=/usr/lib/ollama/runners/cpu_avx/ollama_llama_server time=2024-10-21T13:35:53.445Z level=DEBUG source=common.go:294 msg="availableServers : found" file=/usr/lib/ollama/runners/cpu_avx2/ollama_llama_server time=2024-10-21T13:35:53.445Z level=DEBUG source=common.go:294 msg="availableServers : found" file=/usr/lib/ollama/runners/cuda_v11/ollama_llama_server time=2024-10-21T13:35:53.445Z level=DEBUG source=common.go:294 msg="availableServers : found" file=/usr/lib/ollama/runners/cuda_v12/ollama_llama_server time=2024-10-21T13:35:53.445Z level=INFO source=common.go:49 msg="Dynamic LLM libraries" runners="[cuda_v11 cuda_v12 cpu cpu_avx cpu_avx2]" time=2024-10-21T13:35:53.445Z level=DEBUG source=common.go:50 msg="Override detection logic by setting OLLAMA_LLM_LIBRARY" time=2024-10-21T13:35:53.445Z level=DEBUG source=sched.go:105 msg="starting llm scheduler" time=2024-10-21T13:35:53.445Z level=INFO source=gpu.go:221 msg="looking for compatible GPUs" time=2024-10-21T13:35:53.446Z level=DEBUG source=gpu.go:94 msg="searching for GPU discovery libraries for NVIDIA" time=2024-10-21T13:35:53.446Z level=DEBUG source=gpu.go:505 msg="Searching for GPU library" name=libcuda.so* time=2024-10-21T13:35:53.446Z level=DEBUG source=gpu.go:528 msg="gpu library search" globs="[/usr/lib/ollama/libcuda.so* /usr/local/nvidia/lib/libcuda.so* /usr/local/nvidia/lib64/libcuda.so* /usr/local/cuda*/targets/*/lib/libcuda.so* /usr/lib/*-linux-gnu/nvidia/current/libcuda.so* /usr/lib/*-linux-gnu/libcuda.so* /usr/lib/wsl/lib/libcuda.so* /usr/lib/wsl/drivers/*/libcuda.so* /opt/cuda/lib*/libcuda.so* /usr/local/cuda/lib*/libcuda.so* /usr/lib*/libcuda.so* /usr/local/lib*/libcuda.so*]" time=2024-10-21T13:35:53.446Z level=DEBUG source=gpu.go:562 msg="discovered GPU libraries" paths=[/usr/lib/x86_64-linux-gnu/libcuda.so.535.171.04] cuInit err: 3 time=2024-10-21T13:35:53.452Z level=INFO source=gpu.go:616 msg="Unable to load cudart library /usr/lib/x86_64-linux-gnu/libcuda.so.535.171.04: cuda driver library init failure: 3" time=2024-10-21T13:35:53.452Z level=DEBUG source=gpu.go:505 msg="Searching for GPU library" name=libcudart.so* time=2024-10-21T13:35:53.452Z level=DEBUG source=gpu.go:528 msg="gpu library search" globs="[/usr/lib/ollama/libcudart.so* /usr/local/nvidia/lib/libcudart.so* /usr/local/nvidia/lib64/libcudart.so* /usr/lib/ollama/libcudart.so* /usr/local/cuda/lib64/libcudart.so* /usr/lib/x86_64-linux-gnu/nvidia/current/libcudart.so* /usr/lib/x86_64-linux-gnu/libcudart.so* /usr/lib/wsl/lib/libcudart.so* /usr/lib/wsl/drivers/*/libcudart.so* /opt/cuda/lib64/libcudart.so* /usr/local/cuda*/targets/aarch64-linux/lib/libcudart.so* /usr/lib/aarch64-linux-gnu/nvidia/current/libcudart.so* /usr/lib/aarch64-linux-gnu/libcudart.so* /usr/local/cuda/lib*/libcudart.so* /usr/lib*/libcudart.so* /usr/local/lib*/libcudart.so*]" time=2024-10-21T13:35:53.452Z level=DEBUG source=gpu.go:562 msg="discovered GPU libraries" paths="[/usr/lib/ollama/libcudart.so.12.4.99 /usr/lib/ollama/libcudart.so.11.3.109]" cudaSetDevice err: 3 time=2024-10-21T13:35:53.457Z level=DEBUG source=gpu.go:578 msg="Unable to load cudart library /usr/lib/ollama/libcudart.so.12.4.99: cudart init failure: 3" cudaSetDevice err: 3 time=2024-10-21T13:35:53.462Z level=DEBUG source=gpu.go:578 msg="Unable to load cudart library /usr/lib/ollama/libcudart.so.11.3.109: cudart init failure: 3" time=2024-10-21T13:35:53.462Z level=DEBUG source=amd_linux.go:416 msg="amdgpu driver not detected /sys/module/amdgpu" time=2024-10-21T13:35:53.462Z level=INFO source=gpu.go:384 msg="no compatible GPUs were discovered" time=2024-10-21T13:35:53.462Z level=INFO source=types.go:123 msg="inference compute" id=0 library=cpu variant=avx2 compute="" driver=0.0 name="" total="15.6 GiB" available="9.9 GiB"` When I run some LLM action, it always shows below information(100% CPU in processor field and the model was loaded by CPU): <img width="949" alt="image" src="https://github.com/user-attachments/assets/fd73106d-48ab-4048-b94f-76c8ca80d858"> **Operation System:** <img width="523" alt="image" src="https://github.com/user-attachments/assets/60de1337-cdbb-47bb-965b-1f415ab98e63"> if any more information needed please let me know. Thank you in advanced. ### OS Linux ### GPU Nvidia ### CPU Intel ### Ollama version 0.3.14
GiteaMirror added the bugdockernvidia labels 2026-05-09 13:42:55 -05:00
Author
Owner

@rick-github commented on GitHub (Oct 21, 2024):

Did your machine recently do a suspend/resume cycle? If so, try:

sudo rmmod nvidia_uvm
sudo modprobe nvidia_uvm
<!-- gh-comment-id:2426911870 --> @rick-github commented on GitHub (Oct 21, 2024): Did your machine recently do a suspend/resume cycle? If so, try: ``` sudo rmmod nvidia_uvm sudo modprobe nvidia_uvm ```
Author
Owner

@dhiltgen commented on GitHub (Oct 21, 2024):

It looks like the error we're hitting from the nvidia driver is:

    /**
     * This indicates that the CUDA driver has not been initialized with
     * ::cuInit() or that initialization has failed.
     */
    CUDA_ERROR_NOT_INITIALIZED                = 3,

If the command Rick suggested above don't clear it up, also check dmesg for any errors from the nvidia drivers.

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

<!-- gh-comment-id:2427904083 --> @dhiltgen commented on GitHub (Oct 21, 2024): It looks like the error we're hitting from the nvidia driver is: ``` /** * This indicates that the CUDA driver has not been initialized with * ::cuInit() or that initialization has failed. */ CUDA_ERROR_NOT_INITIALIZED = 3, ``` If the command Rick suggested above don't clear it up, also check `dmesg` for any errors from the nvidia drivers. https://github.com/ollama/ollama/blob/main/docs/troubleshooting.md#linux-nvidia-troubleshooting
Author
Owner

@wangqiang-kubota commented on GitHub (Oct 22, 2024):

@rick-github @dhiltgen Thank you for the reply, I found the root cause. My Linux is a virtual machine. Although I successfully installed CUDA and ran nvidia-smi command inside the virtual machine, it seems that the GPU still cannot be passed through. So after deploying the Ollama container on the physical machine, everything worked properly, and the GPU could be used as expected. Thank you both for your help!

<!-- gh-comment-id:2428222452 --> @wangqiang-kubota commented on GitHub (Oct 22, 2024): @rick-github @dhiltgen Thank you for the reply, I found the root cause. My Linux is a virtual machine. Although I successfully installed CUDA and ran nvidia-smi command inside the virtual machine, it seems that the GPU still cannot be passed through. So after deploying the Ollama container on the physical machine, everything worked properly, and the GPU could be used as expected. Thank you both for your help!
Author
Owner

@wangqiang-kubota commented on GitHub (Oct 22, 2024):

My issue fixed. So closed

<!-- gh-comment-id:2428226330 --> @wangqiang-kubota commented on GitHub (Oct 22, 2024): My issue fixed. So closed
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#82319