linux.md 2.06 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
```

Michael Yang's avatar
Michael Yang committed
13
## Manual install
Jeffrey Morgan's avatar
Jeffrey Morgan committed
14

Michael Yang's avatar
Michael Yang committed
15
### Download the `ollama` binary
Jeffrey Morgan's avatar
Jeffrey Morgan committed
16

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

19
```bash
20
sudo curl -L https://ollama.com/download/ollama-linux-amd64 -o /usr/bin/ollama
Michael Yang's avatar
Michael Yang committed
21
sudo chmod +x /usr/bin/ollama
Jeffrey Morgan's avatar
Jeffrey Morgan committed
22
23
```

Michael Yang's avatar
Michael Yang committed
24
### Adding Ollama as a startup service (recommended)
Jeffrey Morgan's avatar
Jeffrey Morgan committed
25
26
27

Create a user for Ollama:

28
```bash
Jeffrey Morgan's avatar
Jeffrey Morgan committed
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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:

52
```bash
Jeffrey Morgan's avatar
Jeffrey Morgan committed
53
54
55
sudo systemctl daemon-reload
sudo systemctl enable ollama
```
Jeffrey Morgan's avatar
Jeffrey Morgan committed
56

Michael Yang's avatar
Michael Yang committed
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
### 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
```

### Start Ollama

Start Ollama using `systemd`:

```bash
sudo systemctl start ollama
```

## Update

Update ollama by running the install script again:

```bash
80
curl -fsSL https://ollama.com/install.sh | sh
Michael Yang's avatar
Michael Yang committed
81
82
83
84
85
```

Or by downloading the ollama binary:

```bash
86
sudo curl -L https://ollama.com/download/ollama-linux-amd64 -o /usr/bin/ollama
Michael Yang's avatar
Michael Yang committed
87
88
89
90
sudo chmod +x /usr/bin/ollama
```

## Viewing logs
Jeffrey Morgan's avatar
Jeffrey Morgan committed
91
92
93

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

94
```bash
Jeffrey Morgan's avatar
Jeffrey Morgan committed
95
96
journalctl -u ollama
```
97
98
99
100

## Uninstall

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

102
```bash
Michael Yang's avatar
Michael Yang committed
103
104
105
sudo systemctl stop ollama
sudo systemctl disable ollama
sudo rm /etc/systemd/system/ollama.service
106
107
108
```

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

110
```bash
Michael Yang's avatar
Michael Yang committed
111
sudo rm $(which ollama)
112
113
```

114
Remove the downloaded models and Ollama service user and group:
115

116
```bash
Michael Yang's avatar
Michael Yang committed
117
118
sudo rm -r /usr/share/ollama
sudo userdel ollama
119
sudo groupdel ollama
120
```