muryshev commited on
Commit
0e004c7
·
verified ·
1 Parent(s): 608d0ea

Update run.sh

Browse files
Files changed (1) hide show
  1. run.sh +66 -1
run.sh CHANGED
@@ -1,2 +1,67 @@
1
  #!/bin/bash
2
- /app/server -m /data/model.gguf -c 4096 -ngl 60 --port 7860 --host 0.0.0.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  #!/bin/bash
2
+
3
+ N_GPU_LAYERS="${N_GPU_LAYERS:-20}"
4
+ MODEL_PATH="${MODEL_PATH:-/data/mixtral-8x7b-instruct-v0.1.Q2_K.gguf}"
5
+ MODEL_URL="${MODEL_URL:-https://huggingface.co/TheBloke/Mixtral-8x7B-Instruct-v0.1-GGUF/resolve/main/mixtral-8x7b-instruct-v0.1.Q2_K.gguf}"
6
+ PORT="${PORT:-7867}"
7
+ CONTEXT="${CONTEXT:-30000}"
8
+
9
+ # Function to print download progress
10
+ print_progress() {
11
+ local percentage=$1
12
+ echo "Download progress: $percentage%"
13
+ }
14
+
15
+ calculate_progress() {
16
+ local current=$1
17
+ local total=$2
18
+ echo "scale=2; $current / $total * 100" | bc
19
+ }
20
+
21
+ # Check if the file exists
22
+ if [ ! -e "$MODEL_PATH" ]; then
23
+ echo "Downloading model."
24
+ # If the file doesn't exist, download it using curl with redirects
25
+ headers=$(curl -sI -L "$MODEL_URL")
26
+
27
+ # Extract the final location from the headers
28
+ final_url=$(echo "$headers" | grep -i '^location:' | awk '{print $2}' | tr -d '\r\n')
29
+
30
+ if [ -z "$final_url" ]; then
31
+ echo "Failed to determine the final URL after following redirects."
32
+ exit 1
33
+ fi
34
+
35
+ # Download the file with the final URL
36
+ {
37
+ echo "Download started from $final_url"
38
+ total_size=$(curl --head --location "$final_url" | grep -i 'Content-Length' | awk '{print $2}' | tr -d '\r\n')
39
+ downloaded_size=0
40
+
41
+ curl --location --output "$MODEL_PATH" "$final_url" \
42
+ --progress-bar \
43
+ --write-out "%{size_download}\n" | \
44
+ while read -r size; do
45
+ downloaded_size=$((downloaded_size + size))
46
+ progress=$(calculate_progress "$downloaded_size" "$total_size")
47
+
48
+ # Print progress messages every 10%
49
+ if (( $(echo "$progress % 10 == 0" | bc -l) )); then
50
+ print_progress "$progress"
51
+ fi
52
+ done
53
+
54
+ echo "Download completed from $final_url"
55
+ } | awk '
56
+ /^Download progress:/ {
57
+ print $0;
58
+ fflush();
59
+ }
60
+ '
61
+
62
+ echo "File downloaded successfully from $final_url."
63
+ else
64
+ echo "File already exists."
65
+ fi
66
+ cd /app
67
+ ./server -m "$MODEL_PATH" -c $CONTEXT --port $PORT --host 0.0.0.0 --n-gpu-layers $N_GPU_LAYERS --path "/app/public"