development.md 2.07 KB
Newer Older
Bruce MacDonald's avatar
Bruce MacDonald committed
1
2
# Development

3
4
5
6
- Install cmake or (optionally, required tools for GPUs)
- run `go generate ./...`
- run `go build .`

Jeffrey Morgan's avatar
Jeffrey Morgan committed
7
Install required tools:
Bruce MacDonald's avatar
Bruce MacDonald committed
8

9
10
11
12
- cmake version 3.24 or higher
- go version 1.20 or higher
- gcc version 11.4.0 or higher

13
```bash
14
brew install go cmake gcc
Bruce MacDonald's avatar
Bruce MacDonald committed
15
16
```

17
18
19
20
21
22
23
Optionally enable debugging and more verbose logging:

```bash
export CGO_CFLAGS="-g"
```

Get the required libraries and build the native LLM code:
24

25
```bash
26
go generate ./...
27
28
```

Matt Williams's avatar
Matt Williams committed
29
Then build ollama:
Bruce MacDonald's avatar
Bruce MacDonald committed
30

31
```bash
Matt Williams's avatar
Matt Williams committed
32
go build .
Bruce MacDonald's avatar
Bruce MacDonald committed
33
34
```

Jeffrey Morgan's avatar
Jeffrey Morgan committed
35
Now you can run `ollama`:
Bruce MacDonald's avatar
Bruce MacDonald committed
36

37
```bash
Jeffrey Morgan's avatar
Jeffrey Morgan committed
38
./ollama
Bruce MacDonald's avatar
Bruce MacDonald committed
39
```
40
41
42

## Building on Linux with GPU support

43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74

### Linux/Windows CUDA (NVIDIA)
*Your operating system distribution may already have packages for NVIDIA CUDA. Distro packages are often preferable, but instructions are distro-specific. Please consult distro-specific docs for dependencies if available!*

Install `cmake` and `golang` as well as [NVIDIA CUDA](https://developer.nvidia.com/cuda-downloads) development and runtime packages.
Then generate dependencies:
```
go generate ./...
```
Then build the binary:
```
go build .
```

### Linux ROCm (AMD)
*Your operating system distribution may already have packages for AMD ROCm and CLBlast. Distro packages are often preferable, but instructions are distro-specific. Please consult distro-specific docs for dependencies if available!*

Install [CLBlast](https://github.com/CNugteren/CLBlast/blob/master/doc/installation.md) and [ROCm](https://rocm.docs.amd.com/en/latest/deploy/linux/quick_start.html) developement packages first, as well as `cmake` and `golang`.
Adjust the paths below (correct for Arch) as appropriate for your distributions install locations and generate dependencies:
```
CLBlast_DIR=/usr/lib/cmake/CLBlast ROCM_PATH=/opt/rocm go generate ./...
```
Then build the binary:
```
go build .
```

ROCm requires elevated privileges to access the GPU at runtime.  On most distros you can add your user account to the `render` group, or run as root.

## Containerized Build

If you have Docker available, you can build linux binaries with `./scripts/build_linux.sh` which has the CUDA and ROCm dependencies included.