#!/bin/sh # Entrypoint for the ollama service under docker-compose.demo.yml: one line # that says whether this container can see a GPU, then `ollama serve`. # # Honest about what it can know: whether a device is passed through and the # backend switched on. Whether ollama USES it is ollama's own # `inference compute ... library=…` line, which follows — `./docker/demo.sh up` # reads that one back. # # POSIX sh (the ollama image's /bin/sh). set -eu DRI_DIR="${OLLAMA_START_DRI_DIR:-/dev/dri}" log() { printf '[ollama] %s\n' "$*"; } render_nodes() { for n in "${DRI_DIR}"/renderD*; do [ -e "$n" ] && printf '%s ' "${n##*/}" done return 0 } nodes="$(render_nodes)" if [ -n "${nodes}" ]; then if [ "${OLLAMA_VULKAN:-}" = "1" ]; then log "gpu: ${nodes}passed through, OLLAMA_VULKAN=1 — the \"inference compute\" line below names the device" else log "gpu: ${nodes}passed through, but OLLAMA_VULKAN is not 1 — ollama will not use it (docker-compose.ollama-vulkan.yml sets it)" fi elif command -v nvidia-smi >/dev/null 2>&1 && nvidia-smi -L >/dev/null 2>&1; then log "gpu: NVIDIA $(nvidia-smi -L 2>/dev/null | head -n 1)" else log "gpu: NONE in this container — models run on the CPU, about 10x slower (docker-compose.ollama-vulkan.yml passes a GPU through)" fi log "cloud: OLLAMA_NO_CLOUD=${OLLAMA_NO_CLOUD:-unset}" log "bounds: parallel ${OLLAMA_NUM_PARALLEL:-default}, loaded models ${OLLAMA_MAX_LOADED_MODELS:-default}, keep-alive ${OLLAMA_KEEP_ALIVE:-default}, prompt cache ${LLAMA_ARG_CACHE_RAM:-default} MiB" exec "${OLLAMA_START_BIN:-/bin/ollama}" serve