linux.mdx 3.97 KB
Newer Older
1
2
3
---
title: Linux
---
Jeffrey Morgan's avatar
Jeffrey Morgan committed
4

Michael Yang's avatar
Michael Yang committed
5
## Install
6

7
To install Ollama, run the following command:
8

9
```shell
10
curl -fsSL https://ollama.com/install.sh | sh
11
12
```

13
## Manual install
Daniel Hiltgen's avatar
Daniel Hiltgen committed
14

15
16
17
18
<Note>
  If you are upgrading from a prior version, you should remove the old libraries
  with `sudo rm -rf /usr/lib/ollama` first.
</Note>
19

20
Download and extract the package:
Daniel Hiltgen's avatar
Daniel Hiltgen committed
21

22
```shell
23
24
curl -fsSL https://ollama.com/download/ollama-linux-amd64.tgz \
    | sudo tar zx -C /usr
25
26
27
28
29
30
31
```

Start Ollama:

```shell
ollama serve
```
Jeffrey Morgan's avatar
Jeffrey Morgan committed
32

33
In another terminal, verify that Ollama is running:
Jeffrey Morgan's avatar
Jeffrey Morgan committed
34

35
36
37
38
39
```shell
ollama -v
```

### AMD GPU install
Jeffrey Morgan's avatar
Jeffrey Morgan committed
40

41
If you have an AMD GPU, also download and extract the additional ROCm package:
42
43

```shell
44
45
curl -fsSL https://ollama.com/download/ollama-linux-amd64-rocm.tgz \
    | sudo tar zx -C /usr
Jeffrey Morgan's avatar
Jeffrey Morgan committed
46
47
```

48
49
50
51
52
### ARM64 install

Download and extract the ARM64-specific package:

```shell
53
54
curl -fsSL https://ollama.com/download/ollama-linux-arm64.tgz \
    | sudo tar zx -C /usr
55
56
```

Michael Yang's avatar
Michael Yang committed
57
### Adding Ollama as a startup service (recommended)
Jeffrey Morgan's avatar
Jeffrey Morgan committed
58

59
Create a user and group for Ollama:
Jeffrey Morgan's avatar
Jeffrey Morgan committed
60

61
```shell
62
63
sudo useradd -r -s /bin/false -U -m -d /usr/share/ollama ollama
sudo usermod -a -G ollama $(whoami)
Jeffrey Morgan's avatar
Jeffrey Morgan committed
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
```

Create a service file in `/etc/systemd/system/ollama.service`:

```ini
[Unit]
Description=Ollama Service
After=network-online.target

[Service]
ExecStart=/usr/bin/ollama serve
User=ollama
Group=ollama
Restart=always
RestartSec=3
79
Environment="PATH=$PATH"
Jeffrey Morgan's avatar
Jeffrey Morgan committed
80
81

[Install]
82
WantedBy=multi-user.target
Jeffrey Morgan's avatar
Jeffrey Morgan committed
83
84
85
86
```

Then start the service:

87
```shell
Jeffrey Morgan's avatar
Jeffrey Morgan committed
88
89
90
sudo systemctl daemon-reload
sudo systemctl enable ollama
```
Jeffrey Morgan's avatar
Jeffrey Morgan committed
91

92
### Install CUDA drivers (optional)
Michael Yang's avatar
Michael Yang committed
93
94
95
96
97

[Download and install](https://developer.nvidia.com/cuda-downloads) CUDA.

Verify that the drivers are installed by running the following command, which should print details about your GPU:

98
```shell
Michael Yang's avatar
Michael Yang committed
99
100
101
nvidia-smi
```

102
### Install AMD ROCm drivers (optional)
103

104
[Download and Install](https://rocm.docs.amd.com/projects/install-on-linux/en/latest/tutorial/quick-start.html) ROCm v6.
105

Michael Yang's avatar
Michael Yang committed
106
107
### Start Ollama

108
Start Ollama and verify it is running:
Michael Yang's avatar
Michael Yang committed
109

110
```shell
Michael Yang's avatar
Michael Yang committed
111
sudo systemctl start ollama
112
sudo systemctl status ollama
Michael Yang's avatar
Michael Yang committed
113
114
```

115
116
117
118
119
120
121
<Note>
  While AMD has contributed the `amdgpu` driver upstream to the official linux
  kernel source, the version is older and may not support all ROCm features. We
  recommend you install the latest driver from
  https://www.amd.com/en/support/linux-drivers for best support of your Radeon
  GPU.
</Note>
122

123
124
125
126
## Customizing

To customize the installation of Ollama, you can edit the systemd service file or the environment variables by running:

127
```shell
128
129
130
131
132
133
134
135
136
137
sudo systemctl edit ollama
```

Alternatively, create an override file manually in `/etc/systemd/system/ollama.service.d/override.conf`:

```ini
[Service]
Environment="OLLAMA_DEBUG=1"
```

138
## Updating
Michael Yang's avatar
Michael Yang committed
139

140
Update Ollama by running the install script again:
Michael Yang's avatar
Michael Yang committed
141

142
```shell
143
curl -fsSL https://ollama.com/install.sh | sh
Michael Yang's avatar
Michael Yang committed
144
145
```

146
Or by re-downloading Ollama:
Michael Yang's avatar
Michael Yang committed
147

148
```shell
149
150
curl -fsSL https://ollama.com/download/ollama-linux-amd64.tgz \
    | sudo tar zx -C /usr
Michael Yang's avatar
Michael Yang committed
151
152
```

153
154
## Installing specific versions

155
Use `OLLAMA_VERSION` environment variable with the install script to install a specific version of Ollama, including pre-releases. You can find the version numbers in the [releases page](https://github.com/ollama/ollama/releases).
156
157
158

For example:

159
```shell
160
curl -fsSL https://ollama.com/install.sh | OLLAMA_VERSION=0.5.7 sh
161
162
```

Michael Yang's avatar
Michael Yang committed
163
## Viewing logs
Jeffrey Morgan's avatar
Jeffrey Morgan committed
164
165
166

To view logs of Ollama running as a startup service, run:

167
```shell
Mohamed A. Fouad's avatar
Mohamed A. Fouad committed
168
journalctl -e -u ollama
Jeffrey Morgan's avatar
Jeffrey Morgan committed
169
```
170
171
172
173

## Uninstall

Remove the ollama service:
Michael Yang's avatar
Michael Yang committed
174

175
```shell
Michael Yang's avatar
Michael Yang committed
176
177
178
sudo systemctl stop ollama
sudo systemctl disable ollama
sudo rm /etc/systemd/system/ollama.service
179
180
```

181
182
183
184
185
186
Remove ollama libraries from your lib directory (either `/usr/local/lib`, `/usr/lib`, or `/lib`):

```shell
sudo rm -r $(which ollama | tr 'bin' 'lib')
```

187
Remove the ollama binary from your bin directory (either `/usr/local/bin`, `/usr/bin`, or `/bin`):
Michael Yang's avatar
Michael Yang committed
188

189
```shell
Michael Yang's avatar
Michael Yang committed
190
sudo rm $(which ollama)
191
192
```

193
Remove the downloaded models and Ollama service user and group:
194

195
```shell
Michael Yang's avatar
Michael Yang committed
196
sudo userdel ollama
197
sudo groupdel ollama
198
sudo rm -r /usr/share/ollama
199
```