@@ -28,7 +28,7 @@ function install_folly() {
28
28
echo -e " ${COLOR_GREEN} [ INFO ] Cloning folly repo ${COLOR_OFF} "
29
29
git clone https://github.com/facebook/folly.git " $FOLLY_SRC_DIR "
30
30
cd $FOLLY_SRC_DIR
31
- git checkout tags/v2022.06.27 .00
31
+ git checkout tags/v2024.01.29 .00
32
32
fi
33
33
34
34
if [ ! -d " $FOLLY_BUILD_DIR " ] ; then
@@ -75,7 +75,18 @@ function install_kineto() {
75
75
76
76
function install_libtorch() {
77
77
if [ " $PLATFORM " = " Mac" ]; then
78
- echo -e " ${COLOR_GREEN} [ INFO ] Skip install libtorch on Mac ${COLOR_OFF} "
78
+ cd " $DEPS_DIR " || exit
79
+ if [[ $( uname -m) == ' x86_64' ]]; then
80
+ echo -e " ${COLOR_GREEN} [ INFO ] Install libtorch on Mac x86_64 ${COLOR_OFF} "
81
+ wget https://download.pytorch.org/libtorch/cpu/libtorch-macos-x86_64-2.2.0.zip
82
+ unzip libtorch-macos-x86_64-2.2.0.zip
83
+ rm libtorch-macos-x86_64-2.2.0.zip
84
+ else
85
+ echo -e " ${COLOR_GREEN} [ INFO ] Install libtorch on Mac arm64 ${COLOR_OFF} "
86
+ wget https://download.pytorch.org/libtorch/cpu/libtorch-macos-arm64-2.2.0.zip
87
+ unzip libtorch-macos-arm64-2.2.0.zip
88
+ rm libtorch-macos-arm64-2.2.0.zip
89
+ fi
79
90
elif [ ! -d " $DEPS_DIR /libtorch" ] ; then
80
91
cd " $DEPS_DIR " || exit
81
92
if [ " $PLATFORM " = " Linux" ]; then
@@ -113,7 +124,7 @@ function install_yaml_cpp() {
113
124
echo -e " ${COLOR_GREEN} [ INFO ] Cloning yaml-cpp repo ${COLOR_OFF} "
114
125
git clone https://github.com/jbeder/yaml-cpp.git " $YAML_CPP_SRC_DIR "
115
126
cd $YAML_CPP_SRC_DIR
116
- git checkout tags/yaml-cpp-0.7 .0
127
+ git checkout tags/0.8 .0
117
128
fi
118
129
119
130
if [ ! -d " $YAML_CPP_BUILD_DIR " ] ; then
@@ -136,11 +147,42 @@ function install_yaml_cpp() {
136
147
cd " $BWD " || exit
137
148
}
138
149
150
+ function install_sentencepiece() {
151
+ SENTENCEPIECE_SRC_DIR=$BASE_DIR /third-party/sentencepiece
152
+ SENTENCEPIECE_BUILD_DIR=$DEPS_DIR /sentencepiece-build
153
+
154
+ if [ ! -d " $SENTENCEPIECE_SRC_DIR " ] ; then
155
+ echo -e " ${COLOR_GREEN} [ INFO ] Cloning sentencepiece repo ${COLOR_OFF} "
156
+ git clone https://github.com/google/sentencepiece.git " $SENTENCEPIECE_SRC_DIR "
157
+ cd $SENTENCEPIECE_SRC_DIR
158
+ git checkout tags/v0.1.99
159
+ fi
160
+
161
+ if [ ! -d " $SENTENCEPIECE_BUILD_DIR " ] ; then
162
+ echo -e " ${COLOR_GREEN} [ INFO ] Building sentencepiece ${COLOR_OFF} "
163
+
164
+ mkdir $SENTENCEPIECE_BUILD_DIR
165
+ cd $SENTENCEPIECE_BUILD_DIR
166
+ cmake $SENTENCEPIECE_SRC_DIR
167
+ make -i $( nproc)
168
+ if [ " $PLATFORM " = " Linux" ]; then
169
+ sudo make install
170
+ sudo ldconfig -v
171
+ elif [ " $PLATFORM " = " Mac" ]; then
172
+ make install
173
+ fi
174
+
175
+ echo -e " ${COLOR_GREEN} [ INFO ] sentencepiece is installed ${COLOR_OFF} "
176
+ fi
177
+
178
+ cd " $BWD " || exit
179
+ }
180
+
139
181
function build_llama_cpp() {
140
182
BWD=$( pwd)
141
183
LLAMA_CPP_SRC_DIR=$BASE_DIR /third-party/llama.cpp
142
184
cd " ${LLAMA_CPP_SRC_DIR} "
143
- make
185
+ make LLAMA_METAL=OFF
144
186
cd " $BWD " || exit
145
187
}
146
188
@@ -191,7 +233,7 @@ function build() {
191
233
fi
192
234
elif [ " $PLATFORM " = " Mac" ]; then
193
235
cmake \
194
- -DCMAKE_PREFIX_PATH=" $( python -c ' import torch; print(torch.utils.cmake_prefix_path) ' ) ; $ DEPS_DIR ;$FOLLY_CMAKE_DIR ;$YAML_CPP_CMAKE_DIR " \
236
+ -DCMAKE_PREFIX_PATH=" $DEPS_DIR ;$FOLLY_CMAKE_DIR ;$YAML_CPP_CMAKE_DIR ; $DEPS_DIR /libtorch " \
195
237
-DCMAKE_INSTALL_PREFIX=" $PREFIX " \
196
238
" $MAYBE_BUILD_QUIC " \
197
239
" $MAYBE_BUILD_TESTS " \
@@ -225,7 +267,7 @@ function build() {
225
267
226
268
function symlink_torch_libs() {
227
269
if [ " $PLATFORM " = " Linux" ]; then
228
- ln -sf ${DEPS_DIR} /libtorch/lib/* .so* ${BUILD_DIR} /libs/
270
+ ln -sf ${DEPS_DIR} /libtorch/lib/* .so* ${LIBS_DIR}
229
271
fi
230
272
}
231
273
@@ -315,6 +357,7 @@ install_folly
315
357
install_kineto
316
358
install_libtorch
317
359
install_yaml_cpp
360
+ install_sentencepiece
318
361
build_llama_cpp
319
362
build
320
363
symlink_torch_libs
0 commit comments