2019-11-01 15:42:04 +08:00
# Install Milvus from Source Code
2020-02-20 13:44:02 +08:00
<!-- TOC -->
2020-03-03 00:25:22 +08:00
- [Build from source ](#build-from-source )
2020-02-21 21:19:55 +08:00
- [Requirements ](#requirements )
2020-03-03 00:25:22 +08:00
2020-02-21 21:19:55 +08:00
- [Compilation ](#compilation )
2020-03-03 00:25:22 +08:00
2020-02-21 21:19:55 +08:00
- [Launch Milvus server ](#launch-milvus-server )
2020-03-03 00:25:22 +08:00
- [Compile Milvus on Docker ](#compile-milvus-on-docker )
2020-02-21 21:19:55 +08:00
- [Step 1 Pull Milvus Docker images ](#step-1-pull-milvus-docker-images )
2020-03-03 00:25:22 +08:00
2020-02-21 21:19:55 +08:00
- [Step 2 Start the Docker container ](#step-2-start-the-docker-container )
2020-03-03 00:25:22 +08:00
2020-02-21 21:19:55 +08:00
- [Step 3 Download Milvus source code ](#step-3-download-milvus-source-code )
2020-03-03 00:25:22 +08:00
2020-02-21 21:19:55 +08:00
- [Step 4 Compile Milvus in the container ](#step-4-compile-milvus-in-the-container )
2020-03-03 00:25:22 +08:00
- [Troubleshooting ](#troubleshooting )
2020-02-21 21:19:55 +08:00
- [Error message: `protocol https not supported or disabled in libcurl` ](#error-message-protocol-https-not-supported-or-disabled-in-libcurl )
2020-03-03 00:25:22 +08:00
2020-02-21 21:19:55 +08:00
- [Error message: `internal compiler error` ](#error-message-internal-compiler-error )
2020-03-03 00:25:22 +08:00
2020-02-21 21:19:55 +08:00
- [Error message: `error while loading shared libraries: libmysqlpp.so.3` ](#error-message-error-while-loading-shared-libraries-libmysqlppso3 )
2020-03-03 00:25:22 +08:00
2020-02-21 21:19:55 +08:00
- [CMake version is not supported ](#cmake-version-is-not-supported )
2020-02-20 13:44:02 +08:00
<!-- /TOC -->
2019-12-02 11:46:29 +08:00
2019-11-28 17:15:21 +08:00
## Build from source
### Requirements
2019-11-01 15:42:04 +08:00
2020-03-03 00:25:22 +08:00
- Operating system
2020-02-21 21:19:55 +08:00
- Ubuntu 18.04 or higher
2020-03-03 00:25:22 +08:00
2020-02-21 21:19:55 +08:00
- CentOS 7
2019-11-19 09:16:58 +08:00
2020-02-27 17:19:51 +08:00
> Note: If your Linux operating system does not meet the requirements, we recommend that you pull a Docker image of [Ubuntu 18.04](https://docs.docker.com/install/linux/docker-ce/ubuntu/) or [CentOS 7](https://docs.docker.com/install/linux/docker-ce/centos/) as your compilation environment.
2019-11-19 09:16:58 +08:00
2020-03-03 00:25:22 +08:00
- GCC 7.0 or higher to support C++ 17
- CMake 3.12 or higher
- Git
2019-11-13 15:43:24 +08:00
2020-02-20 13:44:02 +08:00
For GPU-enabled version, you will also need:
2019-11-13 15:43:24 +08:00
2020-03-03 00:25:22 +08:00
- CUDA 10.0 or higher
- NVIDIA driver 418 or higher
2019-11-01 15:42:04 +08:00
2019-11-28 17:15:21 +08:00
### Compilation
2019-11-01 15:42:04 +08:00
2019-11-28 17:15:21 +08:00
#### Step 1 Install dependencies
2019-11-01 15:42:04 +08:00
2020-02-21 21:19:55 +08:00
##### Install in Ubuntu
2019-11-01 15:42:04 +08:00
```shell
2019-11-13 15:43:24 +08:00
$ cd [Milvus root path]/core
2019-11-01 15:42:04 +08:00
$ ./ubuntu_build_deps.sh
```
2020-02-21 21:19:55 +08:00
##### Install in CentOS
2020-02-20 13:44:02 +08:00
2019-11-01 15:42:04 +08:00
```shell
2019-11-13 15:43:24 +08:00
$ cd [Milvus root path]/core
2020-02-21 21:19:55 +08:00
$ ./centos7_build_deps.sh
2020-02-20 13:44:02 +08:00
```
2020-02-21 21:19:55 +08:00
#### Step 2 Build
2020-02-20 13:44:02 +08:00
```shell
2020-02-21 21:19:55 +08:00
$ cd [Milvus root path]/core
$ ./build.sh -t Debug
2019-11-13 16:18:18 +08:00
```
2019-11-13 15:43:24 +08:00
2020-02-21 21:19:55 +08:00
or
2020-02-20 13:44:02 +08:00
```shell
2020-02-21 21:19:55 +08:00
$ ./build.sh -t Release
2020-02-20 13:44:02 +08:00
```
By default, it will build CPU-only version. To build GPU version, add `-g` option.
2019-11-15 17:44:38 +08:00
```shell
2019-11-13 15:43:24 +08:00
$ ./build.sh -g
2019-11-01 15:42:04 +08:00
```
2020-02-20 13:44:02 +08:00
If you want to know the complete build options, run the following command.
2019-11-15 17:44:38 +08:00
```shell
$./build.sh -h
```
2020-02-21 21:19:55 +08:00
When the build is completed, everything that you need in order to run Milvus will be installed under `[Milvus root path]/core/milvus` .
2019-11-01 15:42:04 +08:00
2019-11-28 17:15:21 +08:00
### Launch Milvus server
2019-11-01 15:42:04 +08:00
```shell
$ cd [Milvus root path]/core/milvus
```
Add `lib/` directory to `LD_LIBRARY_PATH`
2019-11-15 17:44:38 +08:00
```shell
2019-11-13 15:43:24 +08:00
$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:[Milvus root path]/core/milvus/lib
2019-11-01 15:42:04 +08:00
```
Then start Milvus server:
2019-11-15 17:44:38 +08:00
```shell
2019-11-01 15:42:04 +08:00
$ cd scripts
$ ./start_server.sh
```
To stop Milvus server, run:
```shell
$ ./stop_server.sh
```
2019-11-13 15:43:24 +08:00
2019-11-28 17:15:21 +08:00
## Compile Milvus on Docker
2020-02-27 17:19:51 +08:00
With the following Docker images, you should be able to compile Milvus on any Linux platform that runs Docker. To build a GPU supported Milvus, you need to install [NVIDIA Docker ](https://github.com/NVIDIA/nvidia-docker/ ) first.
2019-11-28 17:15:21 +08:00
2019-11-28 17:34:45 +08:00
### Step 1 Pull Milvus Docker images
2019-11-28 17:15:21 +08:00
Pull CPU-only image:
```shell
2020-02-14 12:19:42 +08:00
$ docker pull milvusdb/milvus-cpu-build-env:latest
2019-11-28 17:15:21 +08:00
```
Pull GPU-enabled image:
```shell
2020-02-14 12:19:42 +08:00
$ docker pull milvusdb/milvus-gpu-build-env:latest
2019-11-28 17:15:21 +08:00
```
2019-11-28 17:34:45 +08:00
### Step 2 Start the Docker container
2019-11-28 17:15:21 +08:00
Start a CPU-only container:
```shell
2020-02-14 12:19:42 +08:00
$ docker run -it -p 19530:19530 -d milvusdb/milvus-cpu-build-env:latest
2019-11-28 17:15:21 +08:00
```
Start a GPU container:
2020-03-11 15:57:49 +08:00
- For nvidia docker 2:
2019-11-28 17:15:21 +08:00
```shell
2020-02-14 12:19:42 +08:00
$ docker run --runtime=nvidia -it -p 19530:19530 -d milvusdb/milvus-gpu-build-env:latest
2019-11-28 17:15:21 +08:00
```
2020-03-11 15:57:49 +08:00
- For nvidia container toolkit:
```shell
docker run --gpus all -it -p 19530:19530 -d milvusdb/milvus-gpu-build-env:latest
```
2019-11-28 17:15:21 +08:00
To enter the container:
```shell
2019-11-28 18:20:57 +08:00
$ docker exec -it [container_id] bash
2019-11-28 17:15:21 +08:00
```
2020-02-21 21:19:55 +08:00
2019-11-28 17:34:45 +08:00
### Step 3 Download Milvus source code
2019-11-28 17:15:21 +08:00
2020-02-14 12:19:42 +08:00
Download latest Milvus source code:
2019-11-28 17:15:21 +08:00
```shell
$ cd /home
2020-02-14 12:19:42 +08:00
$ git clone https://github.com/milvus-io/milvus
2019-11-28 17:15:21 +08:00
```
2020-02-14 12:19:42 +08:00
To enter its core directory:
2019-11-28 17:15:21 +08:00
```shell
2020-02-14 12:19:42 +08:00
$ cd ./milvus/core
2019-11-28 17:15:21 +08:00
```
2019-11-28 17:34:45 +08:00
### Step 4 Compile Milvus in the container
2019-11-28 17:15:21 +08:00
2020-03-19 10:17:31 +08:00
If you are using a CPU-only image:
1. run `build.sh` :
2020-02-14 12:19:42 +08:00
2019-11-28 17:15:21 +08:00
```shell
$ ./build.sh -t Release
```
2020-03-19 10:17:31 +08:00
2. Start Milvus server:
```shell
$ ./start_server.sh
```
If you are using a GPU-enabled image:
1. Add cuda library path to `LD_LIBRARY_PATH` :
```shell
$ export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
```
2. Add cuda binary path to `PATH` :
```shell
$ export PATH=/usr/local/cuda/bin:$PATH
```
3. Add a `-g` parameter to run `build.sh` :
2020-02-14 12:19:42 +08:00
2019-11-28 17:15:21 +08:00
```shell
$ ./build.sh -g -t Release
```
2020-03-19 10:17:31 +08:00
4. Start Milvus server:
2020-02-14 12:19:42 +08:00
2019-11-28 17:15:21 +08:00
```shell
$ ./start_server.sh
```
2019-11-13 15:43:24 +08:00
## Troubleshooting
2020-02-15 18:21:57 +08:00
2020-02-20 13:44:02 +08:00
### Error message: `protocol https not supported or disabled in libcurl`
Follow the steps below to solve this problem:
2020-03-03 00:25:22 +08:00
1. Make sure you have `libcurl4-openssl-dev` installed in your system.
2. Try reinstalling the latest CMake from source with `--system-curl` option:
2019-11-28 17:36:21 +08:00
```shell
2020-02-20 13:44:02 +08:00
$ ./bootstrap --system-curl
$ make
2019-11-28 17:36:21 +08:00
$ sudo make install
```
2020-02-14 12:19:42 +08:00
2020-02-20 13:44:02 +08:00
If the `--system-curl` command doesn't work, you can also reinstall CMake in **Ubuntu Software** on your local computer.
2020-02-15 18:21:57 +08:00
2020-02-20 13:44:02 +08:00
### Error message: `internal compiler error`
2020-02-15 18:21:57 +08:00
2020-02-21 21:19:55 +08:00
Try increasing the memory allocated to Docker. If this doesn't work, you can reduce the number of threads in CMake build in `[Milvus root path]/core/build.sh` .
```shell
make -j 8 install || exit 1 # The default number of threads is 8.
```
Note: You might also need to configure CMake build for faiss in `[Milvus root path]/core/src/index/thirdparty/faiss` .
2020-02-20 13:44:02 +08:00
### Error message: `error while loading shared libraries: libmysqlpp.so.3`
Follow the steps below to solve this problem:
2020-02-21 21:19:55 +08:00
2020-03-03 00:25:22 +08:00
1. Check whether `libmysqlpp.so.3` is correctly installed.
2. If `libmysqlpp.so.3` is installed, check whether it is added to `LD_LIBRARY_PATH` .
2020-02-15 18:21:57 +08:00
2020-02-20 13:44:02 +08:00
### CMake version is not supported
2020-02-15 18:21:57 +08:00
2020-02-20 13:44:02 +08:00
Follow the steps below to install a supported version of CMake:
2020-03-03 00:25:22 +08:00
1. Remove the unsupported version of CMake.
2. Get CMake 3.12 or higher. Here we get CMake 3.12.
2020-02-20 13:44:02 +08:00
```shell
$ wget https://cmake.org/files/v3.12/cmake-3.12.2-Linux-x86_64.tar.gz
```
2020-03-03 00:25:22 +08:00
3. Extract the file and install CMake.
2020-02-20 13:44:02 +08:00
```shell
$ tar zxvf cmake-3.12.2-Linux-x86_64.tar.gz
$ mv cmake-3.12.2-Linux-x86_64 /opt/cmake-3.12.2
$ ln -sf /opt/cmake-3.12.2/bin/* /usr/bin/
```