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

Michael Yang's avatar
Michael Yang committed
3
Install prerequisites:
4

Michael Yang's avatar
Michael Yang committed
5
- [Go](https://go.dev/doc/install)
6
- C/C++ Compiler e.g. Clang on macOS, [TDM-GCC](https://github.com/jmeubank/tdm-gcc/releases/latest) (Windows amd64) or [llvm-mingw](https://github.com/mstorsjo/llvm-mingw) (Windows arm64), GCC/Clang on Linux.
7

Michael Yang's avatar
Michael Yang committed
8
Then build and run Ollama from the root directory of the repository:
9

10
```shell
Michael Yang's avatar
Michael Yang committed
11
go run . serve
12
13
```

Michael Yang's avatar
Michael Yang committed
14
## macOS (Apple Silicon)
15

Michael Yang's avatar
Michael Yang committed
16
macOS Apple Silicon supports Metal which is built-in to the Ollama binary. No additional steps are required.
17

Michael Yang's avatar
Michael Yang committed
18
## macOS (Intel)
19

Michael Yang's avatar
Michael Yang committed
20
Install prerequisites:
21

Michael Yang's avatar
Michael Yang committed
22
- [CMake](https://cmake.org/download/) or `brew install cmake`
23

Michael Yang's avatar
Michael Yang committed
24
Then, configure and build the project:
25

26
```shell
Michael Yang's avatar
Michael Yang committed
27
28
cmake -B build
cmake --build build
29
30
```

Michael Yang's avatar
Michael Yang committed
31
Lastly, run Ollama:
32

33
```shell
Michael Yang's avatar
Michael Yang committed
34
go run . serve
35
36
```

Michael Yang's avatar
Michael Yang committed
37
## Windows
38

Michael Yang's avatar
Michael Yang committed
39
Install prerequisites:
40

Michael Yang's avatar
Michael Yang committed
41
42
43
44
45
46
47
- [CMake](https://cmake.org/download/)
- [Visual Studio 2022](https://visualstudio.microsoft.com/downloads/) including the Native Desktop Workload
- (Optional) AMD GPU support
    - [ROCm](https://rocm.github.io/install.html)
    - [Ninja](https://github.com/ninja-build/ninja/releases)
- (Optional) NVIDIA GPU support
    - [CUDA SDK](https://developer.nvidia.com/cuda-downloads?target_os=Windows&target_arch=x86_64&target_version=11&target_type=exe_network)
48

Michael Yang's avatar
Michael Yang committed
49
Then, configure and build the project:
50

51
```shell
Michael Yang's avatar
Michael Yang committed
52
53
cmake -B build
cmake --build build --config Release
54
55
```

56
57
58
59
60
61
62
63
> [!IMPORTANT]
> Building for ROCm requires additional flags:
> ```
> cmake -B build -G Ninja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
> cmake --build build --config Release
> ```


Michael Yang's avatar
Michael Yang committed
64
Lastly, run Ollama:
65

66
```shell
Michael Yang's avatar
Michael Yang committed
67
68
go run . serve
```
69

Michael Yang's avatar
Michael Yang committed
70
## Windows (ARM)
71

Michael Yang's avatar
Michael Yang committed
72
Windows ARM does not support additional acceleration libraries at this time.
73

Michael Yang's avatar
Michael Yang committed
74
## Linux
75

Michael Yang's avatar
Michael Yang committed
76
Install prerequisites:
77

Michael Yang's avatar
Michael Yang committed
78
79
80
81
82
- [CMake](https://cmake.org/download/) or `sudo apt install cmake` or `sudo dnf install cmake`
- (Optional) AMD GPU support
    - [ROCm](https://rocm.docs.amd.com/projects/install-on-linux/en/latest/install/quick-start.html)
- (Optional) NVIDIA GPU support
    - [CUDA SDK](https://developer.nvidia.com/cuda-downloads)
83

Michael Yang's avatar
Michael Yang committed
84
85
> [!IMPORTANT]
> Ensure prerequisites are in `PATH` before running CMake.
86
87


Michael Yang's avatar
Michael Yang committed
88
Then, configure and build the project:
89

90
```shell
Michael Yang's avatar
Michael Yang committed
91
92
cmake -B build
cmake --build build
93
94
```

Michael Yang's avatar
Michael Yang committed
95
Lastly, run Ollama:
96

97
```shell
Michael Yang's avatar
Michael Yang committed
98
go run . serve
99
100
```

Michael Yang's avatar
Michael Yang committed
101
## Docker
102

103
```shell
Michael Yang's avatar
Michael Yang committed
104
docker build .
105
106
```

Michael Yang's avatar
Michael Yang committed
107
108
### ROCm

109
```shell
Michael Yang's avatar
Michael Yang committed
110
docker build --build-arg FLAVOR=rocm .
111
112
```

Michael Yang's avatar
Michael Yang committed
113
114
115
## Running tests

To run tests, use `go test`:
116

117
```shell
Michael Yang's avatar
Michael Yang committed
118
go test ./...
119
```
120
121
122
123
124
125
126
127
128
129
130

## Library detection

Ollama looks for acceleration libraries in the following paths relative to the `ollama` executable:

* `./lib/ollama` (Windows)
* `../lib/ollama` (Linux)
* `.` (macOS)
* `build/lib/ollama` (for development)

If the libraries are not found, Ollama will not run with any acceleration libraries.