[GH-ISSUE #2781] Specifying GPU Usage on Linux Systems #1677

Closed
opened 2026-04-12 11:39:03 -05:00 by GiteaMirror · 0 comments
Owner

Originally created by @rongkunxue on GitHub (Feb 27, 2024).
Original GitHub issue: https://github.com/ollama/ollama/issues/2781

Originally assigned to: @dhiltgen on GitHub.

To check if the "ollama serve" process is running, execute ps aux | grep "ollama serve". If the output matches the status shown below, it indicates normal operation. image-20240227214151610. However, if it's automatically started by the system, specifying the GPU becomes problematic.

To address this, we need to first stop the automatic startup service:

sudo service ollama stop

Then, set the location of the models as an environment variable:

export OLLAMA_MODELS=/usr/share/ollama/.ollama/models

Now, start the server:

CUDA_VISIBLE_DEVICES=0 ollama serve

Following these steps should resolve the issue.

If you lack permission to stop the system's automatic service, you can include the HOST parameter in the CUDA_VISIBLE_DEVICES=0 ollama serve command to change the IP address, effectively creating two instances.

For further reference, please check the following GitHub resources:

Originally created by @rongkunxue on GitHub (Feb 27, 2024). Original GitHub issue: https://github.com/ollama/ollama/issues/2781 Originally assigned to: @dhiltgen on GitHub. To check if the "ollama serve" process is running, execute `ps aux | grep "ollama serve"`. If the output matches the status shown below, it indicates normal operation. ![image-20240227214151610](https://p.ipic.vip/o8qagv.png). However, if it's automatically started by the system, specifying the GPU becomes problematic. To address this, we need to first stop the automatic startup service: ``` sudo service ollama stop ``` Then, set the location of the models as an environment variable: ``` export OLLAMA_MODELS=/usr/share/ollama/.ollama/models ``` Now, start the server: ``` CUDA_VISIBLE_DEVICES=0 ollama serve ``` Following these steps should resolve the issue. If you lack permission to stop the system's automatic service, you can include the `HOST` parameter in the `CUDA_VISIBLE_DEVICES=0 ollama serve` command to change the IP address, effectively creating two instances. For further reference, please check the following GitHub resources: - [GitHub Issue #690](https://github.com/ollama/ollama/issues/690) - [API Documentation](https://github.com/ollama/ollama/blob/main/docs/api.md) - [GitHub Issue #1737](https://github.com/ollama/ollama/issues/1737)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#1677