char-fork/llama.cpp
git clone https://git.t4t.associates/char-fork/llama.cpp
0177dcc73
char/aliceai-t5-moe
1#!/bin/bash 2 3# MIT license 4# Copyright (C) 2024 Intel Corporation 5# SPDX-License-Identifier: MIT 6 7Help () { 8cat <<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 26ignored. 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 49case " $ 1 " in 50 -d| --device) 51SYCL_DEVICES =" $ 2 " 52shift 53shift 54 ;; 55 -c| --context) 56CONTEXT =$ 2 57# Shift twice to consume both the option flag and its value 58shift 59shift 60 ;; 61 -m| --model) 62MODEL_FILE =" $ 2 " 63# Shift twice to consume both the option flag and its value 64shift 65shift 66 ;; 67 -mg| --main-gpu) 68GGML_SYCL_DEVICE =$ 2 69SPLIT_MODE =none 70# Shift twice to consume both the option flag and its value 71shift 72shift 73 ;; 74 -sm| --split-mode) 75SPLIT_MODE =$ 2 76# Shift twice to consume both the option flag and its value 77shift 78shift 79 ;; 80 -ngl| --n-gpu-layers) 81NGL =$ 2 82# Shift twice to consume both the option flag and its value 83shift 84shift 85 ;; 86 -lv| --log-verbosity) 87LOG_VERBOSE =$ 2 88# Shift twice to consume both the option flag and its value 89shift 90shift 91 ;; 92 -h| --help) 93Help 94exit 0 95 ;; 96 *) 97# Handle unknown options or stop processing options 98echo "Invalid option: $ 1 " 99# Optional: exit script or shift to treat remaining as positional args 100exit 1 101 ;; 102esac 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 119echo "Use $ GGML_SYCL_DEVICE as main GPU" 120#use signle GPU only 121GPUS_SETTING ="-mg $ GGML_SYCL_DEVICE -sm ${ SPLIT_MODE } " 122else 123echo "Use Intel GPUs: ${ SYCL_DEVICES } " 124GPUS_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