diff --git a/README.md b/README.md index 50d09e0..2150d4f 100644 --- a/README.md +++ b/README.md @@ -84,16 +84,32 @@ To use Llama.cpp with hardware acceleration inside a toolbox container, you must > * Extra groups (`video`, `render`, `sudo`) may be required for full access to GPU nodes and compute features, especially with ROCm. > * Use `--security-opt seccomp=unconfined` to avoid seccomp sandbox issues (needed for some GPU syscalls). -#### 2.1.1 Updating boxes +Here’s how you can **integrate usage of the refresh script** into your README, following the concise, direct style of the original: -If you want to make sure to get updated version of the toolboxes, always pull the new image and delete any existing box: -```sh -podman pull docker.io/kyuz0/amd-strix-halo-toolboxes:vulkan-amdvlk -toolbox rm -f llama-vulkan-amdvlk +### 2.1.1 Toolbox Refresh Script (Automatic Updates) + +To pull the latest container images and recreate toolboxes cleanly, use the provided script: + +#### 📦 `refresh-toolboxes.sh` + +```bash +./refresh-toolboxes.sh all ``` -### 2.2 Running models inside the toolboxes +This will: + +1. Delete existing toolboxes (if any) +2. Pull the latest images from DockerHub +3. Recreate each toolbox with correct GPU access flags + +You can also refresh just one or more toolboxes: + +```bash +./refreshtoolboxes.sh llama-vulkan-amdvlk llama-rocm-6.4.2 +``` + +### 2.2 Running models inside the toolboxes Before running any commands, you must first enter your toolbox container shell using: diff --git a/refresh-toolboxes.sh b/refresh-toolboxes.sh new file mode 100644 index 0000000..8512775 --- /dev/null +++ b/refresh-toolboxes.sh @@ -0,0 +1,69 @@ +#!/usr/bin/env bash + +set -e + +# List of all known toolboxes and their configurations +declare -A TOOLBOXES + +TOOLBOXES["llama-vulkan-amdvlk"]="docker.io/kyuz0/amd-strix-halo-toolboxes:vulkan-amdvlk --device /dev/dri --group-add video --security-opt seccomp=unconfined" +TOOLBOXES["llama-vulkan-radv"]="docker.io/kyuz0/amd-strix-halo-toolboxes:vulkan-radv --device /dev/dri --group-add video --security-opt seccomp=unconfined" +TOOLBOXES["llama-rocm-6.4.2"]="docker.io/kyuz0/amd-strix-halo-toolboxes:rocm-6.4.2 --device /dev/dri --device /dev/kfd --group-add video --group-add render --group-add sudo --security-opt seccomp=unconfined" +TOOLBOXES["llama-rocm-7beta"]="docker.io/kyuz0/amd-strix-halo-toolboxes:rocm-7beta --device /dev/dri --device /dev/kfd --group-add video --group-add render --group-add sudo --security-opt seccomp=unconfined" +TOOLBOXES["llama-rocm-7rc"]="docker.io/kyuz0/amd-strix-halo-toolboxes:rocm-7rc --device /dev/dri --device /dev/kfd --group-add video --group-add render --group-add sudo --security-opt seccomp=unconfined" + +function usage() { + echo "Usage: $0 [all|toolbox-name1 toolbox-name2 ...]" + echo "Available toolboxes:" + for name in "${!TOOLBOXES[@]}"; do + echo " - $name" + done + exit 1 +} + +# Check dependencies +for cmd in podman toolbox; do + command -v "$cmd" > /dev/null || { echo "Error: '$cmd' is not installed." >&2; exit 1; } +done + +if [ "$#" -lt 1 ]; then + usage +fi + +# Determine which toolboxes to refresh +if [ "$1" = "all" ]; then + SELECTED_TOOLBOXES=("${!TOOLBOXES[@]}") +else + SELECTED_TOOLBOXES=() + for arg in "$@"; do + if [[ -v TOOLBOXES["$arg"] ]]; then + SELECTED_TOOLBOXES+=("$arg") + else + echo "Error: Unknown toolbox '$arg'" + usage + fi + done +fi + +# Loop through selected toolboxes +for name in "${SELECTED_TOOLBOXES[@]}"; do + config="${TOOLBOXES[$name]}" + image=$(echo "$config" | awk '{print $1}') + options="${config#* }" + + echo "🔄 Refreshing $name (image: $image)" + + # Remove the toolbox if it exists + if toolbox list | grep -q "$name"; then + echo "🧹 Removing existing toolbox: $name" + toolbox rm -f "$name" + fi + + echo "⬇️ Pulling latest image: $image" + podman pull "$image" + + echo "📦 Recreating toolbox: $name" + toolbox create "$name" --image "$image" -- $options + + echo "✅ $name refreshed" + echo +done