INSTALL.md 5.9 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)

A
AmyYH 已提交
7
    - [Requirements](#requirements)
J
Jin Hai 已提交
8

A
AmyYH 已提交
9
    - [Compilation](#compilation)
J
Jin Hai 已提交
10

A
AmyYH 已提交
11
    - [Launch Milvus server](#launch-milvus-server)
J
Jin Hai 已提交
12

A
AmyYH 已提交
13
-   [Compile Milvus on Docker](#compile-milvus-on-docker)  
J
Jin Hai 已提交
14

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

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

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

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

-   [Troubleshooting](#troubleshooting)

A
AmyYH 已提交
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

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

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

A
AmyYH 已提交
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

A
AmyYH 已提交
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

55
-   CUDA 10.x (10.0, 10.1, 10.2)
J
Jin Hai 已提交
56 57

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

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

A
AmyYH 已提交
61
#### Step 1 Download Milvus source code
J
jielinxu 已提交
62

A
AmyYH 已提交
63
Download the latest Milvus source code and change directory:
X
Xiaohai Xu 已提交
64

J
jielinxu 已提交
65
```shell
A
AmyYH 已提交
66 67
$ git clone https://github.com/milvus-io/milvus
$ cd ./milvus/core
68 69
```

A
AmyYH 已提交
70
#### Step 2 Install dependencies
71

A
AmyYH 已提交
72
##### Install in Ubuntu
73 74

```shell
A
AmyYH 已提交
75
$ ./ubuntu_build_deps.sh
76 77
```

A
AmyYH 已提交
78
##### Install in CentOS
79

Z
Zhiru Zhu 已提交
80
```shell
A
AmyYH 已提交
81
$ ./centos7_build_deps.sh
J
jielinxu 已提交
82 83
```

A
AmyYH 已提交
84
#### Step 3 Build Milvus source code
85

Z
Zhiru Zhu 已提交
86
```shell
A
AmyYH 已提交
87
$ ./build.sh -t Debug
Z
Zhiru Zhu 已提交
88
```
A
AmyYH 已提交
89
When the build completes, everything that you need to run Milvus is under `[Milvus root path]/core/milvus`.
J
jielinxu 已提交
90

J
jielinxu 已提交
91
### Launch Milvus server
J
jielinxu 已提交
92 93 94 95 96 97 98

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

Add `lib/` directory to `LD_LIBRARY_PATH`

Z
Zhiru Zhu 已提交
99
```shell
100
$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:[Milvus root path]/core/milvus/lib
J
jielinxu 已提交
101 102 103 104
```

Then start Milvus server:

Z
Zhiru Zhu 已提交
105
```shell
J
jielinxu 已提交
106 107 108 109 110 111 112 113 114
$ cd scripts
$ ./start_server.sh
```

To stop Milvus server, run:

```shell
$ ./stop_server.sh
```
115

J
jielinxu 已提交
116 117
## Compile Milvus on Docker

118
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 已提交
119

J
jielinxu 已提交
120
### Step 1 Pull Milvus Docker images
J
jielinxu 已提交
121 122 123 124

Pull CPU-only image:

```shell
valerianian's avatar
valerianian 已提交
125
$ docker pull milvusdb/milvus-cpu-build-env:latest
J
jielinxu 已提交
126 127 128 129 130
```

Pull GPU-enabled image:

```shell
valerianian's avatar
valerianian 已提交
131
$ docker pull milvusdb/milvus-gpu-build-env:latest
J
jielinxu 已提交
132
```
J
jielinxu 已提交
133
### Step 2 Start the Docker container
J
jielinxu 已提交
134 135 136 137

Start a CPU-only container:

```shell
valerianian's avatar
valerianian 已提交
138
$ docker run -it -p 19530:19530 -d milvusdb/milvus-cpu-build-env:latest
J
jielinxu 已提交
139 140 141 142
```

Start a GPU container:

L
Lutkin Wang 已提交
143 144
- For nvidia docker 2:

J
jielinxu 已提交
145
```shell
valerianian's avatar
valerianian 已提交
146
$ docker run --runtime=nvidia -it -p 19530:19530 -d milvusdb/milvus-gpu-build-env:latest
J
jielinxu 已提交
147
```
L
Lutkin Wang 已提交
148 149 150 151 152 153 154

- For nvidia container toolkit:

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

J
jielinxu 已提交
155 156 157
To enter the container:

```shell
J
jielinxu 已提交
158
$ docker exec -it [container_id] bash
J
jielinxu 已提交
159
```
X
Xiaohai Xu 已提交
160

J
jielinxu 已提交
161
### Step 3 Download Milvus source code
J
jielinxu 已提交
162

valerianian's avatar
valerianian 已提交
163
Download latest Milvus source code:
J
jielinxu 已提交
164 165

```shell
valerianian's avatar
valerianian 已提交
166
$ git clone https://github.com/milvus-io/milvus
J
jielinxu 已提交
167 168
```

valerianian's avatar
valerianian 已提交
169
To enter its core directory:
J
jielinxu 已提交
170 171

```shell
valerianian's avatar
valerianian 已提交
172
$ cd ./milvus/core
J
jielinxu 已提交
173 174
```

J
jielinxu 已提交
175
### Step 4 Compile Milvus in the container
J
jielinxu 已提交
176

177 178 179
If you are using a CPU-only image:

1. run `build.sh`:
valerianian's avatar
valerianian 已提交
180

J
jielinxu 已提交
181 182 183 184
```shell
$ ./build.sh -t Release
```

185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205
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`:
valerianian's avatar
valerianian 已提交
206

J
jielinxu 已提交
207 208 209 210
```shell
$ ./build.sh -g -t Release
```

211
4. Start Milvus server:
valerianian's avatar
valerianian 已提交
212

J
jielinxu 已提交
213 214 215 216
```shell
$ ./start_server.sh
```

217
## Troubleshooting
218

219 220 221 222
### Error message: `protocol https not supported or disabled in libcurl`

Follow the steps below to solve this problem:

J
Jin Hai 已提交
223 224
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 已提交
225 226

   ```shell
227 228
   $ ./bootstrap --system-curl
   $ make
J
jielinxu 已提交
229 230
   $ sudo make install
   ```
valerianian's avatar
valerianian 已提交
231

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

234
### Error message: `internal compiler error`
235

X
Xiaohai Xu 已提交
236 237 238 239 240 241 242
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`.
243 244 245 246

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

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

J
Jin Hai 已提交
248 249
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`.
250

251
### CMake version is not supported
252

253 254
Follow the steps below to install a supported version of CMake:

J
Jin Hai 已提交
255 256
1.  Remove the unsupported version of CMake.
2.  Get CMake 3.12 or higher. Here we get CMake 3.12.
257 258 259 260 261

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

J
Jin Hai 已提交
262
3.  Extract the file and install CMake.
263 264 265 266 267 268

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