clone_tensorrtllm.sh 4.17 KB
Newer Older
1
#!/bin/bash -e
Neelay Shah's avatar
Neelay Shah committed
2
# SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3
# SPDX-License-Identifier: Apache-2.0
4
5
6
7
8
9
10
11
12
13
14
15
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
16

17
18
TENSORRTLLM_BACKEND_REPO_TAG=
TENSORRTLLM_BACKEND_REBUILD=
Neelay Shah's avatar
Neelay Shah committed
19
DYNAMO_LLM_PATH=
20
21
22
23
24
25
26
27
28
29
GIT_TOKEN=
GIT_REPO=

get_options() {
    while :; do
        case $1 in
        -h | -\? | --help)
            show_help
            exit
            ;;
30
    --tensorrtllm-backend-repo-tag)
31
            if [ "$2" ]; then
32
33
34
35
36
37
38
39
40
                TENSORRTLLM_BACKEND_REPO_TAG=$2
                shift
            else
		missing_requirement $1
            fi
            ;;
    --tensorrtllm-backend-rebuild)
            if [ "$2" ]; then
                TENSORRTLLM_BACKEND_REBUILD=$2
41
42
43
44
45
                shift
            else
		missing_requirement $1
            fi
            ;;
Neelay Shah's avatar
Neelay Shah committed
46
    --dynamo-llm-path)
47
            if [ "$2" ]; then
Neelay Shah's avatar
Neelay Shah committed
48
                DYNAMO_LLM_PATH=$2
49
50
51
52
53
                shift
            else
		missing_requirement $1
            fi
            ;;
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
    --git-token)
            if [ "$2" ]; then
                GIT_TOKEN=$2
                shift
            else
		missing_requirement $1
            fi
            ;;
    --git-repo)
            if [ "$2" ]; then
                GIT_REPO=$2
                shift
            else
		missing_requirement $1
            fi
            ;;
         -?*)
	    error 'ERROR: Unknown option: ' $1
            ;;
	 ?*)
	    error 'ERROR: Unknown option: ' $1
            ;;
        *)
            break
            ;;
        esac

        shift
    done
}

show_options() {
    echo ""
    echo "Getting TENSORRTLLM Backend Repo"
    echo ""
89
90
    echo "   Tensorrtllm Backend Repo Tag: '${TENSORRTLLM_BACKEND_REPO_TAG}'"
    echo "   Tensorrtllm Backend Rebuild: '${TENSORRTLLM_BACKEND_REBUILD}'"
91
92
93
94
95
96
    echo ""
}


show_help() {
    echo "usage: clone_tensorrtllm.sh"
97
98
    echo "  [--tensorrtllm-backend-repo-tag commit]"
    echo "  [--tensorrtllm-backend-rebuild whether to rebuild backend]"
99
    echo "  [--git-token git-token]"
100
    echo "  [--git-repo git-repo]"
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
    exit 0
}

missing_requirement() {
    error "ERROR: $1 requires an argument."
}

error() {
    printf '%s %s\n' "$1" "$2" >&2
    exit 1
}

get_options "$@"

if [ -z ${GIT_REPO} ]; then
       GIT_REPO="github.com/triton-inference-server/tensorrtllm_backend"
fi

if [ ! -z ${GIT_TOKEN} ]; then
    GIT_REPO="https://oauth2:${GIT_TOKEN}@${GIT_REPO}"
else
    GIT_REPO="https://${GIT_REPO}"
fi

show_options

git clone ${GIT_REPO}
cd tensorrtllm_backend
Tanmay Verma's avatar
Tanmay Verma committed
129
git checkout ${TENSORRTLLM_BACKEND_REPO_TAG}
130
131
132
git submodule update --init --recursive
git lfs install
git lfs pull
133

Tanmay Verma's avatar
Tanmay Verma committed
134
if [ ! -z ${TENSORRTLLM_BACKEND_REBUILD} ]; then
135
136
137
138
139
140
141
142
143
144
    # Install cmake
    apt update -q=2 \
	    && apt install -y gpg wget \
        && wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - |  tee /usr/share/keyrings/kitware-archive-keyring.gpg >/dev/null \
	    && . /etc/os-release \
	    && echo "deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ $UBUNTU_CODENAME main" | tee /etc/apt/sources.list.d/kitware.list >/dev/null \
	    && apt-get update -q=2 \
	    && apt-get install -y --no-install-recommends cmake=3.28.3* cmake-data=3.28.3* \
        && cmake --version

Tanmay Verma's avatar
Tanmay Verma committed
145
146
147
    # Install rapidjson
    apt install -y rapidjson-dev

148
149
    # Build the backend
    (cd inflight_batcher_llm/src \
Neelay Shah's avatar
Neelay Shah committed
150
        && cmake -DCMAKE_INSTALL_PREFIX:PATH=`pwd`/install -DUSE_CXX11_ABI=1 -DDYNAMO_LLM_PATH=$DYNAMO_LLM_PATH .. \
151
        && make install \
152
        && cp libtriton_tensorrtllm.so /opt/tritonserver/backends/tensorrtllm/ \
153
154
155
        && cp trtllmExecutorWorker /opt/tritonserver/backends/tensorrtllm/ \
    )
fi
156
157
cd ..
mv tensorrtllm_backend /