linux.md 2.98 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

Daniel Hiltgen's avatar
Daniel Hiltgen committed
23
### Download `ollama`
Jeffrey Morgan's avatar
Jeffrey Morgan committed
24

Daniel Hiltgen's avatar
Daniel Hiltgen committed
25
Download and extract the Linux package:
Jeffrey Morgan's avatar
Jeffrey Morgan committed
26

27
```bash
Daniel Hiltgen's avatar
Daniel Hiltgen committed
28
curl -fsSL https://ollama.com/download/ollama-linux-amd64.tgz | sudo tar zx -C /usr
Jeffrey Morgan's avatar
Jeffrey Morgan committed
29
30
```

31
32
33
34
35
If you have an AMD GPU, also download and extract the ROCm package into the same location
```bash
curl -fsSL https://ollama.com/download/ollama-linux-amd64-rocm.tgz | sudo tar zx -C /usr
```

Michael Yang's avatar
Michael Yang committed
36
### Adding Ollama as a startup service (recommended)
Jeffrey Morgan's avatar
Jeffrey Morgan committed
37
38
39

Create a user for Ollama:

40
```bash
Jeffrey Morgan's avatar
Jeffrey Morgan committed
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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:

64
```bash
Jeffrey Morgan's avatar
Jeffrey Morgan committed
65
66
67
sudo systemctl daemon-reload
sudo systemctl enable ollama
```
Jeffrey Morgan's avatar
Jeffrey Morgan committed
68

Michael Yang's avatar
Michael Yang committed
69
70
71
72
73
74
75
76
77
78
### 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
```

79
80
81
82
83
### 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
84
85
86
87
88
89
90
91
92
93
94
95
96
### Start Ollama

Start Ollama using `systemd`:

```bash
sudo systemctl start ollama
```

## Update

Update ollama by running the install script again:

```bash
97
curl -fsSL https://ollama.com/install.sh | sh
Michael Yang's avatar
Michael Yang committed
98
99
100
101
102
```

Or by downloading the ollama binary:

```bash
Daniel Hiltgen's avatar
Daniel Hiltgen committed
103
curl -fsSL https://ollama.com/download/ollama-linux-amd64.tgz | sudo tar zx -C /usr
Michael Yang's avatar
Michael Yang committed
104
105
```

106
107
108
109
110
111
112
113
114
115
## 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
116
## Viewing logs
Jeffrey Morgan's avatar
Jeffrey Morgan committed
117
118
119

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

120
```bash
Mohamed A. Fouad's avatar
Mohamed A. Fouad committed
121
journalctl -e -u ollama
Jeffrey Morgan's avatar
Jeffrey Morgan committed
122
```
123
124
125
126

## Uninstall

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

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

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

136
```bash
Michael Yang's avatar
Michael Yang committed
137
sudo rm $(which ollama)
138
139
```

140
Remove the downloaded models and Ollama service user and group:
141

142
```bash
Michael Yang's avatar
Michael Yang committed
143
144
sudo rm -r /usr/share/ollama
sudo userdel ollama
145
sudo groupdel ollama
146
```