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-completion 38SEED =0 39GPUS_SETTING ="" 40 41INPUT_PROMPT ="Building a website can be done in 10 simple steps:\nStep 1:" 42MODEL_FILE =../models/llama-2-7b.Q4_0.gguf 43NGL =99 44CONTEXT =4096 45GGML_SYCL_DEVICE =-1 46SYCL_DEVICES ="SYCL0" 47SPLIT_MODE =layer 48LOG_VERBOSE =3 49while [[$ # -gt 0 ]];do 50case " $ 1 " in 51 -d| --device) 52SYCL_DEVICES =" $ 2 " 53shift 54shift 55 ;; 56 -c| --context) 57CONTEXT =$ 2 58# Shift twice to consume both the option flag and its value 59shift 60shift 61 ;; 62 -p| --promote) 63# Option that is a simple flag (boolean) 64INPUT_PROMPT =" $ 2 " 65# Shift once to consume the option flag 66shift 67shift 68 ;; 69 -m| --model) 70MODEL_FILE =" $ 2 " 71# Shift twice to consume both the option flag and its value 72shift 73shift 74 ;; 75 -mg| --main-gpu) 76GGML_SYCL_DEVICE =$ 2 77SPLIT_MODE =none 78# Shift twice to consume both the option flag and its value 79shift 80shift 81 ;; 82 -sm| --split-mode) 83SPLIT_MODE =$ 2 84# Shift twice to consume both the option flag and its value 85shift 86shift 87 ;; 88 -ngl| --n-gpu-layers) 89NGL =$ 2 90# Shift twice to consume both the option flag and its value 91shift 92shift 93 ;; 94 -lv| --log-verbosity) 95LOG_VERBOSE =$ 2 96# Shift twice to consume both the option flag and its value 97shift 98shift 99 ;; 100 -h| --help) 101Help 102exit 0 103 ;; 104 *) 105# Handle unknown options or stop processing options 106echo "Invalid option: $ 1 " 107# Optional: exit script or shift to treat remaining as positional args 108exit 1 109 ;; 110esac 111done 112 113 114 115source /opt/intel/oneapi/setvars.sh 116 117#export GGML_SYCL_DEBUG=1 118 119#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. 120 121#support malloc device memory more than 4GB. 122export UR_L0_ENABLE_RELAXED_ALLOCATION_LIMITS =1 123echo "UR_L0_ENABLE_RELAXED_ALLOCATION_LIMITS= ${ UR_L0_ENABLE_RELAXED_ALLOCATION_LIMITS } " 124 125echo "ONEAPI_DEVICE_SELECTOR= ${ ONEAPI_DEVICE_SELECTOR } " 126 127if [$ GGML_SYCL_DEVICE -ne -1 ];then 128echo "Use $ GGML_SYCL_DEVICE as main GPU" 129#use signle GPU only 130GPUS_SETTING ="-mg $ GGML_SYCL_DEVICE -sm ${ SPLIT_MODE } " 131else 132echo "Use Intel GPUs: ${ SYCL_DEVICES } " 133GPUS_SETTING ="-sm ${ SPLIT_MODE } " 134fi 135 136echo "run cmd: ZES_ENABLE_SYSMAN=1 ${ BIN_FILE } -m ${ MODEL_FILE } -no-cnv -p " ${ INPUT_PROMPT } " -n 200 -e -ngl ${ NGL } -s ${ SEED } -c ${ CONTEXT } ${ GPUS_SETTING } -lv ${ LOG_VERBOSE } --device ${ SYCL_DEVICES } --load-mode auto " 137ZES_ENABLE_SYSMAN =1${ BIN_FILE } -m ${ MODEL_FILE } -no-cnv -p " ${ INPUT_PROMPT } " -n 200-e -ngl ${ NGL } -s ${ SEED } -c ${ CONTEXT } ${ GPUS_SETTING } -lv ${ LOG_VERBOSE } --device ${ SYCL_DEVICES } --load-mode auto 138