development.md 2.78 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
6
- [Go](https://go.dev/doc/install)
- C/C++ Compiler e.g. Clang on macOS, [TDM-GCC](https://jmeubank.github.io/tdm-gcc/download/) (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
50
> [!IMPORTANT]
> Ensure prerequisites are in `PATH` before running CMake.
51

Michael Yang's avatar
Michael Yang committed
52
53
> [!IMPORTANT]
> ROCm is not compatible with Visual Studio CMake generators. Use `-GNinja` when configuring the project.
54

Michael Yang's avatar
Michael Yang committed
55
56
> [!IMPORTANT]
> CUDA is only compatible with Visual Studio CMake generators.
57

Michael Yang's avatar
Michael Yang committed
58
Then, configure and build the project:
59

60
```shell
Michael Yang's avatar
Michael Yang committed
61
62
cmake -B build
cmake --build build --config Release
63
64
```

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

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

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

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

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

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

Michael Yang's avatar
Michael Yang committed
79
80
81
82
83
- [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)
84

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


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

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

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

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

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

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

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

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

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

To run tests, use `go test`:
117

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

## 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.