Repository navigation
Expand file tree
/
Copy pathdocker-compose.yaml
More file actions
148 lines (127 loc) 路 6.31 KB
/
Copy pathdocker-compose.yaml
File metadata and controls
148 lines (127 loc) 路 6.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
services:
tabby:
container_name: tabby-vulkan
image: ubuntu:24.04
privileged: true # Required for direct hardware access in some AMD environments
user: "0:0"
environment:
# --- TABBY CORE SETTINGS ---
- TABBY_ROOT=/var/lib/tabby
- TABBY_DISABLE_TELEMETRY=1 # disable telemetry for privacy
# it didn't work!!
# - TABBY_CONFIG_FILE=/var/lib/tabby/config.toml
- RUST_LOG=info
- tabby=debug
# set timezone to Asia/Seoul
- TZ=Asia/Seoul
# --- VULKAN AND AMD GPU SETTINGS ---
- GGML_VULKAN=1
# vulkan ICD file's value of "library_path" is relative path in my environment, so we generate icd.json file in entrypoint by dynamic dispath
# - VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/radeon_icd.json
- LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libvulkan.so.1:/usr/lib/x86_64-linux-gnu/libdl.so.2
- LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu
- LIBGL_DRIVERS_PATH=/usr/lib/x86_64-linux-gnu/dri
# Performance & Stability tweaks for RADV
- RADV_DEBUG=nocache,nooutoforder
- MESA_VK_WSI_PRESENT_MODE=immediate
# Debugging (Uncomment if you encounter issues)
# - GGML_VULKAN_DEBUG=1
# - VK_LOADER_DEBUG=all
# - RUST_BACKTRACE=full
# disable vulkan additional features to avoid potential issues
- VK_LOADER_LAYERS_DISABLE=all
volumes:
# to use local binary file (instead of tabby official docker image)
- ./data/binary:/usr/local/bin
# to use local model files (instead of downloading in entrypoint)
- ./data/models:/var/lib/tabby/models
# vulkan driver and settings
- /usr/share/vulkan/icd.d:/usr/share/vulkan/icd.d:ro
- /usr/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu:ro
- /lib/x86_64-linux-gnu:/lib/x86_64-linux-gnu:ro
- /usr/lib/firmware:/usr/lib/firmware:ro
- /usr/share/libdrm:/usr/share/libdrm:ro
- /etc/vulkan:/etc/vulkan:ro
# sync timezone with host
- /etc/localtime:/etc/etc/localtime:ro
- /etc/timezone:/etc/timezone:ro
# use tmpfs for index to improve performance
# Use RAM for search index to avoid I/O bottlenecks and disk wear
tmpfs:
- /var/lib/tabby/index:size=2G,uid=0,gid=0,mode=777
devices:
- /dev/dri:/dev/dri # Direct Rendering Infrastructure for GPU accleleration
# --- Caution: The following group_id settings may need to be adjusted based on your host system's group IDs ---
# --- Try `getent group video render` on your host! ---
group_add:
- 44 # video
- 993 # render
ports:
- "9000:9000"
ulimits:
memlock: -1
stack: 67108864
deploy:
resources:
limits:
memory: 12G
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "10"
entrypoint:
- "bin/sh"
- "-c"
- |
echo "-----------------------------------------------------------------------"
echo "NOTICE: System library path (/usr/lib/x86_64-linux-gnu) is READ-ONLY."
echo "-----------------------------------------------------------------------"
echo "Tried multiple workarounds to fix the 'Read-only file system' error:"
echo " 1. Attempted to mount only specific required libraries."
echo " 2. Changed mount points to /vendor/lib to avoid system path conflicts."
echo ""
echo "Despite these attempts, the original path remained locked as Read-only,"
echo "likely due to Ubuntu's internal file linking and inode protection."
echo ""
echo "NOTE: Errors during 'apt install curl' will be visible, but since the"
echo "binary is functional, these errors can be safely ignored."
echo "The script will proceed using 'curl -k' to bypass SSL issues."
echo "-----------------------------------------------------------------------"
apt update && apt install -y curl # ca-certificates
# 1. Download Tabby binary if not exists (Optional: You can also bind mount the binary directly)
if [ ! -f /usr/local/bin/tabby ]; then
echo "Binary not found. Downloading Tabby Vulkan Binary without SSL..."
curl -k -L -o /usr/local/bin/tabby "https://github.com/TabbyML/tabby/releases/download/v0.10.0/tabby_x86_64-manylinux2014-vulkan"
chmod +x /usr/local/bin/tabby
fi
# 2. Generate model directory and tabby.json config if not exists (Optional: You can also bind mount these directly)
# Note: if you have custom models, make sure to adjust the MODEL_DIR and the content of tabby.json accordingly
MODEL_DIR="/var/lib/tabby/models/qwen2.5-coder-7b-instruct-gguf"
mkdir -p "$$MODEL_DIR/ggml"
if [ ! -f "$$MODEL_DIR/tabby.json" ]; then
echo "Model config not found. Generating tabby.json..."
echo '{
"format": "ggml",
"model": "/var/lib/tabby/models/qwen2.5-coder-7b-instruct-gguf/ggml/q8_0.v2.gguf",
"chat_template": "<|im_start|>system\\n{system_prompt}<|im_end|>\\n<|im_start|>user\\n{user_prompt}<|im_end|>\\n<|im_start|>assistant\\n"
}' > "$$MODEL_DIR/tabby.json"
fi
# 3. Check Model file and download if not exists (Optional: You can also bind mount the model file directly)
GGUF_FILE="$$MODEL_DIR/ggml/q8_0.v2.gguf"
if [ ! -f "$$GGUF_FILE" ]; then
echo "Model file not found. Downloading Qwen2.5-Coder-7B-Instruct GGUF model without SSL..."
curl -k -L -o "$$GGUF_FILE" "https://huggingface.co/Qwen/Qwen2.5-Coder-7B-Instruct-GGUF/resolve/main/qwen2.5-coder-7b-instruct-q4_k_m.gguf"
fi
# 4. Dynamic IDC Generation: Fixes the relative labrary_path issue what i explained 'environment' section
mkdir -p /tmp/vulkan/icd.d
if [ -f /usr/share/vulkan/icd.d/radeon_icd.json ]; then
sed 's/"library_path": "libvulkan_radeon.so"/"library_path": "\/usr\/lib\/x86_64-linux-gnu\/libvulkan_radeon.so"/g' \
/usr/share/vulkan/icd.d/radeon_icd.json > /tmp/vulkan/icd.d/radeon_icd.json
export VK_ICD_FILENAMES=/tmp/vulkan/icd.d/radeon_icd.json
fi
# 5. "All requirements are set. Starting Tabby Vulkan Server..."
echo "Starting Tabby Vulkan Server..."
exec tabby serve --device vulkan --port '9000' \
--model "$$MODEL_DIR" \
--chat-model "$$MODEL_DIR"