From f3f98cc23e884458486ad7e696420aba1a991c42 Mon Sep 17 00:00:00 2001 From: RomanNum3ral Date: Mon, 29 Sep 2025 12:29:24 +0000 Subject: [PATCH] Update 02-ollama_install_v2.sh --- 02-ollama_install_v2.sh | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/02-ollama_install_v2.sh b/02-ollama_install_v2.sh index f6b43ec..e4db664 100644 --- a/02-ollama_install_v2.sh +++ b/02-ollama_install_v2.sh @@ -1,6 +1,10 @@ #!/bin/bash set -euo pipefail +# Always run relative to this script's folder (so compose file is found) +SCRIPT_DIR="$(cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P)" +cd "$SCRIPT_DIR" + # --- System prep --- sudo apt update sudo apt -y upgrade @@ -11,7 +15,10 @@ sudo apt install -y build-essential dkms linux-headers-generic # --- NVIDIA driver (auto-select) --- sudo ubuntu-drivers install --gpgpu -# Optional but recommended: reboot here so the new kernel/driver settle +# Strongly recommended: reboot here so the new kernel/driver settle, +# then re-run this script to do the rest. +# exit 0 +# OR uncomment to auto-reboot now (and rerun manually after boot): # sudo reboot # --- Docker Engine + Compose --- @@ -30,16 +37,37 @@ sudo apt install -y nvidia-container-toolkit sudo nvidia-ctk runtime configure --runtime=docker sudo systemctl restart docker +# Optional: verify driver is live (helps catch Secure Boot/MOK issues) +if ! command -v nvidia-smi >/dev/null 2>&1 || ! nvidia-smi >/dev/null 2>&1; then + echo "Warning: NVIDIA driver not loaded yet (Secure Boot? reboot needed?). GPU in containers may not work." +fi + # --- Ollama (host install; runs on 127.0.0.1:11434) --- -curl -fsSL https://ollama.com/install.sh | sh +if ! command -v ollama >/dev/null 2>&1; then + curl -fsSL https://ollama.com/install.sh | sh +fi # --- OpenWebUI via Compose (talks to host Ollama) --- mkdir -p "$HOME/docker-compose-files/open_web_ui" -mv docker-compose.yaml "$HOME/docker-compose-files/open_web_ui" + +# Copy (don't move) the compose file that sits next to this script. +# -n avoids overwriting an existing file. +if [ -f "$SCRIPT_DIR/docker-compose.yaml" ]; then + cp -n "$SCRIPT_DIR/docker-compose.yaml" "$HOME/docker-compose-files/open_web_ui/docker-compose.yaml" +elif [ -f "$SCRIPT_DIR/docker-compose.yml" ]; then + cp -n "$SCRIPT_DIR/docker-compose.yml" "$HOME/docker-compose-files/open_web_ui/docker-compose.yml" +fi + cd "$HOME/docker-compose-files/open_web_ui" + +# Validate compose before launch +sudo docker compose config >/dev/null + +# Bring it up sudo docker compose up -d # --- Models (ensure Ollama service is running) --- +# (These will fail the script if a model name is wrong due to -e) ollama pull codellama:7b ollama pull qwen2-math:7b ollama pull llama3:8b \ No newline at end of file