linux.md 3.09 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
Create a user and group for Ollama:
Jeffrey Morgan's avatar
Jeffrey Morgan committed
39

40
```bash
41
42
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
```

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
58
Environment="PATH=$PATH"
Jeffrey Morgan's avatar
Jeffrey Morgan committed
59
60
61
62
63
64
65

[Install]
WantedBy=default.target
```

Then start the service:

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

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

81
82
83
84
85
### 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
86
87
### Start Ollama

88
Start Ollama and verify it is running:
Michael Yang's avatar
Michael Yang committed
89
90
91

```bash
sudo systemctl start ollama
92
sudo systemctl status ollama
Michael Yang's avatar
Michael Yang committed
93
94
95
96
97
98
99
```

## Update

Update ollama by running the install script again:

```bash
100
curl -fsSL https://ollama.com/install.sh | sh
Michael Yang's avatar
Michael Yang committed
101
102
103
104
105
```

Or by downloading the ollama binary:

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

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

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

123
```bash
Mohamed A. Fouad's avatar
Mohamed A. Fouad committed
124
journalctl -e -u ollama
Jeffrey Morgan's avatar
Jeffrey Morgan committed
125
```
126
127
128
129

## Uninstall

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

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

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

139
```bash
Michael Yang's avatar
Michael Yang committed
140
sudo rm $(which ollama)
141
142
```

143
Remove the downloaded models and Ollama service user and group:
144

145
```bash
Michael Yang's avatar
Michael Yang committed
146
147
sudo rm -r /usr/share/ollama
sudo userdel ollama
148
sudo groupdel ollama
149
```