2019-11-01 07:42:04 +00:00
# Install Milvus from Source Code
2019-11-28 09:18:01 +00:00
- [Build from source ](#build-from-source )
- [Compile Milvus on Docker ](#compile-milvus-on-docker )
2020-02-15 10:21:57 +00:00
- [Troubleshooting ](#troubleshooting )
2019-12-02 03:46:29 +00:00
2019-11-28 09:15:21 +00:00
## Build from source
### Requirements
2019-11-01 07:42:04 +00:00
- Ubuntu 18.04 or higher
2019-11-19 01:16:58 +00:00
2019-11-19 03:49:05 +00:00
If your operating system is not Ubuntu 18.04 or higher, we recommend you to pull a [docker image of Ubuntu 18.04 ](https://docs.docker.com/install/linux/docker-ce/ubuntu/ ) as your compilation environment.
2019-11-19 01:16:58 +00:00
2020-01-06 09:40:28 +00:00
- GCC 7.0 or higher to support C++17
2019-11-13 07:43:24 +00:00
- CMake 3.12 or higher
2019-11-28 09:15:21 +00:00
##### For GPU-enabled version, you will also need:
2019-11-13 07:43:24 +00:00
2019-11-01 07:42:04 +00:00
- CUDA 10.0 or higher
- NVIDIA driver 418 or higher
2019-11-28 09:15:21 +00:00
### Compilation
2019-11-01 07:42:04 +00:00
2019-11-28 09:15:21 +00:00
#### Step 1 Install dependencies
2019-11-01 07:42:04 +00:00
```shell
2019-11-13 07:43:24 +00:00
$ cd [Milvus root path]/core
2019-11-01 07:42:04 +00:00
$ ./ubuntu_build_deps.sh
```
2019-11-28 09:15:21 +00:00
#### Step 2 Build
2019-11-01 07:42:04 +00:00
```shell
2019-11-13 07:43:24 +00:00
$ cd [Milvus root path]/core
2019-11-01 07:42:04 +00:00
$ ./build.sh -t Debug
or
$ ./build.sh -t Release
2019-11-13 08:18:18 +00:00
```
2019-11-13 07:43:24 +00:00
2019-11-28 09:15:21 +00:00
By default, it will build CPU-only version. To build GPU version, add `-g` option
2019-11-15 09:44:38 +00:00
```shell
2019-11-13 07:43:24 +00:00
$ ./build.sh -g
2019-11-01 07:42:04 +00:00
```
2019-11-15 09:44:38 +00:00
If you want to know the complete build options, run
```shell
$./build.sh -h
```
2019-11-01 07:42:04 +00:00
When the build is completed, all the stuff that you need in order to run Milvus will be installed under `[Milvus root path]/core/milvus` .
2019-11-28 09:15:21 +00:00
### Launch Milvus server
2019-11-01 07:42:04 +00:00
```shell
$ cd [Milvus root path]/core/milvus
```
Add `lib/` directory to `LD_LIBRARY_PATH`
2019-11-15 09:44:38 +00:00
```shell
2019-11-13 07:43:24 +00:00
$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:[Milvus root path]/core/milvus/lib
2019-11-01 07:42:04 +00:00
```
Then start Milvus server:
2019-11-15 09:44:38 +00:00
```shell
2019-11-01 07:42:04 +00:00
$ cd scripts
$ ./start_server.sh
```
To stop Milvus server, run:
```shell
$ ./stop_server.sh
```
2019-11-13 07:43:24 +00:00
2019-11-28 09:15:21 +00:00
## Compile Milvus on Docker
2020-02-14 04:19:42 +00:00
With the following Docker images, you should be able to compile Milvus on any Linux platform that run Docker. To build a GPU supported Milvus, you need to install [NVIDIA Docker ](https://github.com/NVIDIA/nvidia-docker/ ) first.
2019-11-28 09:15:21 +00:00
2019-11-28 09:34:45 +00:00
### Step 1 Pull Milvus Docker images
2019-11-28 09:15:21 +00:00
Pull CPU-only image:
```shell
2020-02-14 04:19:42 +00:00
$ docker pull milvusdb/milvus-cpu-build-env:latest
2019-11-28 09:15:21 +00:00
```
Pull GPU-enabled image:
```shell
2020-02-14 04:19:42 +00:00
$ docker pull milvusdb/milvus-gpu-build-env:latest
2019-11-28 09:15:21 +00:00
```
2019-11-28 09:34:45 +00:00
### Step 2 Start the Docker container
2019-11-28 09:15:21 +00:00
Start a CPU-only container:
```shell
2020-02-14 04:19:42 +00:00
$ docker run -it -p 19530:19530 -d milvusdb/milvus-cpu-build-env:latest
2019-11-28 09:15:21 +00:00
```
Start a GPU container:
```shell
2020-02-14 04:19:42 +00:00
$ docker run --runtime=nvidia -it -p 19530:19530 -d milvusdb/milvus-gpu-build-env:latest
2019-11-28 09:15:21 +00:00
```
To enter the container:
```shell
2019-11-28 10:20:57 +00:00
$ docker exec -it [container_id] bash
2019-11-28 09:15:21 +00:00
```
2019-11-28 09:34:45 +00:00
### Step 3 Download Milvus source code
2019-11-28 09:15:21 +00:00
2020-02-14 04:19:42 +00:00
Download latest Milvus source code:
2019-11-28 09:15:21 +00:00
```shell
$ cd /home
2020-02-14 04:19:42 +00:00
$ git clone https://github.com/milvus-io/milvus
2019-11-28 09:15:21 +00:00
```
2020-02-14 04:19:42 +00:00
To enter its core directory:
2019-11-28 09:15:21 +00:00
```shell
2020-02-14 04:19:42 +00:00
$ cd ./milvus/core
2019-11-28 09:15:21 +00:00
```
2019-11-28 09:34:45 +00:00
### Step 4 Compile Milvus in the container
2019-11-28 09:15:21 +00:00
If you are using a CPU-only image, compile it like this:
2020-02-14 04:19:42 +00:00
2019-11-28 09:15:21 +00:00
```shell
$ ./build.sh -t Release
```
2019-11-28 09:33:52 +00:00
If you are using a GPU-enabled image, you need to add a `-g` parameter:
2020-02-14 04:19:42 +00:00
2019-11-28 09:15:21 +00:00
```shell
$ ./build.sh -g -t Release
```
Then start Milvus server:
2020-02-14 04:19:42 +00:00
2019-11-28 09:15:21 +00:00
```shell
$ ./start_server.sh
```
2019-11-13 07:43:24 +00:00
## Troubleshooting
2020-02-15 10:21:57 +00:00
2019-11-13 07:43:24 +00:00
1. If you encounter the following error when compiling:
`protocol https not supported or disabled in libcurl` .
First, make sure you have `libcurl4-openssl-dev` installed in your system.
2019-12-02 03:46:29 +00:00
Then try reinstalling the latest CMake from source with `--system-curl` option:
2019-11-28 09:36:21 +00:00
```shell
$ ./bootstrap --system-curl
$ make
$ sudo make install
```
2020-02-19 02:24:58 +00:00
If the `--system-curl` command doesn't work, you can also reinstall CMake in **Ubuntu Software** on your local computer.
2020-02-14 04:19:42 +00:00
2020-02-15 10:21:57 +00:00
2. If you encounter the following error when compiling in a Docker image: `internal compiler error` . Try increasing the memory allocated to docker first.
3. If you encounter the following error during compilation:
```
.../bin/milvus_server: error while loading shared libraries: libmysqlpp.so.3: cannot open shared object file: No such file or directory
```
Try the following solutions:
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` .