forked from dusty-nv/jetson-containers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·100 lines (78 loc) · 2.72 KB
/
build.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
#!/usr/bin/env bash
set -ex
echo "Building MLC ${MLC_VERSION} (commit=${MLC_COMMIT})"
# install LLVM the upstream way instead of apt because of:
# https://discourse.llvm.org/t/llvm-15-0-7-missing-libpolly-a/67942
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
./llvm.sh ${LLVM_VERSION} all
ln -sf /usr/bin/llvm-config-* /usr/bin/llvm-config
# could NOT find zstd (missing: zstd_LIBRARY zstd_INCLUDE_DIR)
apt-get update
apt-get install -y --no-install-recommends libzstd-dev ccache
rm -rf /var/lib/apt/lists/*
apt-get clean
# clone the sources
git clone https://github.com/mlc-ai/mlc-llm /opt/mlc-llm
cd /opt/mlc-llm
git checkout ${MLC_COMMIT}
git submodule update --init --recursive
# apply patches to the source
if [ -s /tmp/mlc/patch.diff ]; then
git apply /tmp/mlc/patch.diff
fi
git status
git diff --submodule=diff
# add extras to the source
cp /tmp/mlc/benchmark.py /opt/mlc-llm/
# flashinfer build references 'python'
ln -sf /usr/bin/python3 /usr/bin/python
# disable pytorch: https://github.com/apache/tvm/issues/9362
# -DUSE_LIBTORCH=$(pip3 show torch | grep Location: | cut -d' ' -f2)/torch
mkdir build
cd build
cmake -G Ninja \
-DCMAKE_CXX_STANDARD=17 \
-DCMAKE_CUDA_STANDARD=17 \
-DCMAKE_CUDA_ARCHITECTURES=${CUDAARCHS} \
-DUSE_CUDA=ON \
-DUSE_CUDNN=ON \
-DUSE_CUBLAS=ON \
-DUSE_CURAND=ON \
-DUSE_CUTLASS=ON \
-DUSE_THRUST=ON \
-DUSE_GRAPH_EXECUTOR_CUDA_GRAPH=ON \
-DUSE_STACKVM_RUNTIME=ON \
-DUSE_LLVM="/usr/bin/llvm-config --link-static" \
-DHIDE_PRIVATE_SYMBOLS=ON \
-DSUMMARIZE=ON \
../
ninja
#rm -rf CMakeFiles tvm/CMakeFiles
#rm -rf tokenizers/CMakeFiles tokenizers/release
# build TVM python module
cd /opt/mlc-llm/3rdparty/tvm/python
TVM_LIBRARY_PATH=/opt/mlc-llm/build/tvm \
python3 setup.py --verbose bdist_wheel --dist-dir /opt
pip3 install --no-cache-dir --verbose /opt/tvm*.whl
#pip3 show tvm && python3 -c 'import tvm'
#rm -rf dist build
# build mlc-llm python module
cd /opt/mlc-llm
if [ -f setup.py ]; then
python3 setup.py --verbose bdist_wheel --dist-dir /opt
fi
cd python
python3 setup.py --verbose bdist_wheel --dist-dir /opt
pip3 install --no-cache-dir --verbose /opt/mlc*.whl
# make sure it loads
#cd /
#pip3 show mlc_llm
#python3 -m mlc_llm.build --help
#python3 -c "from mlc_chat import ChatModule; print(ChatModule)"
# make the CUTLASS sources available for model builder
ln -s /opt/mlc-llm/3rdparty/tvm/3rdparty /usr/local/lib/python${PYTHON_VERSION}/dist-packages/tvm/3rdparty
# upload wheels
twine upload --verbose /opt/tvm*.whl || echo "failed to upload wheel to ${TWINE_REPOSITORY_URL}"
twine upload --verbose /opt/mlc_llm*.whl || echo "failed to upload wheel to ${TWINE_REPOSITORY_URL}"
twine upload --verbose /opt/mlc_chat*.whl || echo "failed to upload wheel to ${TWINE_REPOSITORY_URL}"