Update 02-ollama_install_v2.sh

This commit is contained in:
RomanNum3ral 2025-09-29 12:15:44 +00:00
parent d3091536a2
commit 1dd140dc04
1 changed files with 31 additions and 37 deletions

View File

@ -1,46 +1,40 @@
#!/usr/bin/env bash
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
trap 'echo "[ERROR] Line ${LINENO}: command failed"; exit 1' ERR
sudo apt update
sudo apt upgrade -y
sudo apt install -y linux-headers-$(uname -r) build-essential dkms
ARCH=$(uname -m)
case "$ARCH" in
x86_64|aarch64|arm64) ;;
*)
echo "[FATAL] Unsupported architecture: $ARCH"
exit 2
;;
esac
sudo apt purge -y 'cuda-drivers*' 'nvidia-driver-*server*' || true
if command -v apt >/dev/null 2>&1; then
PKG="curl ca-certificates"
sudo apt-get update -y
sudo apt-get install -y $PKG
fi
sudo ubuntu-drivers install --gpgpu
sudo apt install -y nvidia-container-toolkit
sudo nvidia-ctk runtime configure --runtime=docker && sudo systemctl restart docker
echo "[STEP] Installing Ollama (official one-liner)"
# Ollama
curl -fsSL https://ollama.com/install.sh | sh
echo "[STEP] Ensuring ollama service is running"
if command -v systemctl >/dev/null 2>&1; then
sudo systemctl enable --now ollama || true
sudo systemctl status --no-pager ollama || true
else
# Non-systemd: try launching in background
nohup ollama serve >/var/log/ollama-serve.log 2>&1 &
sleep 2
fi
# Docker Engine + Compose
sudo apt-get update
sudo apt-get install -y ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo tee /etc/apt/keyrings/docker.asc >/dev/null
sudo chmod a+r /etc/apt/keyrings/docker.asc
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] \
https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" \
| sudo tee /etc/apt/sources.list.d/docker.list >/dev/null
sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
echo "[STEP] Testing API on localhost:11434"
for i in {1..10}; do
if curl -fsS http://127.0.0.1:11434/api/version >/dev/null 2>&1; then
echo "[OK] Ollama API is reachable."
exit 0
fi
sleep 1
done
# Run Docker without sudo from now on
sudo usermod -aG docker $USER && newgrp docker
echo "[WARN] Ollama API not reachable yet. Check logs: journalctl -u ollama -e"
exit 0
# Option B: compose file
mkdir -p ~/docker-compose-files/open_web_ui && cd ~/docker-compose-files/open_web_ui
wget https://wget-pulls.fortis-scientia.com/open_web_ui.yaml
sudo docker compose -f open_web_ui.yaml up -d
# Pull models (note: llama3.3:70b is huge; ensure VRAM/disk)
ollama pull llama3:8b
ollama pull codellama:7b
ollama pull qwen2-math:7b