-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
docker_build_script_ubuntu.sh
executable file
·153 lines (139 loc) · 4.09 KB
/
docker_build_script_ubuntu.sh
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
149
150
151
152
153
#!/bin/bash
set -o pipefail
set -ex
export DEBIAN_FRONTEND=noninteractive
export PATH=/h2ogpt_conda/bin:$PATH
export HOME=/workspace
export CUDA_HOME=/usr/local/cuda-12.1
export PIP_EXTRA_INDEX_URL="https://download.pytorch.org/whl/cu121 https://huggingface.github.io/autogptq-index/whl/cu121"
# Install linux dependencies
apt-get update && apt-get install -y \
git \
curl \
wget \
software-properties-common \
pandoc \
vim \
libmagic-dev \
poppler-utils \
tesseract-ocr \
libtesseract-dev \
libreoffice \
autoconf \
libtool \
docker.io \
nodejs \
npm \
zip \
unzip \
htop \
tree \
tmux \
jq \
net-tools \
nmap \
ncdu \
mtr \
rsync \
build-essential \
parallel \
bc \
pv \
expect \
cron \
at \
screen \
inotify-tools \
jq \
xmlstarlet \
dos2unix \
ssh
# Run upgrades
apt-get upgrade -y
# Install conda
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh && \
mkdir -p /h2ogpt_conda && \
bash ./Miniconda3-latest-Linux-x86_64.sh -b -u -p /h2ogpt_conda && \
conda update -n base conda && \
source /h2ogpt_conda/etc/profile.d/conda.sh && \
conda create -n h2ogpt -y && \
conda activate h2ogpt && \
conda install python=3.10 pygobject weasyprint -c conda-forge -y && \
echo "h2oGPT conda env: $CONDA_DEFAULT_ENV"
# if building for CPU, would remove CMAKE_ARGS and avoid GPU image as base image
# Choose llama_cpp_python ARGS for your system according to [llama_cpp_python backend documentation](https://github.com/abetlen/llama-cpp-python?tab=readme-ov-file#supported-backends), e.g. for CUDA:
export GGML_CUDA=1
export CMAKE_ARGS="-DGGML_CUDA=on -DCMAKE_CUDA_ARCHITECTURES=all"
# for Metal MAC M1/M2 comment out above two lines and uncomment out the below line
# export CMAKE_ARGS="-DLLAMA_METAL=on"
export FORCE_CMAKE=1
export GPLOK=1
bash docs/linux_install.sh
chmod -R a+rwx /h2ogpt_conda
# setup tiktoken cache
export TIKTOKEN_CACHE_DIR=/workspace/tiktoken_cache
python3.10 -c "
import tiktoken
from tiktoken_ext import openai_public
# FakeTokenizer etc. needs tiktoken for general tasks
for enc in openai_public.ENCODING_CONSTRUCTORS:
encoding = tiktoken.get_encoding(enc)
model_encodings = [
'gpt-4',
'gpt-4-0314',
'gpt-4-32k',
'gpt-4-32k-0314',
'gpt-3.5-turbo',
'gpt-3.5-turbo-16k',
'gpt-3.5-turbo-0301',
'text-ada-001',
'ada',
'text-babbage-001',
'babbage',
'text-curie-001',
'curie',
'davinci',
'text-davinci-003',
'text-davinci-002',
'code-davinci-002',
'code-davinci-001',
'code-cushman-002',
'code-cushman-001'
]
for enc in model_encodings:
encoding = tiktoken.encoding_for_model(enc)
print('Done!')
"
# Open Web UI
conda create -n open-webui -y
source /h2ogpt_conda/etc/profile.d/conda.sh
conda activate open-webui
conda install python=3.11 -y
echo "open-webui conda env: $CONDA_DEFAULT_ENV"
chmod -R a+rwx /h2ogpt_conda
pip install https://h2o-release.s3.amazonaws.com/h2ogpt/open_webui-0.3.8-py3-none-any.whl
# Track build info
cp /workspace/build_info.txt /build_info.txt
mkdir -p /workspace/save
chmod -R a+rwx /workspace/save
# Cleanup
rm -rf /workspace/Miniconda3-py310_23.1.0-1-Linux-x86_64.sh
rm -rf /workspace/.cache/pip
rm -rf /h2ogpt_conda/pkgs
rm -rf /workspace/spaces
rm -rf /workspace/benchmarks
rm -rf /workspace/data
rm -rf /workspace/cloud
rm -rf /workspace/docs
rm -rf /workspace/helm
rm -rf /workspace/notebooks
rm -rf /workspace/papers
# Hotswap vulnerable dependencies
wget https://s3.amazonaws.com/artifacts.h2o.ai/deps/h2ogpt/ubuntu20.04/apparmor_4.0.0~alpha2-0ubuntu5_amd64.deb
wget https://s3.amazonaws.com/artifacts.h2o.ai/deps/h2ogpt/ubuntu20.04/libapparmor1_4.0.0~alpha2-0ubuntu5_amd64.deb
dpkg -i libapparmor1_4.0.0~alpha2-0ubuntu5_amd64.deb
dpkg -i apparmor_4.0.0~alpha2-0ubuntu5_amd64.deb
rm -rf libapparmor1_4*.deb apparmor_4*.deb
wget https://s3.amazonaws.com/artifacts.h2o.ai/deps/h2ogpt/ubuntu20.04/libarchive13_3.6.2-1ubuntu1_amd64.deb
dpkg -i libarchive13_3.6.2-1ubuntu1_amd64.deb
rm -rf libarchive13_3.6.2-1ubuntu1_amd64.deb