#!/bin/bash
#SBATCH --job-name=Ollama-case
#SBATCH --partition=ampere
#SBATCH --time=20:00
#SBATCH --nodes=1
#SBATCH --gres=gpu:1
#SBATCH --output=output.log

module load ollama

# Create a temp directory
export TMPDIR=$SCRATCH/ollama_tmp
mkdir -p $TMPDIR

# Start Ollama service
ollama serve &> serve_ollama_${SLURM_JOBID}.log &

# Wait until Ollama service has been started
sleep 20

# Run Ollama using llama2 model
time ollama run llama2 "How do you schedule a job with slurm?"

# Terminate Ollama service
killall ollama

