Add new LXC: Ollama (#3979)
This commit is contained in:
parent
5ae25108ef
commit
af0376f25b
3 changed files with 170 additions and 2 deletions
72
ct/ollama.sh
Normal file
72
ct/ollama.sh
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func)
|
||||||
|
# Copyright (c) 2021-2024 tteck
|
||||||
|
# Author: tteck
|
||||||
|
# Co-Author: havardthom
|
||||||
|
# License: MIT
|
||||||
|
# https://github.com/tteck/Proxmox/raw/main/LICENSE
|
||||||
|
|
||||||
|
function header_info {
|
||||||
|
clear
|
||||||
|
cat <<"EOF"
|
||||||
|
____ ____
|
||||||
|
/ __ \/ / /___ _____ ___ ____ _
|
||||||
|
/ / / / / / __ `/ __ `__ \/ __ `/
|
||||||
|
/ /_/ / / / /_/ / / / / / / /_/ /
|
||||||
|
\____/_/_/\__,_/_/ /_/ /_/\__,_/
|
||||||
|
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
header_info
|
||||||
|
echo -e "Loading..."
|
||||||
|
APP="Ollama"
|
||||||
|
var_disk="24"
|
||||||
|
var_cpu="4"
|
||||||
|
var_ram="4096"
|
||||||
|
var_os="ubuntu"
|
||||||
|
var_version="22.04"
|
||||||
|
variables
|
||||||
|
color
|
||||||
|
catch_errors
|
||||||
|
|
||||||
|
function default_settings() {
|
||||||
|
CT_TYPE="1"
|
||||||
|
PW=""
|
||||||
|
CT_ID=$NEXTID
|
||||||
|
HN=$NSAPP
|
||||||
|
DISK_SIZE="$var_disk"
|
||||||
|
CORE_COUNT="$var_cpu"
|
||||||
|
RAM_SIZE="$var_ram"
|
||||||
|
BRG="vmbr0"
|
||||||
|
NET="dhcp"
|
||||||
|
GATE=""
|
||||||
|
APT_CACHER=""
|
||||||
|
APT_CACHER_IP=""
|
||||||
|
DISABLEIP6="no"
|
||||||
|
MTU=""
|
||||||
|
SD=""
|
||||||
|
NS=""
|
||||||
|
MAC=""
|
||||||
|
VLAN=""
|
||||||
|
SSH="no"
|
||||||
|
VERB="no"
|
||||||
|
echo_default
|
||||||
|
}
|
||||||
|
|
||||||
|
function update_script() {
|
||||||
|
header_info
|
||||||
|
if [[ ! -d /opt/ollama ]]; then msg_error "No ${APP} Installation Found!"; exit; fi
|
||||||
|
msg_info "Updating ${APP}"
|
||||||
|
apt-get update &>/dev/null
|
||||||
|
apt-get -y upgrade &>/dev/null
|
||||||
|
msg_ok "Updated Successfully"
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
|
||||||
|
start
|
||||||
|
build_container
|
||||||
|
description
|
||||||
|
|
||||||
|
msg_ok "Completed Successfully!\n"
|
||||||
|
echo -e "${APP} should be reachable by going to the following URL.
|
||||||
|
${BL}http://${IP}:11434${CL} \n"
|
96
install/ollama-install.sh
Normal file
96
install/ollama-install.sh
Normal file
|
@ -0,0 +1,96 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Copyright (c) 2021-2024 tteck
|
||||||
|
# Author: tteck
|
||||||
|
# Co-Author: havardthom
|
||||||
|
# License: MIT
|
||||||
|
# https://github.com/tteck/Proxmox/raw/main/LICENSE
|
||||||
|
|
||||||
|
source /dev/stdin <<< "$FUNCTIONS_FILE_PATH"
|
||||||
|
color
|
||||||
|
verb_ip6
|
||||||
|
catch_errors
|
||||||
|
setting_up_container
|
||||||
|
network_check
|
||||||
|
update_os
|
||||||
|
|
||||||
|
msg_info "Installing Dependencies"
|
||||||
|
$STD apt-get install -y curl
|
||||||
|
$STD apt-get install -y sudo
|
||||||
|
$STD apt-get install -y mc
|
||||||
|
$STD apt-get install -y gpg
|
||||||
|
$STD apt-get install -y git
|
||||||
|
$STD apt-get install -y build-essential
|
||||||
|
$STD apt-get install -y pkg-config
|
||||||
|
$STD apt-get install -y cmake
|
||||||
|
msg_ok "Installed Dependencies"
|
||||||
|
|
||||||
|
msg_info "Installing Golang"
|
||||||
|
$STD wget https://golang.org/dl/go1.23.2.linux-amd64.tar.gz
|
||||||
|
$STD tar -xzf go1.23.2.linux-amd64.tar.gz -C /usr/local
|
||||||
|
$STD ln -s /usr/local/go/bin/go /usr/local/bin/go
|
||||||
|
rm -rf go1.23.2.linux-amd64.tar.gz
|
||||||
|
msg_ok "Installed Golang"
|
||||||
|
|
||||||
|
msg_info "Setting up Intel® Repositories"
|
||||||
|
mkdir -p /etc/apt/keyrings
|
||||||
|
curl -fsSL https://repositories.intel.com/gpu/intel-graphics.key | gpg --dearmor -o /etc/apt/keyrings/intel-graphics.gpg
|
||||||
|
echo "deb [arch=amd64,i386 signed-by=/etc/apt/keyrings/intel-graphics.gpg] https://repositories.intel.com/gpu/ubuntu jammy client" >/etc/apt/sources.list.d/intel-gpu-jammy.list
|
||||||
|
curl -fsSL https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB | gpg --dearmor -o /etc/apt/keyrings/oneapi-archive-keyring.gpg
|
||||||
|
echo "deb [signed-by=/etc/apt/keyrings/oneapi-archive-keyring.gpg] https://apt.repos.intel.com/oneapi all main" >/etc/apt/sources.list.d/oneAPI.list
|
||||||
|
$STD apt-get update
|
||||||
|
msg_ok "Set up Intel® Repositories"
|
||||||
|
|
||||||
|
msg_info "Setting Up Hardware Acceleration"
|
||||||
|
$STD apt-get -y install {va-driver-all,ocl-icd-libopencl1,intel-opencl-icd,vainfo,intel-gpu-tools,intel-level-zero-gpu,level-zero,level-zero-dev}
|
||||||
|
if [[ "$CTTYPE" == "0" ]]; then
|
||||||
|
chgrp video /dev/dri
|
||||||
|
chmod 755 /dev/dri
|
||||||
|
chmod 660 /dev/dri/*
|
||||||
|
$STD adduser $(id -u -n) video
|
||||||
|
$STD adduser $(id -u -n) render
|
||||||
|
fi
|
||||||
|
msg_ok "Set Up Hardware Acceleration"
|
||||||
|
|
||||||
|
msg_info "Installing Intel® oneAPI Base Toolkit (Patience)"
|
||||||
|
$STD apt-get install -y --no-install-recommends intel-basekit-2024.1
|
||||||
|
msg_ok "Installed Intel® oneAPI Base Toolkit"
|
||||||
|
|
||||||
|
msg_info "Installing Ollama (Patience)"
|
||||||
|
$STD git clone https://github.com/ollama/ollama.git /opt/ollama
|
||||||
|
cd /opt/ollama
|
||||||
|
$STD go generate ./...
|
||||||
|
$STD go build .
|
||||||
|
msg_ok "Installed Ollama"
|
||||||
|
|
||||||
|
msg_info "Creating Service"
|
||||||
|
cat <<EOF >/etc/systemd/system/ollama.service
|
||||||
|
[Unit]
|
||||||
|
Description=Ollama Service
|
||||||
|
After=network-online.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=exec
|
||||||
|
ExecStart=/opt/ollama/ollama serve
|
||||||
|
Environment=HOME=$HOME
|
||||||
|
Environment=OLLAMA_INTEL_GPU=true
|
||||||
|
Environment=OLLAMA_HOST=0.0.0.0
|
||||||
|
Environment=OLLAMA_NUM_GPU=999
|
||||||
|
Environment=SYCL_CACHE_PERSISTENT=1
|
||||||
|
Environment=ZES_ENABLE_SYSMAN=1
|
||||||
|
Restart=always
|
||||||
|
RestartSec=3
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
EOF
|
||||||
|
systemctl enable -q --now ollama.service
|
||||||
|
msg_ok "Created Service"
|
||||||
|
|
||||||
|
motd_ssh
|
||||||
|
customize
|
||||||
|
|
||||||
|
msg_info "Cleaning up"
|
||||||
|
$STD apt-get -y autoremove
|
||||||
|
$STD apt-get -y autoclean
|
||||||
|
msg_ok "Cleaned"
|
|
@ -588,7 +588,7 @@ EOF
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$CT_TYPE" == "0" ]; then
|
if [ "$CT_TYPE" == "0" ]; then
|
||||||
if [[ "$APP" == "Channels" || "$APP" == "Emby" || "$APP" == "ErsatzTV" || "$APP" == "Frigate" || "$APP" == "Jellyfin" || "$APP" == "Plex" || "$APP" == "Scrypted" || "$APP" == "Tdarr" || "$APP" == "Unmanic" ]]; then
|
if [[ "$APP" == "Channels" || "$APP" == "Emby" || "$APP" == "ErsatzTV" || "$APP" == "Frigate" || "$APP" == "Jellyfin" || "$APP" == "Plex" || "$APP" == "Scrypted" || "$APP" == "Tdarr" || "$APP" == "Unmanic" || "$APP" == "Ollama" ]]; then
|
||||||
cat <<EOF >>$LXC_CONFIG
|
cat <<EOF >>$LXC_CONFIG
|
||||||
# VAAPI hardware transcoding
|
# VAAPI hardware transcoding
|
||||||
lxc.cgroup2.devices.allow: c 226:0 rwm
|
lxc.cgroup2.devices.allow: c 226:0 rwm
|
||||||
|
@ -600,7 +600,7 @@ lxc.mount.entry: /dev/dri/renderD128 dev/dri/renderD128 none bind,optional,creat
|
||||||
EOF
|
EOF
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
if [[ "$APP" == "Channels" || "$APP" == "Emby" || "$APP" == "ErsatzTV" || "$APP" == "Frigate" || "$APP" == "Jellyfin" || "$APP" == "Plex" || "$APP" == "Scrypted" || "$APP" == "Tdarr" || "$APP" == "Unmanic" ]]; then
|
if [[ "$APP" == "Channels" || "$APP" == "Emby" || "$APP" == "ErsatzTV" || "$APP" == "Frigate" || "$APP" == "Jellyfin" || "$APP" == "Plex" || "$APP" == "Scrypted" || "$APP" == "Tdarr" || "$APP" == "Unmanic" || "$APP" == "Ollama" ]]; then
|
||||||
if [[ -e "/dev/dri/renderD128" ]]; then
|
if [[ -e "/dev/dri/renderD128" ]]; then
|
||||||
if [[ -e "/dev/dri/card0" ]]; then
|
if [[ -e "/dev/dri/card0" ]]; then
|
||||||
cat <<EOF >>$LXC_CONFIG
|
cat <<EOF >>$LXC_CONFIG
|
||||||
|
|
Loading…
Reference in a new issue