[GH-ISSUE #9408] how to use slurm to run the Ollama service. #6133

Open
opened 2026-04-12 17:28:43 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @jjxyhb on GitHub (Feb 28, 2025).
Original GitHub issue: https://github.com/ollama/ollama/issues/9408

I want to configure ollama on a specific node and gpu in a lenovo lico cluster Thanks

Originally created by @jjxyhb on GitHub (Feb 28, 2025). Original GitHub issue: https://github.com/ollama/ollama/issues/9408 I want to configure ollama on a specific node and gpu in a lenovo lico cluster Thanks
GiteaMirror added the question label 2026-04-12 17:28:43 -05:00
Author
Owner

@flywiththetide commented on GitHub (Mar 4, 2025):

You can run Ollama on a specific node and GPU in a Slurm-managed cluster by using a Slurm job script. Here’s how to do it:

1. Create a Slurm Job Script (run_ollama.sh)

Create a Slurm script to request a specific node and GPU:

#!/bin/bash
#SBATCH --job-name=ollama-job
#SBATCH --partition=gpu
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=1
#SBATCH --gres=gpu:1
#SBATCH --constraint=YOUR_GPU_MODEL
#SBATCH --output=ollama_output.log
#SBATCH --error=ollama_error.log

# Load necessary modules
module load cuda/12.1

# Activate the environment if needed
source ~/.bashrc
conda activate ollama_env  # or source venv/bin/activate

# Run Ollama server
ollama serve

2. Submit the Job

Submit the script using:

sbatch run_ollama.sh

This will:

  • Request one GPU on an available node.
  • Log outputs to ollama_output.log.
  • Ensure Ollama runs with GPU acceleration.

3. Verify GPU Allocation

Once the job is running, check GPU usage with:

squeue --user=$USER
srun --jobid=<JOB_ID> nvidia-smi

Let me know if you need help adjusting this for specific GPUs or multi-node execution!

<!-- gh-comment-id:2696234241 --> @flywiththetide commented on GitHub (Mar 4, 2025): You can run Ollama on a **specific node and GPU** in a Slurm-managed cluster by using a Slurm job script. Here’s how to do it: ### **1. Create a Slurm Job Script (`run_ollama.sh`)** Create a Slurm script to request a **specific node and GPU**: ```bash #!/bin/bash #SBATCH --job-name=ollama-job #SBATCH --partition=gpu #SBATCH --nodes=1 #SBATCH --ntasks-per-node=1 #SBATCH --gres=gpu:1 #SBATCH --constraint=YOUR_GPU_MODEL #SBATCH --output=ollama_output.log #SBATCH --error=ollama_error.log # Load necessary modules module load cuda/12.1 # Activate the environment if needed source ~/.bashrc conda activate ollama_env # or source venv/bin/activate # Run Ollama server ollama serve ``` ### **2. Submit the Job** Submit the script using: ```bash sbatch run_ollama.sh ``` This will: - **Request one GPU** on an available node. - **Log outputs** to `ollama_output.log`. - **Ensure Ollama runs** with GPU acceleration. ### **3. Verify GPU Allocation** Once the job is running, check GPU usage with: ```bash squeue --user=$USER srun --jobid=<JOB_ID> nvidia-smi ``` Let me know if you need help adjusting this for **specific GPUs or multi-node execution**!
Author
Owner

@giuliofrey commented on GitHub (Jun 12, 2025):

I created a template that might be useful for others that come to this issue. You can find it here

<!-- gh-comment-id:2966859796 --> @giuliofrey commented on GitHub (Jun 12, 2025): I created a template that might be useful for others that come to this issue. You can find it [here](https://github.com/giuliofrey/slurm_ollama)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#6133