llama
This commit is contained in:
3
.env.example
Normal file
3
.env.example
Normal file
@@ -0,0 +1,3 @@
|
||||
TAILSCALE_HOSTNAME=gpu-node
|
||||
TS_AUTHKEY=
|
||||
LLAMA_MODELS_PATH=./gpu/llama_models
|
||||
30
.gitignore
vendored
Normal file
30
.gitignore
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
# SSH
|
||||
ssh/authorized_keys
|
||||
|
||||
# Tailscale
|
||||
tailscale/state/
|
||||
tailscale/config/
|
||||
|
||||
# GPU models / generated data
|
||||
gpu/llama_models/*
|
||||
gpu/comfy/models/*
|
||||
gpu/comfy/input/*
|
||||
gpu/comfy/output/*
|
||||
gpu/comfy/custom_nodes/*
|
||||
gpu/comfy/user/*
|
||||
gpu/comfy/run/*
|
||||
|
||||
# Environment / secrets
|
||||
.env
|
||||
*.env
|
||||
|
||||
# Python
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
.venv/
|
||||
|
||||
# OS / IDE
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
.idea/
|
||||
.vscode/
|
||||
25
START_GPU_NODE.bat
Normal file
25
START_GPU_NODE.bat
Normal file
@@ -0,0 +1,25 @@
|
||||
@echo off
|
||||
cd /d "%~dp0"
|
||||
|
||||
echo ========================================
|
||||
echo SALEM AI GPU NODE
|
||||
echo ========================================
|
||||
echo.
|
||||
|
||||
echo Starting Docker services...
|
||||
docker compose up -d
|
||||
|
||||
if errorlevel 1 (
|
||||
echo.
|
||||
echo ERROR: Failed to start GPU node.
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo.
|
||||
echo GPU node started successfully.
|
||||
echo.
|
||||
docker ps --filter "name=gpu-node-"
|
||||
|
||||
echo.
|
||||
pause
|
||||
84
compose.yaml
Normal file
84
compose.yaml
Normal file
@@ -0,0 +1,84 @@
|
||||
name: gpu-node
|
||||
|
||||
services:
|
||||
tailscale:
|
||||
image: tailscale/tailscale:latest
|
||||
container_name: gpu-node-tailscale
|
||||
|
||||
hostname: ${TAILSCALE_HOSTNAME:-gpu-node}
|
||||
|
||||
environment:
|
||||
TS_AUTHKEY: ${TS_AUTHKEY}
|
||||
TS_STATE_DIR: /var/lib/tailscale
|
||||
TS_SERVE_CONFIG: /config/serve.json
|
||||
|
||||
volumes:
|
||||
- ./tailscale/state:/var/lib/tailscale
|
||||
- ./tailscale/config:/config:ro
|
||||
|
||||
networks:
|
||||
- gpu-node
|
||||
|
||||
restart: unless-stopped
|
||||
|
||||
ssh:
|
||||
build:
|
||||
context: ./ssh
|
||||
|
||||
container_name: gpu-node-ssh
|
||||
hostname: ssh-operator
|
||||
|
||||
volumes:
|
||||
- ./ssh/authorized_keys:/mounted-authorized-keys:ro
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
- ./:/project:ro
|
||||
|
||||
networks:
|
||||
- gpu-node
|
||||
|
||||
restart: unless-stopped
|
||||
|
||||
gpu-test:
|
||||
profiles:
|
||||
- test
|
||||
build:
|
||||
context: ./gpu
|
||||
|
||||
container_name: gpu-node-gpu-test
|
||||
|
||||
gpus: all
|
||||
|
||||
networks:
|
||||
- gpu-node
|
||||
|
||||
restart: "no"
|
||||
|
||||
llama:
|
||||
profiles:
|
||||
- llama
|
||||
|
||||
image: ghcr.io/ggml-org/llama.cpp:server-cuda
|
||||
|
||||
container_name: gpu-node-llama
|
||||
|
||||
gpus: all
|
||||
|
||||
volumes:
|
||||
- ${LLAMA_MODELS_HOST:-./gpu/llama_models}:/models
|
||||
|
||||
command:
|
||||
- --host
|
||||
- 0.0.0.0
|
||||
- --port
|
||||
- "8080"
|
||||
- --model
|
||||
- /models/model.gguf
|
||||
|
||||
networks:
|
||||
- gpu-node
|
||||
|
||||
restart: "no"
|
||||
|
||||
networks:
|
||||
gpu-node:
|
||||
name: gpu-node
|
||||
3
gpu/Dockerfile
Normal file
3
gpu/Dockerfile
Normal file
@@ -0,0 +1,3 @@
|
||||
FROM nvidia/cuda:12.8.1-base-ubuntu24.04
|
||||
|
||||
CMD ["nvidia-smi"]
|
||||
31
ssh/Dockerfile
Normal file
31
ssh/Dockerfile
Normal file
@@ -0,0 +1,31 @@
|
||||
FROM alpine:3.22
|
||||
|
||||
RUN apk add --no-cache \
|
||||
openssh-server \
|
||||
docker-cli \
|
||||
docker-cli-compose \
|
||||
&& addgroup -g 1001 docker-host \
|
||||
&& adduser -D -s /bin/sh operator \
|
||||
&& adduser operator docker-host \
|
||||
&& passwd -d operator \
|
||||
&& mkdir -p /home/operator/.ssh \
|
||||
&& ssh-keygen -A
|
||||
|
||||
RUN printf '%s\n' \
|
||||
'PasswordAuthentication no' \
|
||||
'KbdInteractiveAuthentication no' \
|
||||
'PubkeyAuthentication yes' \
|
||||
'PermitRootLogin no' \
|
||||
>> /etc/ssh/sshd_config
|
||||
|
||||
COPY entrypoint.sh /entrypoint.sh
|
||||
COPY gpuctl /usr/local/bin/gpuctl
|
||||
|
||||
RUN sed -i 's/\r$//' /usr/local/bin/gpuctl \
|
||||
&& chmod +x /entrypoint.sh /usr/local/bin/gpuctl
|
||||
|
||||
RUN chmod +x /entrypoint.sh /usr/local/bin/gpuctl
|
||||
|
||||
EXPOSE 22
|
||||
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
10
ssh/entrypoint.sh
Normal file
10
ssh/entrypoint.sh
Normal file
@@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
cp /mounted-authorized-keys /home/operator/.ssh/authorized_keys
|
||||
|
||||
chown -R operator:operator /home/operator/.ssh
|
||||
chmod 700 /home/operator/.ssh
|
||||
chmod 600 /home/operator/.ssh/authorized_keys
|
||||
|
||||
exec /usr/sbin/sshd -D -e
|
||||
138
ssh/gpuctl
Normal file
138
ssh/gpuctl
Normal file
@@ -0,0 +1,138 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -eu
|
||||
|
||||
PROJECT_DIR="/project"
|
||||
|
||||
get_host_project_dir() {
|
||||
docker inspect gpu-node-ssh \
|
||||
--format '{{range .Mounts}}{{if eq .Destination "/project"}}{{.Source}}{{end}}{{end}}'
|
||||
}
|
||||
|
||||
case "${1:-}" in
|
||||
|
||||
status)
|
||||
docker ps \
|
||||
--filter "name=gpu-node-" \
|
||||
--format 'table {{.Names}}\t{{.Status}}\t{{.Ports}}'
|
||||
;;
|
||||
|
||||
start)
|
||||
case "${2:-}" in
|
||||
|
||||
llama)
|
||||
cd "$PROJECT_DIR"
|
||||
|
||||
HOST_PROJECT_DIR="$(get_host_project_dir)"
|
||||
|
||||
if [ -z "$HOST_PROJECT_DIR" ]; then
|
||||
echo "ERROR: cannot determine host project directory"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Starting llama..."
|
||||
echo "Models: $HOST_PROJECT_DIR/gpu/llama_models"
|
||||
|
||||
LLAMA_MODELS_HOST="$HOST_PROJECT_DIR/gpu/llama_models" \
|
||||
docker compose --profile llama up -d llama
|
||||
|
||||
echo
|
||||
docker ps \
|
||||
--filter "name=gpu-node-llama" \
|
||||
--format 'table {{.Names}}\t{{.Status}}\t{{.Ports}}'
|
||||
;;
|
||||
|
||||
comfy)
|
||||
cd "$PROJECT_DIR"
|
||||
|
||||
HOST_PROJECT_DIR="$(get_host_project_dir)"
|
||||
|
||||
if [ -z "$HOST_PROJECT_DIR" ]; then
|
||||
echo "ERROR: cannot determine host project directory"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Starting ComfyUI..."
|
||||
echo "Models: $HOST_PROJECT_DIR/gpu/comfy_models"
|
||||
|
||||
COMFY_MODELS_HOST="$HOST_PROJECT_DIR/gpu/comfy_models" \
|
||||
docker compose --profile comfy up -d comfyui
|
||||
|
||||
echo
|
||||
docker ps \
|
||||
--filter "name=gpu-node-comfyui" \
|
||||
--format 'table {{.Names}}\t{{.Status}}\t{{.Ports}}'
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Usage: gpuctl start {llama|comfy}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
|
||||
stop)
|
||||
case "${2:-}" in
|
||||
|
||||
llama)
|
||||
docker stop gpu-node-llama
|
||||
;;
|
||||
|
||||
comfy)
|
||||
docker stop gpu-node-comfyui
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Usage: gpuctl stop {llama|comfy}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
|
||||
restart)
|
||||
case "${2:-}" in
|
||||
|
||||
llama)
|
||||
docker restart gpu-node-llama
|
||||
;;
|
||||
|
||||
comfy)
|
||||
docker restart gpu-node-comfyui
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Usage: gpuctl restart {llama|comfy}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
|
||||
logs)
|
||||
case "${2:-}" in
|
||||
|
||||
llama)
|
||||
docker logs --tail 100 gpu-node-llama
|
||||
;;
|
||||
|
||||
comfy)
|
||||
docker logs --tail 100 gpu-node-comfyui
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Usage: gpuctl logs {llama|comfy}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Usage:"
|
||||
echo " gpuctl status"
|
||||
echo " gpuctl start {llama|comfy}"
|
||||
echo " gpuctl stop {llama|comfy}"
|
||||
echo " gpuctl restart {llama|comfy}"
|
||||
echo " gpuctl logs {llama|comfy}"
|
||||
exit 1
|
||||
;;
|
||||
|
||||
esac
|
||||
Reference in New Issue
Block a user