Skip to content

Commit f547c1f

Browse files
author
Bennu
authored
Add ci for milvus gpu (#22845)
Signed-off-by: Bennu-Li <yunmei.li@zilliz.com>
1 parent ff9b3be commit f547c1f

File tree

13 files changed

+821
-9
lines changed

13 files changed

+821
-9
lines changed

.env

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ IMAGE_ARCH=amd64
33
OS_NAME=ubuntu20.04
44
DATE_VERSION=20230215-5351fee
55
LATEST_DATE_VERSION=20230215-5351fee
6+
GPU_DATE_VERSION=20230317-a1c7b0c
7+
LATEST_GPU_DATE_VERSION=20230317-a1c7b0c
68
MINIO_ADDRESS=minio:9000
79
PULSAR_ADDRESS=pulsar://pulsar:6650
8-
ETCD_ENDPOINTS=etcd:2379
10+
ETCD_ENDPOINTS=etcd:2379

.github/workflows/publish-builder.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ on:
66
push:
77
# file paths to consider in the event. Optional; defaults to all.
88
paths:
9-
- 'build/docker/builder/**'
9+
- 'build/docker/builder/cpu/**'
1010
- '.github/workflows/publish-builder.yaml'
1111
- '!**.md'
1212
pull_request:
1313
# file paths to consider in the event. Optional; defaults to all.
1414
paths:
15-
- 'build/docker/builder/**'
15+
- 'build/docker/builder/cpu/**'
1616
- '.github/workflows/publish-builder.yaml'
1717
- '!**.md'
1818

Makefile

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ milvus-gpu: build-cpp-gpu print-build-info
3939
@echo "Building Milvus-gpu ..."
4040
@source $(PWD)/scripts/setenv.sh && \
4141
mkdir -p $(INSTALL_PATH) && go env -w CGO_ENABLED="1" && \
42-
GO111MODULE=on $(GO) build -ldflags="-r $${RPATH} -X '$(OBJPREFIX).BuildTags=$(BUILD_TAGS)' -X '$(OBJPREFIX).BuildTime=$(BUILD_TIME)' -X '$(OBJPREFIX).GitCommit=$(GIT_COMMIT)' -X '$(OBJPREFIX).GoVersion=$(GO_VERSION)'" \
43-
${AARCH64_FLAG} -o $(INSTALL_PATH)/milvus-gpu $(PWD)/cmd/main.go 1>/dev/null
42+
GO111MODULE=on $(GO) build -ldflags="-r $${RPATH} -X '$(OBJPREFIX).BuildTags=$(BUILD_TAGS_GPU)' -X '$(OBJPREFIX).BuildTime=$(BUILD_TIME)' -X '$(OBJPREFIX).GitCommit=$(GIT_COMMIT)' -X '$(OBJPREFIX).GoVersion=$(GO_VERSION)'" \
43+
${AARCH64_FLAG} -o $(INSTALL_PATH)/milvus $(PWD)/cmd/main.go 1>/dev/null
4444

4545
get-build-deps:
4646
@(env bash $(PWD)/scripts/install_deps.sh)
@@ -122,6 +122,7 @@ integration-test:
122122
${APPLE_SILICON_FLAG} -o $(INSTALL_PATH)/integration-test $(INTERATION_PATH)/ 1>/dev/null
123123

124124
BUILD_TAGS = $(shell git describe --tags --always --dirty="-dev")
125+
BUILD_TAGS_GPU = ${BUILD_TAGS}-gpu
125126
BUILD_TIME = $(shell date -u)
126127
GIT_COMMIT = $(shell git rev-parse --short HEAD)
127128
GO_VERSION = $(shell go version)
@@ -282,6 +283,16 @@ install: milvus
282283
-cp -r -P $(PWD)/internal/core/output/lib64/*.so* $(LIBRARY_PATH) 2>/dev/null
283284
@echo "Installation successful."
284285

286+
gpu-install: milvus-gpu
287+
@echo "Installing binary to './bin'"
288+
@mkdir -p $(GOPATH)/bin && cp -f $(PWD)/bin/milvus $(GOPATH)/bin/milvus
289+
@mkdir -p $(LIBRARY_PATH)
290+
-cp -r -P $(PWD)/internal/core/output/lib/*.dylib* $(LIBRARY_PATH) 2>/dev/null
291+
-cp -r -P $(PWD)/internal/core/output/lib/*.so* $(LIBRARY_PATH) 2>/dev/null
292+
-cp -r -P $(PWD)/internal/core/output/lib64/*.so* $(LIBRARY_PATH) 2>/dev/null
293+
@echo "Installation successful."
294+
295+
285296
clean:
286297
@echo "Cleaning up all the generated files"
287298
@find . -name '*.test' | xargs rm -fv
@@ -348,3 +359,4 @@ generate-mockery: getdeps
348359
$(PWD)/bin/mockery --name=QueryCoordComponent --dir=$(PWD)/internal/types --output=$(PWD)/internal/types --filename=mock_querycoord.go --with-expecter --structname=MockQueryCoord --outpkg=types --inpackage
349360
$(PWD)/bin/mockery --name=QueryNodeComponent --dir=$(PWD)/internal/types --output=$(PWD)/internal/types --filename=mock_querynode.go --with-expecter --structname=MockQueryNode --outpkg=types --inpackage
350361
ci-ut: build-cpp-with-coverage generated-proto-go-without-cpp codecov-cpp codecov-go
362+

build/build_image_gpu.sh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/bin/bash
2+
3+
# Licensed to the LF AI & Data foundation under one
4+
# or more contributor license agreements. See the NOTICE file
5+
# distributed with this work for additional information
6+
# regarding copyright ownership. The ASF licenses this file
7+
# to you under the Apache License, Version 2.0 (the
8+
# "License"); you may not use this file except in compliance
9+
# with the License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the License for the specific language governing permissions and
17+
# limitations under the License.
18+
19+
# Exit immediately for non zero status
20+
set -e
21+
# Print commands
22+
set -x
23+
24+
# Absolute path to the toplevel milvus directory.
25+
toplevel=$(dirname "$(cd "$(dirname "${0}")"; pwd)")
26+
27+
OS_NAME="${OS_NAME:-ubuntu20.04}"
28+
MILVUS_IMAGE_REPO="${MILVUS_IMAGE_REPO:-milvusdb/milvus}"
29+
MILVUS_IMAGE_TAG="${MILVUS_IMAGE_TAG:-gpu-latest}"
30+
31+
MILVUS_BASE_IMAGE_REPO="${MILVUS_BASE_IMAGE_REPO:-milvusdb/milvus-base}"
32+
MILVUS_BASE_IMAGE_TAG="gpu-local"
33+
BUILD_ARGS=""
34+
35+
pushd "${toplevel}"
36+
BUILD_BASE_IMAGE=${BUILD_BASE_IMAGE:-"false"}
37+
38+
# Seperate base dockerfile to ignore install dependencies when build milvus image
39+
if [[ ${OS_NAME} == "ubuntu20.04" && ${BUILD_BASE_IMAGE} == "true" ]]; then
40+
docker build -f "./build/docker/milvus/gpu/${OS_NAME}/Dockerfile.base" -t "${MILVUS_BASE_IMAGE_REPO}:${MILVUS_BASE_IMAGE_TAG}" .
41+
BUILD_ARGS="--build-arg MILVUS_BASE_IMAGE_REPO=${MILVUS_BASE_IMAGE_REPO} --build-arg MILVUS_BASE_IMAGE_TAG=${MILVUS_BASE_IMAGE_TAG}"
42+
fi
43+
44+
docker build ${BUILD_ARGS} -f "./build/docker/milvus/gpu/${OS_NAME}/Dockerfile" -t "${MILVUS_IMAGE_REPO}:${MILVUS_IMAGE_TAG}" .
45+
46+
image_size=$(docker inspect ${MILVUS_IMAGE_REPO}:${MILVUS_IMAGE_TAG} -f '{{.Size}}'| awk '{ byte =$1 /1024/1024/1024; print byte " GB" }')
47+
48+
echo "Image Size for ${MILVUS_IMAGE_REPO}:${MILVUS_IMAGE_TAG} is ${image_size}"
49+
50+
popd

build/builder_gpu.sh

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
# Absolute path to the toplevel milvus directory.
6+
toplevel=$(dirname "$(cd "$(dirname "${0}")"; pwd)")
7+
8+
export OS_NAME="${OS_NAME:-ubuntu20.04}"
9+
10+
pushd "${toplevel}"
11+
12+
if [[ "${1-}" == "pull" ]]; then
13+
docker-compose pull --ignore-pull-failures gpubuilder
14+
exit 0
15+
fi
16+
17+
if [[ "${1-}" == "down" ]]; then
18+
docker-compose down
19+
exit 0
20+
fi
21+
22+
# Attempt to run in the container with the same UID/GID as we have on the host,
23+
# as this results in the correct permissions on files created in the shared
24+
# volumes. This isn't always possible, however, as IDs less than 100 are
25+
# reserved by Debian, and IDs in the low 100s are dynamically assigned to
26+
# various system users and groups. To be safe, if we see a UID/GID less than
27+
# 500, promote it to 501. This is notably necessary on macOS Lion and later,
28+
# where administrator accounts are created with a GID of 20. This solution is
29+
# not foolproof, but it works well in practice.
30+
uid=$(id -u)
31+
gid=$(id -g)
32+
[ "$uid" -lt 500 ] && uid=501
33+
[ "$gid" -lt 500 ] && gid=$uid
34+
35+
mkdir -p "${DOCKER_VOLUME_DIRECTORY:-.docker-gpu}/amd64-${OS_NAME}-ccache"
36+
mkdir -p "${DOCKER_VOLUME_DIRECTORY:-.docker-gpu}/amd64-${OS_NAME}-go-mod"
37+
mkdir -p "${DOCKER_VOLUME_DIRECTORY:-.docker-gpu}/amd64-${OS_NAME}-vscode-extensions"
38+
mkdir -p "${DOCKER_VOLUME_DIRECTORY:-.docker-gpu}/amd64-${OS_NAME}-conan"
39+
chmod -R 777 "${DOCKER_VOLUME_DIRECTORY:-.docker-gpu}"
40+
41+
docker-compose pull --ignore-pull-failures gpubuilder
42+
if [[ "${CHECK_BUILDER:-}" == "1" ]]; then
43+
docker-compose build gpubuilder
44+
fi
45+
46+
if [[ "$(id -u)" != "0" ]]; then
47+
docker-compose run --no-deps --rm -u "$uid:$gid" gpubuilder "$@"
48+
else
49+
docker-compose run --no-deps --rm --entrypoint "/tini -- /entrypoint.sh" gpubuilder "$@"
50+
fi
51+
52+
popd
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Copyright (C) 2019-2022 Zilliz. All rights reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
4+
# with the License. You may obtain a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software distributed under the License
9+
# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
10+
# or implied. See the License for the specific language governing permissions and limitations under the License.
11+
12+
FROM nvidia/cuda:11.6.0-devel-ubuntu20.04
13+
14+
RUN apt-get update && apt-get install -y --no-install-recommends wget curl ca-certificates gnupg2 && \
15+
wget -qO- "https://cmake.org/files/v3.24/cmake-3.24.0-linux-x86_64.tar.gz" | tar --strip-components=1 -xz -C /usr/local && \
16+
apt-get update && apt-get install -y --no-install-recommends \
17+
g++ gcc gfortran git make ccache libssl-dev zlib1g-dev unzip \
18+
clang-format-10 clang-tidy-10 lcov libtool m4 autoconf automake python3 python3-pip \
19+
pkg-config uuid-dev libaio-dev libgoogle-perftools-dev libopenblas-dev && \
20+
apt-get remove --purge -y && \
21+
rm -rf /var/lib/apt/lists/*
22+
23+
RUN pip3 install conan==1.58.0
24+
25+
# Instal openblas
26+
# RUN wget https://github.com/xianyi/OpenBLAS/archive/v0.3.21.tar.gz && \
27+
# tar zxvf v0.3.21.tar.gz && cd OpenBLAS-0.3.21 && \
28+
# make NO_STATIC=1 NO_LAPACK=1 NO_LAPACKE=1 NO_CBLAS=1 NO_AFFINITY=1 USE_OPENMP=1 \
29+
# TARGET=HASWELL DYNAMIC_ARCH=1 \
30+
# NUM_THREADS=64 MAJOR_VERSION=3 libs shared && \
31+
# make PREFIX=/usr/local NUM_THREADS=64 MAJOR_VERSION=3 install && \
32+
# rm -f /usr/local/include/cblas.h /usr/local/include/lapack* && \
33+
# cd .. && rm -rf OpenBLAS-0.3.21 && rm v0.3.21.tar.gz
34+
35+
ENV LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/lib"
36+
37+
# Install Go
38+
ENV GOPATH /go
39+
ENV GOROOT /usr/local/go
40+
ENV GO111MODULE on
41+
ENV PATH $GOPATH/bin:$GOROOT/bin:$PATH
42+
RUN mkdir -p /usr/local/go && wget -qO- "https://golang.org/dl/go1.18.3.linux-amd64.tar.gz" | tar --strip-components=1 -xz -C /usr/local/go && \
43+
mkdir -p "$GOPATH/src" "$GOPATH/bin" && \
44+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b ${GOPATH}/bin v1.46.2 && \
45+
# export GO111MODULE=on && go get github.com/quasilyte/go-ruleguard/cmd/ruleguard@v0.2.1 && \
46+
go install github.com/ramya-rao-a/go-outline@latest && \
47+
go install golang.org/x/tools/gopls@latest && \
48+
go install github.com/uudashr/gopkgs/v2/cmd/gopkgs@latest && \
49+
go install github.com/go-delve/delve/cmd/dlv@latest && \
50+
go install honnef.co/go/tools/cmd/staticcheck@2022.1 && \
51+
go clean --modcache && \
52+
chmod -R 777 "$GOPATH" && chmod -R a+w $(go env GOTOOLDIR)
53+
54+
RUN ln -s /go/bin/dlv /go/bin/dlv-dap
55+
56+
RUN apt-get update && apt-get install -y --no-install-recommends \
57+
gdb gdbserver && \
58+
apt-get remove --purge -y && \
59+
rm -rf /var/lib/apt/lists/*
60+
61+
RUN echo 'root:root' | chpasswd
62+
63+
# refer: https://code.visualstudio.com/docs/remote/containers-advanced#_avoiding-extension-reinstalls-on-container-rebuild
64+
RUN mkdir -p /home/milvus/.vscode-server/extensions \
65+
/home/milvus/.vscode-server-insiders/extensions \
66+
&& chmod -R 777 /home/milvus
67+
68+
COPY --chown=0:0 build/docker/builder/entrypoint.sh /
69+
70+
RUN wget -qO- "https://github.com/jeffoverflow/autouseradd/releases/download/1.2.0/autouseradd-1.2.0-amd64.tar.gz" | tar xz -C / --strip-components 1
71+
72+
RUN wget -O /tini https://github.com/krallin/tini/releases/download/v0.19.0/tini && \
73+
chmod +x /tini
74+
75+
ENTRYPOINT [ "/tini", "--", "autouseradd", "--user", "milvus", "--", "/entrypoint.sh" ]
76+
CMD ["tail", "-f", "/dev/null"]
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Copyright (C) 2019-2022 Zilliz. All rights reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
4+
# with the License. You may obtain a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software distributed under the License
9+
# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
10+
# or implied. See the License for the specific language governing permissions and limitations under the License.
11+
ARG MILVUS_BASE_IMAGE_REPO="milvusdb/milvus-base"
12+
ARG MILVUS_BASE_IMAGE_TAG="gpu-20230317-e62607a"
13+
FROM ${MILVUS_BASE_IMAGE_REPO}:${MILVUS_BASE_IMAGE_TAG}
14+
15+
COPY ./bin/ /milvus/bin/
16+
17+
COPY ./configs/ /milvus/configs/
18+
19+
COPY ./lib/ /milvus/lib/
20+
21+
ENV PATH=/milvus/bin:$PATH
22+
ENV LD_LIBRARY_PATH=/milvus/lib:$LD_LIBRARY_PATH:/usr/lib
23+
ENV LD_PRELOAD=/milvus/lib/libjemalloc.so
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Copyright (C) 2019-2022 Zilliz. All rights reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
4+
# with the License. You may obtain a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software distributed under the License
9+
# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
10+
# or implied. See the License for the specific language governing permissions and limitations under the License.
11+
12+
FROM milvusdb/openblas:ubuntu20.04-20220914-179ea77 AS openblas
13+
14+
#FROM alpine
15+
#FROM ubuntu:focal-20220426
16+
#ENV DEBIAN_FRONTEND=noninteractive
17+
18+
FROM nvidia/cuda:11.6.0-runtime-ubuntu20.04
19+
20+
ENV TZ=UTC
21+
22+
RUN apt-get update && \
23+
apt-get install -y --no-install-recommends curl libtbb-dev gfortran netcat iputils-ping ca-certificates liblapack3 libzstd-dev uuid-dev libaio-dev libboost-program-options-dev libboost-filesystem-dev && \
24+
apt-get remove --purge -y && \
25+
rm -rf /var/lib/apt/lists/*
26+
27+
COPY --from=openblas /usr/local/lib/libopenblasp-r0.3.21.so /usr/lib/
28+
29+
RUN ln -s /usr/lib/libopenblasp-r0.3.21.so /usr/lib/libopenblas.so.3 && \
30+
ln -s /usr/lib/libopenblas.so.3 /usr/lib/libopenblas.so.0 && \
31+
ln -s /usr/lib/libopenblas.so.0 /usr/lib/libopenblas.so
32+
33+
# Add Tini
34+
ADD https://github.com/krallin/tini/releases/download/v0.19.0/tini /tini
35+
RUN chmod +x /tini
36+
ENTRYPOINT ["/tini", "--"]
37+
38+
WORKDIR /milvus/

0 commit comments

Comments
 (0)