INSTALL.md 5.8 KB
Newer Older
J
jielinxu 已提交
1 2
# Install Milvus from Source Code

3 4
<!-- TOC -->

J
Jin Hai 已提交
5 6
-   [Build from source](#build-from-source)

X
Xiaohai Xu 已提交
7
  - [Requirements](#requirements)
J
Jin Hai 已提交
8

X
Xiaohai Xu 已提交
9
  - [Compilation](#compilation)
J
Jin Hai 已提交
10

X
Xiaohai Xu 已提交
11
  - [Launch Milvus server](#launch-milvus-server)
J
Jin Hai 已提交
12 13 14

-   [Compile Milvus on Docker](#compile-milvus-on-docker)

X
Xiaohai Xu 已提交
15
  - [Step 1 Pull Milvus Docker images](#step-1-pull-milvus-docker-images)
J
Jin Hai 已提交
16

X
Xiaohai Xu 已提交
17
  - [Step 2 Start the Docker container](#step-2-start-the-docker-container)
J
Jin Hai 已提交
18

X
Xiaohai Xu 已提交
19
  - [Step 3 Download Milvus source code](#step-3-download-milvus-source-code)
J
Jin Hai 已提交
20

X
Xiaohai Xu 已提交
21
  - [Step 4 Compile Milvus in the container](#step-4-compile-milvus-in-the-container)
J
Jin Hai 已提交
22 23 24

-   [Troubleshooting](#troubleshooting)

X
Xiaohai Xu 已提交
25
  - [Error message: `protocol https not supported or disabled in libcurl`](#error-message-protocol-https-not-supported-or-disabled-in-libcurl)
J
Jin Hai 已提交
26

X
Xiaohai Xu 已提交
27
  - [Error message: `internal compiler error`](#error-message-internal-compiler-error)
J
Jin Hai 已提交
28

X
Xiaohai Xu 已提交
29
  - [Error message: `error while loading shared libraries: libmysqlpp.so.3`](#error-message-error-while-loading-shared-libraries-libmysqlppso3)
J
Jin Hai 已提交
30

X
Xiaohai Xu 已提交
31
  - [CMake version is not supported](#cmake-version-is-not-supported)
32 33

<!-- /TOC -->
34

J
jielinxu 已提交
35 36 37
## Build from source

### Requirements
J
jielinxu 已提交
38

J
Jin Hai 已提交
39 40
-   Operating system

X
Xiaohai Xu 已提交
41
  - Ubuntu 18.04 or higher
J
Jin Hai 已提交
42

X
Xiaohai Xu 已提交
43
  - CentOS 7
44

45
  > 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.
46
  
J
Jin Hai 已提交
47 48 49 50 51
-   GCC 7.0 or higher to support C++ 17

-   CMake 3.12 or higher

-   Git
52

53
For GPU-enabled version, you will also need:
54

J
Jin Hai 已提交
55 56 57
-   CUDA 10.0 or higher

-   NVIDIA driver 418 or higher
J
jielinxu 已提交
58

J
jielinxu 已提交
59
### Compilation
J
jielinxu 已提交
60

J
jielinxu 已提交
61
#### Step 1 Install dependencies
J
jielinxu 已提交
62

X
Xiaohai Xu 已提交
63 64
##### Install in Ubuntu

J
jielinxu 已提交
65
```shell
66
$ cd [Milvus root path]/core
J
jielinxu 已提交
67 68 69
$ ./ubuntu_build_deps.sh
```

X
Xiaohai Xu 已提交
70
##### Install in CentOS
71

J
jielinxu 已提交
72
```shell
73
$ cd [Milvus root path]/core
X
Xiaohai Xu 已提交
74
$ ./centos7_build_deps.sh
75 76
```

X
Xiaohai Xu 已提交
77
#### Step 2 Build
78 79

```shell
X
Xiaohai Xu 已提交
80 81
$ cd [Milvus root path]/core
$ ./build.sh -t Debug
Z
Zhiru Zhu 已提交
82
```
83

X
Xiaohai Xu 已提交
84
or
85 86

```shell
X
Xiaohai Xu 已提交
87
$ ./build.sh -t Release
88 89 90 91
```

By default, it will build CPU-only version. To build GPU version, add `-g` option.

Z
Zhiru Zhu 已提交
92
```shell
93
$ ./build.sh -g
J
jielinxu 已提交
94 95
```

96 97
If you want to know the complete build options, run the following command.

Z
Zhiru Zhu 已提交
98 99 100 101
```shell
$./build.sh -h
```

X
Xiaohai Xu 已提交
102
When the build is completed, everything that you need in order to run Milvus will be installed under `[Milvus root path]/core/milvus`.
J
jielinxu 已提交
103

J
jielinxu 已提交
104
### Launch Milvus server
J
jielinxu 已提交
105 106 107 108 109 110 111

```shell
$ cd [Milvus root path]/core/milvus
```

Add `lib/` directory to `LD_LIBRARY_PATH`

Z
Zhiru Zhu 已提交
112
```shell
113
$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:[Milvus root path]/core/milvus/lib
J
jielinxu 已提交
114 115 116 117
```

Then start Milvus server:

Z
Zhiru Zhu 已提交
118
```shell
J
jielinxu 已提交
119 120 121 122 123 124 125 126 127
$ cd scripts
$ ./start_server.sh
```

To stop Milvus server, run:

```shell
$ ./stop_server.sh
```
128

J
jielinxu 已提交
129 130
## Compile Milvus on Docker

131
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.
J
jielinxu 已提交
132

J
jielinxu 已提交
133
### Step 1 Pull Milvus Docker images
J
jielinxu 已提交
134 135 136 137

Pull CPU-only image:

```shell
valerianian's avatar
valerianian 已提交
138
$ docker pull milvusdb/milvus-cpu-build-env:latest
J
jielinxu 已提交
139 140 141 142 143
```

Pull GPU-enabled image:

```shell
valerianian's avatar
valerianian 已提交
144
$ docker pull milvusdb/milvus-gpu-build-env:latest
J
jielinxu 已提交
145
```
J
jielinxu 已提交
146
### Step 2 Start the Docker container
J
jielinxu 已提交
147 148 149 150

Start a CPU-only container:

```shell
valerianian's avatar
valerianian 已提交
151
$ docker run -it -p 19530:19530 -d milvusdb/milvus-cpu-build-env:latest
J
jielinxu 已提交
152 153 154 155
```

Start a GPU container:

L
Lutkin Wang 已提交
156 157
- For nvidia docker 2:

J
jielinxu 已提交
158
```shell
valerianian's avatar
valerianian 已提交
159
$ docker run --runtime=nvidia -it -p 19530:19530 -d milvusdb/milvus-gpu-build-env:latest
J
jielinxu 已提交
160
```
L
Lutkin Wang 已提交
161 162 163 164 165 166 167

- For nvidia container toolkit:

```shell
docker run --gpus all -it -p 19530:19530 -d milvusdb/milvus-gpu-build-env:latest
```

J
jielinxu 已提交
168 169 170
To enter the container:

```shell
J
jielinxu 已提交
171
$ docker exec -it [container_id] bash
J
jielinxu 已提交
172
```
X
Xiaohai Xu 已提交
173

J
jielinxu 已提交
174
### Step 3 Download Milvus source code
J
jielinxu 已提交
175

valerianian's avatar
valerianian 已提交
176
Download latest Milvus source code:
J
jielinxu 已提交
177 178 179

```shell
$ cd /home
valerianian's avatar
valerianian 已提交
180
$ git clone https://github.com/milvus-io/milvus
J
jielinxu 已提交
181 182
```

valerianian's avatar
valerianian 已提交
183
To enter its core directory:
J
jielinxu 已提交
184 185

```shell
valerianian's avatar
valerianian 已提交
186
$ cd ./milvus/core
J
jielinxu 已提交
187 188
```

J
jielinxu 已提交
189
### Step 4 Compile Milvus in the container
J
jielinxu 已提交
190 191

If you are using a CPU-only image, compile it like this:
valerianian's avatar
valerianian 已提交
192

J
jielinxu 已提交
193 194 195 196
```shell
$ ./build.sh -t Release
```

J
jielinxu 已提交
197
If you are using a GPU-enabled image, you need to add a `-g` parameter:
valerianian's avatar
valerianian 已提交
198

J
jielinxu 已提交
199 200 201 202 203
```shell
$ ./build.sh -g -t Release
```

Then start Milvus server:
valerianian's avatar
valerianian 已提交
204

J
jielinxu 已提交
205 206 207 208
```shell
$ ./start_server.sh
```

209
## Troubleshooting
210

211 212 213 214
### Error message: `protocol https not supported or disabled in libcurl`

Follow the steps below to solve this problem:

J
Jin Hai 已提交
215 216
1.  Make sure you have `libcurl4-openssl-dev` installed in your system.
2.  Try reinstalling the latest CMake from source with `--system-curl` option:
J
jielinxu 已提交
217 218

   ```shell
219 220
   $ ./bootstrap --system-curl
   $ make
J
jielinxu 已提交
221 222
   $ sudo make install
   ```
valerianian's avatar
valerianian 已提交
223

224
   If the `--system-curl` command doesn't work, you can also reinstall CMake in **Ubuntu Software** on your local computer.
225

226
### Error message: `internal compiler error`
227

X
Xiaohai Xu 已提交
228 229 230 231 232 233 234
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`.
235 236 237 238

### Error message: `error while loading shared libraries: libmysqlpp.so.3`

Follow the steps below to solve this problem:
X
Xiaohai Xu 已提交
239

J
Jin Hai 已提交
240 241
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`.
242

243
### CMake version is not supported
244

245 246
Follow the steps below to install a supported version of CMake:

J
Jin Hai 已提交
247 248
1.  Remove the unsupported version of CMake.
2.  Get CMake 3.12 or higher. Here we get CMake 3.12.
249 250 251 252 253

    ```shell
    $ wget https://cmake.org/files/v3.12/cmake-3.12.2-Linux-x86_64.tar.gz
    ```

J
Jin Hai 已提交
254
3.  Extract the file and install CMake.
255 256 257 258 259 260

    ```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/
    ```