Elffuss BraidHub

kikocis/llama-stack public

main · 1.3 KiB · executableRawPermalink
1#!/bin/bash
2
3# Copyright (c) Meta Platforms, Inc. and affiliates.
4# All rights reserved.
5#
6# This source code is licensed under the terms described in the LICENSE file in
7# the root directory of this source tree.
8
9DOCKER_BINARY=${DOCKER_BINARY:-docker}
10DOCKER_OPTS=${DOCKER_OPTS:-}
11LLAMA_CHECKPOINT_DIR=${LLAMA_CHECKPOINT_DIR:-}
12
13set -euo pipefail
14
15RED='\033[0;31m'
16NC='\033[0m' # No Color
17
18error_handler() {
19 echo "Error occurred in script at line: ${1}" >&2
20 exit 1
21}
22
23trap 'error_handler ${LINENO}' ERR
24
25if [ $# -lt 3 ]; then
26 echo "Usage: $0 <build_name> <yaml_config> <port> <other_args...>"
27 exit 1
28fi
29
30build_name="$1"
31docker_image="llamastack-$build_name"
32shift
33
34yaml_config="$1"
35shift
36
37port="$1"
38shift
39
40set -x
41
42if [ -n "$LLAMA_CHECKPOINT_DIR" ]; then
43 $DOCKER_BINARY run $DOCKER_OPTS -it \
44 -p $port:$port \
45 -v "$yaml_config:/app/config.yaml" \
46 -v "$LLAMA_CHECKPOINT_DIR:/root/.llama" \
47 --gpus=all \
48 $docker_image \
49 python -m llama_stack.distribution.server.server \
50 --yaml_config /app/config.yaml \
51 --port $port "$@"
52fi
53
54if [ -z "$LLAMA_CHECKPOINT_DIR" ]; then
55 $DOCKER_BINARY run $DOCKER_OPTS -it \
56 -p $port:$port \
57 -v "$yaml_config:/app/config.yaml" \
58 $docker_image \
59 python -m llama_stack.distribution.server.server \
60 --yaml_config /app/config.yaml \
61 --port $port "$@"
62fi