[GH-ISSUE #2277] How to set ROCR_VISIBLE_DEVICES to 0 #1309

Closed
opened 2026-04-12 11:08:10 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @meminens on GitHub (Jan 30, 2024).
Original GitHub issue: https://github.com/ollama/ollama/issues/2277

Originally assigned to: @dhiltgen on GitHub.

I have installed ollama (v0.1.22) and ROCm (v5.7.1) to Arch Linux via the following commands

pacman -S ollama rocm-hip-sdk rocm-opencl-sdk clblast
systemctl daemon-reload
systemctl enable ollama.service
systemctl start ollama.service

and then run

ollama run mistral

Checking htop and nvtop, I see that only CPU is being used.

Ollama log in journalctl -u ollama shows the following:

Searching for GPU management library libnvidia-ml.so
Discovered GPU libraries: []
Searching for GPU management library librocm_smi64.so
Discovered GPU libraries: [/opt/rocm/lib/librocm_smi64.so.5.0]
Radeon GPU detected
ROCm integrated GPU detected - ROCR_VISIBLE_DEVICES=1

I believe the ROCR_VISIBLE_DEVICES parameter should be set to 0.

My system info is below:

                   -`                    misaligar@arch 
                  .o+`                   --------- 
                 `ooo/                   OS: Arch Linux x86_64 
                `+oooo:                  Host: B650 AORUS ELITE AX 
               `+oooooo:                 Kernel: 6.7.2-arch1-1 
               -+oooooo+:                Uptime: 18 mins 
             `/:-:++oooo+:               Packages: 1065 (pacman), 7 (flatpak) 
            `/++++/+++++++:              Shell: bash 5.2.26 
           `/++++++++++++++:             Resolution: 2560x1440 
          `/+++ooooooooooooo/`           DE: Plasma 5.27.10 
         ./ooosssso++osssssso+`          WM: kwin 
        .oossssso-````/ossssss+`         Theme: [Plasma], Breeze [GTK2/3] 
       -osssssso.      :ssssssso.        Icons: kora [Plasma], kora [GTK2/3] 
      :osssssss/        osssso+++.       Terminal: konsole 
     /ossssssss/        +ssssooo/-       Terminal Font: Hack Nerd Font Mono 10 
   `/ossssso+/:-        -:/+osssso+-     CPU: AMD Ryzen 9 7900X (24) @ 5.733GHz 
  `+sso+:-`                 `.-/+oso:    GPU: AMD ATI 13:00.0 Raphael 
 `++:.                           `-/+/   GPU: AMD ATI Radeon RX 7900 XT/7900 XTX 
 .`                                 `/   Memory: 4811MiB / 63438MiB 

How can I tell ollama to use the external GPU?

Originally created by @meminens on GitHub (Jan 30, 2024). Original GitHub issue: https://github.com/ollama/ollama/issues/2277 Originally assigned to: @dhiltgen on GitHub. I have installed ollama (v0.1.22) and ROCm (v5.7.1) to Arch Linux via the following commands ``` pacman -S ollama rocm-hip-sdk rocm-opencl-sdk clblast systemctl daemon-reload systemctl enable ollama.service systemctl start ollama.service ``` and then run `ollama run mistral` Checking `htop` and `nvtop`, I see that only CPU is being used. Ollama log in `journalctl -u ollama` shows the following: ``` Searching for GPU management library libnvidia-ml.so Discovered GPU libraries: [] Searching for GPU management library librocm_smi64.so Discovered GPU libraries: [/opt/rocm/lib/librocm_smi64.so.5.0] Radeon GPU detected ROCm integrated GPU detected - ROCR_VISIBLE_DEVICES=1 ``` I believe the `ROCR_VISIBLE_DEVICES` parameter should be set to `0`. My system info is below: ``` -` misaligar@arch .o+` --------- `ooo/ OS: Arch Linux x86_64 `+oooo: Host: B650 AORUS ELITE AX `+oooooo: Kernel: 6.7.2-arch1-1 -+oooooo+: Uptime: 18 mins `/:-:++oooo+: Packages: 1065 (pacman), 7 (flatpak) `/++++/+++++++: Shell: bash 5.2.26 `/++++++++++++++: Resolution: 2560x1440 `/+++ooooooooooooo/` DE: Plasma 5.27.10 ./ooosssso++osssssso+` WM: kwin .oossssso-````/ossssss+` Theme: [Plasma], Breeze [GTK2/3] -osssssso. :ssssssso. Icons: kora [Plasma], kora [GTK2/3] :osssssss/ osssso+++. Terminal: konsole /ossssssss/ +ssssooo/- Terminal Font: Hack Nerd Font Mono 10 `/ossssso+/:- -:/+osssso+- CPU: AMD Ryzen 9 7900X (24) @ 5.733GHz `+sso+:-` `.-/+oso: GPU: AMD ATI 13:00.0 Raphael `++:. `-/+/ GPU: AMD ATI Radeon RX 7900 XT/7900 XTX .` `/ Memory: 4811MiB / 63438MiB ``` How can I tell ollama to use the external GPU?
Author
Owner

@dhiltgen commented on GitHub (Jan 31, 2024):

Please run the server with OLLAMA_DEBUG=1 and attach the logs of the early startup so we can see why it's selecting the wrong GPU.

As a workaround until this is fixed, if you set ROCR_VISIBLE_DEVICES=0 explicitly before starting the server, it should respect your setting.

<!-- gh-comment-id:1919500648 --> @dhiltgen commented on GitHub (Jan 31, 2024): Please run the server with `OLLAMA_DEBUG=1` and attach the logs of the early startup so we can see why it's selecting the wrong GPU. As a workaround until this is fixed, if you set `ROCR_VISIBLE_DEVICES=0` explicitly before starting the server, it should respect your setting.
Author
Owner

@meminens commented on GitHub (Jan 31, 2024):

This is probably related to https://github.com/ollama/ollama/issues/2165. Feel free to close this issue if you agree.

<!-- gh-comment-id:1919812646 --> @meminens commented on GitHub (Jan 31, 2024): This is probably related to https://github.com/ollama/ollama/issues/2165. Feel free to close this issue if you agree.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#1309