linux.md 2.9 KB
Newer Older
Michael Yang's avatar
Michael Yang committed
1
# Ollama on Linux
Jeffrey Morgan's avatar
Jeffrey Morgan committed
2

Michael Yang's avatar
Michael Yang committed
3
## Install
4

Michael Yang's avatar
Michael Yang committed
5
Install Ollama running this one-liner:
6

Michael Yang's avatar
Michael Yang committed
7
>
8

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

Daniel Hiltgen's avatar
Daniel Hiltgen committed
13
14
15
16
17
18
19
20
## AMD Radeon GPU support

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.

Michael Yang's avatar
Michael Yang committed
21
## Manual install
Jeffrey Morgan's avatar
Jeffrey Morgan committed
22

Michael Yang's avatar
Michael Yang committed
23
### Download the `ollama` binary
Jeffrey Morgan's avatar
Jeffrey Morgan committed
24

Michael Yang's avatar
Michael Yang committed
25
Ollama is distributed as a self-contained binary. Download it to a directory in your PATH:
Jeffrey Morgan's avatar
Jeffrey Morgan committed
26

27
```bash
28
sudo curl -L https://ollama.com/download/ollama-linux-amd64 -o /usr/bin/ollama
Michael Yang's avatar
Michael Yang committed
29
sudo chmod +x /usr/bin/ollama
Jeffrey Morgan's avatar
Jeffrey Morgan committed
30
31
```

Michael Yang's avatar
Michael Yang committed
32
### Adding Ollama as a startup service (recommended)
Jeffrey Morgan's avatar
Jeffrey Morgan committed
33
34
35

Create a user for Ollama:

36
```bash
Jeffrey Morgan's avatar
Jeffrey Morgan committed
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
sudo useradd -r -s /bin/false -m -d /usr/share/ollama ollama
```

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

[Install]
WantedBy=default.target
```

Then start the service:

60
```bash
Jeffrey Morgan's avatar
Jeffrey Morgan committed
61
62
63
sudo systemctl daemon-reload
sudo systemctl enable ollama
```
Jeffrey Morgan's avatar
Jeffrey Morgan committed
64

Michael Yang's avatar
Michael Yang committed
65
66
67
68
69
70
71
72
73
74
### Install CUDA drivers (optional – for Nvidia GPUs)

[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:

```bash
nvidia-smi
```

75
76
77
78
79
### Install ROCm (optional - for Radeon GPUs)
[Download and Install](https://rocm.docs.amd.com/projects/install-on-linux/en/latest/tutorial/quick-start.html)

Make sure to install ROCm v6

Michael Yang's avatar
Michael Yang committed
80
81
82
83
84
85
86
87
88
89
90
91
92
### Start Ollama

Start Ollama using `systemd`:

```bash
sudo systemctl start ollama
```

## Update

Update ollama by running the install script again:

```bash
93
curl -fsSL https://ollama.com/install.sh | sh
Michael Yang's avatar
Michael Yang committed
94
95
96
97
98
```

Or by downloading the ollama binary:

```bash
99
sudo curl -L https://ollama.com/download/ollama-linux-amd64 -o /usr/bin/ollama
Michael Yang's avatar
Michael Yang committed
100
101
102
sudo chmod +x /usr/bin/ollama
```

103
104
105
106
107
108
109
110
111
112
## Installing specific versions

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

For example:

```
curl -fsSL https://ollama.com/install.sh | OLLAMA_VERSION=0.1.32 sh
```

Michael Yang's avatar
Michael Yang committed
113
## Viewing logs
Jeffrey Morgan's avatar
Jeffrey Morgan committed
114
115
116

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

117
```bash
Mohamed A. Fouad's avatar
Mohamed A. Fouad committed
118
journalctl -e -u ollama
Jeffrey Morgan's avatar
Jeffrey Morgan committed
119
```
120
121
122
123

## Uninstall

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

125
```bash
Michael Yang's avatar
Michael Yang committed
126
127
128
sudo systemctl stop ollama
sudo systemctl disable ollama
sudo rm /etc/systemd/system/ollama.service
129
130
131
```

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

133
```bash
Michael Yang's avatar
Michael Yang committed
134
sudo rm $(which ollama)
135
136
```

137
Remove the downloaded models and Ollama service user and group:
138

139
```bash
Michael Yang's avatar
Michael Yang committed
140
141
sudo rm -r /usr/share/ollama
sudo userdel ollama
142
sudo groupdel ollama
143
```