char-fork/llama.cpp

git clone https://git.t4t.associates/char-fork/llama.cpp

Fathi Boudracommon: migrate the deprecated --mmap/--no-mmap to --load-mode (#26934)0177dcc73

char/aliceai-t5-moe
4.0 KiB130 linesraw
1#!/bin/bash
2
3#  MIT license
4#  Copyright (C) 2024 Intel Corporation
5#  SPDX-License-Identifier: MIT
6
7Help() {
8  cat << EOF
9Usage: $(basename "$0") [OPTIONS]
10
11This script processes files with specified options.
12
13Options:
14  -h, --help    Display this help message and exit.
15  -d, --device  <value>    Set SYCL devices (default: SYCL0).
16  -c, --context <value>    Set context length. Bigger need more memory.
17  -p, --promote <value>    Prompt to start generation with.
18  -m, --model   <value>    Full model file path.
19  -mg,--main-gpu <value>   Set main GPU ID (0 - n) for single GPU mode.
20  -sm,--split-mode <value> How to split the model across multiple GPUs, one of:
21                            - none: use one GPU only
22                            - layer (default): split layers and KV across GPUs
23                            - row: split rows across GPUs
24  -ngl,--n-gpu-layers <value>  Max. number of layers to store in VRAM (default: -1)
25  -lv,--log-verbosity <value>  Set the verbosity threshold. Messages with a higher verbosity will be
26                               ignored. Values:
27                                - 0: generic output
28                                - 1: error
29                                - 2: warning
30                                - 3: info
31                                - 4: debug
32
33
34EOF
35}
36
37BIN_FILE=./build/bin/llama-server
38SEED=0
39GPUS_SETTING=""
40
41MODEL_FILE=../models/Qwen3.5-4B-Q4_0.gguf
42NGL=99
43CONTEXT=4096
44GGML_SYCL_DEVICE=-1
45SYCL_DEVICES="SYCL0"
46SPLIT_MODE=layer
47LOG_VERBOSE=3
48while [[ $# -gt 0 ]]; do
49    case "$1" in
50        -d|--device)
51            SYCL_DEVICES="$2"
52            shift
53            shift
54            ;;
55        -c|--context)
56            CONTEXT=$2
57            # Shift twice to consume both the option flag and its value
58            shift
59            shift
60            ;;
61        -m|--model)
62            MODEL_FILE="$2"
63            # Shift twice to consume both the option flag and its value
64            shift
65            shift
66            ;;
67        -mg|--main-gpu)
68            GGML_SYCL_DEVICE=$2
69            SPLIT_MODE=none
70            # Shift twice to consume both the option flag and its value
71            shift
72            shift
73            ;;
74        -sm|--split-mode)
75            SPLIT_MODE=$2
76            # Shift twice to consume both the option flag and its value
77            shift
78            shift
79            ;;
80        -ngl|--n-gpu-layers)
81            NGL=$2
82            # Shift twice to consume both the option flag and its value
83            shift
84            shift
85            ;;
86        -lv|--log-verbosity)
87            LOG_VERBOSE=$2
88            # Shift twice to consume both the option flag and its value
89            shift
90            shift
91            ;;
92        -h|--help)
93            Help
94            exit 0
95            ;;
96        *)
97            # Handle unknown options or stop processing options
98            echo "Invalid option: $1"
99            # Optional: exit script or shift to treat remaining as positional args
100            exit 1
101            ;;
102    esac
103done
104
105source /opt/intel/oneapi/setvars.sh
106
107#export GGML_SYCL_DEBUG=1
108
109#ZES_ENABLE_SYSMAN=1, Support to get free memory of GPU by sycl::aspect::ext_intel_free_memory. Recommended to use when --split-mode = layer.
110
111#support malloc device memory more than 4GB.
112export UR_L0_ENABLE_RELAXED_ALLOCATION_LIMITS=1
113echo "UR_L0_ENABLE_RELAXED_ALLOCATION_LIMITS=${UR_L0_ENABLE_RELAXED_ALLOCATION_LIMITS}"
114
115echo "ONEAPI_DEVICE_SELECTOR=${ONEAPI_DEVICE_SELECTOR}"
116
117
118if [ $GGML_SYCL_DEVICE -ne -1 ]; then
119    echo "Use $GGML_SYCL_DEVICE as main GPU"
120    #use signle GPU only
121    GPUS_SETTING="-mg $GGML_SYCL_DEVICE -sm ${SPLIT_MODE}"
122else
123    echo "Use Intel GPUs: ${SYCL_DEVICES}"
124    GPUS_SETTING="-sm ${SPLIT_MODE}"
125fi
126
127echo "run cmd: ZES_ENABLE_SYSMAN=1 ${BIN_FILE} -m ${MODEL_FILE} -ngl ${NGL} -s ${SEED} -c ${CONTEXT} ${GPUS_SETTING} -lv ${LOG_VERBOSE} --device ${SYCL_DEVICES} --load-mode auto --host 0.0.0.0 --port 8000"
128ZES_ENABLE_SYSMAN=1 ${BIN_FILE} -m ${MODEL_FILE} -ngl ${NGL} -s ${SEED} -c ${CONTEXT} ${GPUS_SETTING} -lv ${LOG_VERBOSE} --device ${SYCL_DEVICES} --load-mode auto --host 0.0.0.0 --port 8000
129
130