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

23
### Download the `ollama` tar file
Jeffrey Morgan's avatar
Jeffrey Morgan committed
24

25
Ollama is distributed as a tar file including GPU library dependencies.
Jeffrey Morgan's avatar
Jeffrey Morgan committed
26

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

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

Create a user for Ollama:

35
```bash
Jeffrey Morgan's avatar
Jeffrey Morgan committed
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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:

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

Michael Yang's avatar
Michael Yang committed
64
65
66
67
68
69
70
71
72
73
### 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
```

74
75
76
77
78
### 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
79
80
81
82
83
84
85
86
87
88
89
90
91
### Start Ollama

Start Ollama using `systemd`:

```bash
sudo systemctl start ollama
```

## Update

Update ollama by running the install script again:

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

Or by downloading the ollama binary:

```bash
98
curl -fsSL https://ollama.com/download/ollama-linux-amd64.tgz | sudo tar -C /usr -zxf -
Michael Yang's avatar
Michael Yang committed
99
100
```

101
102
103
104
105
106
107
108
109
110
## 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
111
## Viewing logs
Jeffrey Morgan's avatar
Jeffrey Morgan committed
112
113
114

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

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

## Uninstall

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

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

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

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

135
Remove the downloaded models and Ollama service user and group:
136

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