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