provision.sh A developer published a bash provisioning script for Vast.ai that automates first-boot setup of a ComfyUI environment, cloning the ComfyUI repository, installing prebuilt llama-cpp-python and FlashAttention wheels, downloading a set of MiniMax-H3 models and LoRAs from Hugging Face, and pulling ten custom nodes. The script wraps installs and downloads in a three-attempt retry helper with 5- and 10-second backoff, falls back between uv and pip or hf commands, and records missing prerequisites such as the virtualenv or uv in a failures array. | | /usr/bin/env bash | | | Vast.ai ComfyUI first-boot provisioning script. | | | Set PROVISIONING SCRIPT to the public raw URL for this file. | | | set -uo pipefail | | | WORKSPACE="${WORKSPACE:-/workspace}" | | | COMFYUI DIR="${WORKSPACE}/ComfyUI" | | | COMFYUI REPO URL="${COMFYUI REPO URL:-https://github.com/Comfy-Org/ComfyUI.git}" | | | COMFYUI BRANCH="${COMFYUI BRANCH:-master}" | | | MODELS DIR="${COMFYUI DIR}/models" | | | VENV PYTHON="/venv/main/bin/python" | | | export HF HUB DOWNLOAD TIMEOUT="${HF HUB DOWNLOAD TIMEOUT:-60}" | | | export HF HUB ETAG TIMEOUT="${HF HUB ETAG TIMEOUT:-30}" | | | WHEEL URLS= | | | "https://github.com/JamePeng/llama-cpp-python/releases/download/v0.3.49-cu131-linux-20260831/llama cpp python-0.3.49+cu131-cp312-cp312-linux x86 64.whl" | | | "https://github.com/mjun0812/flash-attention-prebuild-wheels/releases/download/v0.9.0/flash attn-2.8.3+cu130torch2.10-cp312-cp312-linux x86 64.whl" | | | | | | MODEL DOWNLOADS= | | | "hf://lightx2v/Minimax-h3-Turbo/minimax h3 fl2v turbo 8step v1.0 comfyui bf16.safetensors\|loras" | | | "hf://Comfy-Org/MiniMax-H3/vae/minimax h3 audio vae fp32.safetensors\|vae" | | | "hf://Kijai/MiniMax-H3-experimental/minimax h3 video vae int8 convrot.safetensors\|vae" | | | "hf://Comfy-Org/MiniMax-H3/loras/minimax h3 ref2v turbo 4step v0.1 comfyui bf16.safetensors\|loras" | | | "hf://Momoking/Qwen3-VL-32B-Heretic-MiniMax-H3-NVFP4/qwen3vl 32b heretic minimax h3 nvfp4.safetensors\|text encoders" | | | "hf://Comfy-Org/MiniMax-H3/diffusion models/minimax h3 ref2va int8 convrot.safetensors\|diffusion models" | | | "hf://TenStrip/10Eros-Max/10Eros Max h3 TURBO-hybrid beta5 int8.safetensors\|diffusion models" | | | "hf://larryvrh/MiniMax-H3-Turbo-Lora/minimax h3 turbo v4 step600 ema.safetensors\|loras" | | | | | | CUSTOM NODES= | | | "https://github.com/city96/ComfyUI-GGUF.git" | | | "https://github.com/rgthree/rgthree-comfy.git" | | | "https://github.com/pytraveler/MiniMax-H3-Prompt-Rewriter-ComfyUI.git" | | | "https://github.com/willmiao/ComfyUI-Lora-Manager.git" | | | "https://github.com/pythongosssss/ComfyUI-Custom-Scripts.git" | | | "https://github.com/kijai/ComfyUI-KJNodes.git" | | | "https://github.com/yolain/ComfyUI-Easy-Use.git" | | | "https://github.com/Comfy-Org/Nvidia RTX Nodes ComfyUI.git" | | | "https://github.com/Kosinkadink/ComfyUI-VideoHelperSuite.git" | | | "https://github.com/dreevelle/ComfyUI-ResolutionTools.git" | | | "https://github.com/vrgamegirl19/comfyui-vrgamedevgirl.git" | | | "https://github.com/owner/ComfyUI-Custom-Node.git" | | | | | | failures= | | | Three attempts, with 5- and 10-second delays between failures. | | | retry { | | | local attempt | | | for attempt in 1 2 3; do | | | if "$@"; then | | | return 0 | | | fi | | | if attempt < 3 ; then | | | echo "Warning: attempt ${attempt}/3 failed; retrying in $ attempt 5 seconds." | | | sleep "$ attempt 5 " | | | fi | | | done | | | return 1 | | | } | | | if -f /venv/main/bin/activate ; then | | | shellcheck disable=SC1091 | | | source /venv/main/bin/activate | | | else | | | echo "Warning: /venv/main/bin/activate was not found." | | | failures+= "main virtual environment" | | | fi | | | if command -v uv /dev/null 2 &1; then | | | HF COMMAND= uv tool run hf | | | elif command -v hf /dev/null 2 &1; then | | | echo "Warning: uv was not found; using the existing hf command." | | | failures+= "uv" | | | HF COMMAND= hf | | | else | | | echo "Warning: neither uv nor hf was found; model downloads will fail." | | | failures+= "uv and hf" | | | HF COMMAND= hf | | | fi | | | if command -v uv /dev/null 2 &1; then | | | PIP COMMAND= uv pip install --python "${VENV PYTHON}" | | | else | | | PIP COMMAND= "${VENV PYTHON}" -m pip install | | | fi | | | echo "Updating ComfyUI to latest ${COMFYUI BRANCH} ..." | | | COMFYUI GIT= git -c safe.directory=' ' -C "${COMFYUI DIR}" | | | comfyui updated=false | | | if -d "${COMFYUI DIR}/.git" ; then | | | if retry "${COMFYUI GIT @ }" fetch origin "+refs/heads/${COMFYUI BRANCH}:refs/remotes/origin/${COMFYUI BRANCH}" && \ | | | "${COMFYUI GIT @ }" checkout -f -B "${COMFYUI BRANCH}" "refs/remotes/origin/${COMFYUI BRANCH}"; then | | | comfyui updated=true | | | else | | | echo "Warning: failed to update ComfyUI in ${COMFYUI DIR}; continuing." | | | failures+= "ComfyUI update" | | | fi | | | elif -e "${COMFYUI DIR}" ; then | | | if retry git clone --branch "${COMFYUI BRANCH}" "${COMFYUI REPO URL}" "${COMFYUI DIR}"; then | | | comfyui updated=true | | | else | | | echo "Warning: failed to clone ComfyUI into ${COMFYUI DIR}; continuing." | | | failures+= "ComfyUI clone" | | | fi | | | else | | | echo "Warning: ${COMFYUI DIR} exists but is not a git repository; skipping ComfyUI update." | | | failures+= "ComfyUI update not a git repo " | | | fi | | | if "${comfyui updated}" == true ; then | | | comfyui commit="$ "${COMFYUI GIT @ }" rev-parse --short HEAD 2 /dev/null \|\| true " | | | if -n "${comfyui commit}" ; then | | | echo "ComfyUI is now at ${comfyui commit}." | | | fi | | | if -f "${COMFYUI DIR}/requirements.txt" ; then | | | echo "Installing ComfyUI requirements..." | | | if retry "${PIP COMMAND @ }" -r "${COMFYUI DIR}/requirements.txt"; then | | | echo "Warning: failed to install ComfyUI requirements; continuing." | | | failures+= "ComfyUI requirements" | | | fi | | | fi | | | if -f "${COMFYUI DIR}/manager requirements.txt" && \ | | | -x "${VENV PYTHON}" && \ | | | "${VENV PYTHON}" -c "import importlib.metadata; importlib.metadata.version 'comfyui-manager' " /dev/null 2 &1; then | | | echo "Installing ComfyUI Manager requirements..." | | | if retry "${PIP COMMAND @ }" -r "${COMFYUI DIR}/manager requirements.txt"; then | | | echo "Warning: failed to install ComfyUI Manager requirements; continuing." | | | failures+= "ComfyUI Manager requirements" | | | fi | | | fi | | | fi | | | for entry in "${MODEL DOWNLOADS @ }"; do | | | uri="${entry%%\| }" | | | model subdir="${entry \|}" | | | destination="${MODELS DIR}/${model subdir}" | | | hf preserves repository paths. Avoid vae/vae, loras/loras, etc. | | | repo path="${uri hf://}" | | | repo path="${repo path /}" | | | repo path="${repo path /}" | | | download dir="${destination}" | | | if "${repo path}" == "${model subdir}/" ; then | | | download dir="${MODELS DIR}" | | | fi | | | if mkdir -p "${destination}"; then | | | failures+= "${uri}: destination directory" | | | continue | | | fi | | | echo "Downloading ${uri} to ${destination}" | | | if retry "${HF COMMAND @ }" download "${uri}" --local-dir "${download dir}"; then | | | echo "Warning: download failed; continuing with the next model." | | | failures+= "${uri}" | | | fi | | | done | | | Install prebuilt CUDA wheels before custom-node requirements so pip/uv | | | does not try to compile packages like llama-cpp-python from source. | | | for wheel url in "${WHEEL URLS @ }"; do | | | echo "Installing wheel ${wheel url /}" | | | if retry "${PIP COMMAND @ }" "${wheel url}"; then | | | echo "Warning: wheel installation failed; continuing." | | | failures+= "${wheel url /}" | | | fi | | | done | | | CUSTOM NODES DIR="${COMFYUI DIR}/custom nodes" | | | mkdir -p "${CUSTOM NODES DIR}" | | | for repo url in "${CUSTOM NODES @ }"; do | | | node name="${repo url%/}" | | | node name="${node name /}" | | | node name="${node name%.git}" | | | node dir="${CUSTOM NODES DIR}/${node name}" | | | if -d "${node dir}/.git" ; then | | | echo "Custom node ${node name} already exists; skipping clone." | | | elif retry git clone "${repo url}" "${node dir}"; then | | | echo "Warning: failed to clone ${repo url}; continuing." | | | failures+= "${repo url}" | | | continue | | | fi | | | node requirements="${node dir}/requirements.txt" | | | if -f "${node requirements}" ; then | | | echo "Installing requirements for ${node name}..." | | | if retry "${PIP COMMAND @ }" -r "${node requirements}"; then | | | echo "Warning: failed to install requirements for ${node name}; continuing." | | | failures+= "${node name} requirements" | | | fi | | | fi | | | done | | | if ${ failures @ } 0 ; then | | | echo | | | echo "Provisioning finished with ${ failures @ } warning s :" | | | printf ' - %s\n' "${failures @ }" | | | else | | | echo "Provisioning completed successfully." | | | fi | | | Always succeed so one unavailable download or custom node does not stop setup. | | | exit 0 |