linux.md 3.49 KB
Newer Older
1
# Linux
Jeffrey Morgan's avatar
Jeffrey Morgan committed
2

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

5
To install Ollama, run the following command:
6

7
```shell
8
curl -fsSL https://ollama.com/install.sh | sh
9
10
```

11
## Manual install
Daniel Hiltgen's avatar
Daniel Hiltgen committed
12

13
Download and extract the package:
Daniel Hiltgen's avatar
Daniel Hiltgen committed
14

15
16
17
18
19
20
21
22
23
24
```shell
curl -L https://ollama.com/download/ollama-linux-amd64.tgz -o ollama-linux-amd64.tgz
sudo tar -C /usr -xzf ollama-linux-amd64.tgz
```

Start Ollama:

```shell
ollama serve
```
Jeffrey Morgan's avatar
Jeffrey Morgan committed
25

26
In another terminal, verify that Ollama is running:
Jeffrey Morgan's avatar
Jeffrey Morgan committed
27

28
29
30
31
32
```shell
ollama -v
```

### AMD GPU install
Jeffrey Morgan's avatar
Jeffrey Morgan committed
33

34
35
36
37
38
If you have an AMD GPU, also download and extract the additional ROCm package:

```shell
curl -L https://ollama.com/download/ollama-linux-amd64-rocm.tgz -o ollama-linux-amd64-rocm.tgz
sudo tar -C /usr -xzf ollama-linux-amd64-rocm.tgz
Jeffrey Morgan's avatar
Jeffrey Morgan committed
39
40
```

41
42
43
44
45
46
47
### ARM64 install

Download and extract the ARM64-specific package:

```shell
curl -L https://ollama.com/download/ollama-linux-arm64.tgz -o ollama-linux-arm64.tgz
sudo tar -C /usr -xzf ollama-linux-arm64.tgz
48
49
```

Michael Yang's avatar
Michael Yang committed
50
### Adding Ollama as a startup service (recommended)
Jeffrey Morgan's avatar
Jeffrey Morgan committed
51

52
Create a user and group for Ollama:
Jeffrey Morgan's avatar
Jeffrey Morgan committed
53

54
```shell
55
56
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
```

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
72
Environment="PATH=$PATH"
Jeffrey Morgan's avatar
Jeffrey Morgan committed
73
74
75
76
77
78
79

[Install]
WantedBy=default.target
```

Then start the service:

80
```shell
Jeffrey Morgan's avatar
Jeffrey Morgan committed
81
82
83
sudo systemctl daemon-reload
sudo systemctl enable ollama
```
Jeffrey Morgan's avatar
Jeffrey Morgan committed
84

85
### Install CUDA drivers (optional)
Michael Yang's avatar
Michael Yang committed
86
87
88
89
90

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

91
```shell
Michael Yang's avatar
Michael Yang committed
92
93
94
nvidia-smi
```

95
### Install AMD ROCm drivers (optional)
96

97
[Download and Install](https://rocm.docs.amd.com/projects/install-on-linux/en/latest/tutorial/quick-start.html) ROCm v6.
98

Michael Yang's avatar
Michael Yang committed
99
100
### Start Ollama

101
Start Ollama and verify it is running:
Michael Yang's avatar
Michael Yang committed
102

103
```shell
Michael Yang's avatar
Michael Yang committed
104
sudo systemctl start ollama
105
sudo systemctl status ollama
Michael Yang's avatar
Michael Yang committed
106
107
```

108
109
110
111
112
113
114
115
> [!NOTE]
> 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.

## Updating
Michael Yang's avatar
Michael Yang committed
116

117
Update Ollama by running the install script again:
Michael Yang's avatar
Michael Yang committed
118

119
```shell
120
curl -fsSL https://ollama.com/install.sh | sh
Michael Yang's avatar
Michael Yang committed
121
122
```

123
Or by re-downloading Ollama:
Michael Yang's avatar
Michael Yang committed
124

125
126
127
```shell
curl -L https://ollama.com/download/ollama-linux-amd64.tgz -o ollama-linux-amd64.tgz
sudo tar -C /usr -xzf ollama-linux-amd64.tgz
Michael Yang's avatar
Michael Yang committed
128
129
```

130
131
132
133
134
135
## 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:

136
137
```shell
curl -fsSL https://ollama.com/install.sh | OLLAMA_VERSION=0.3.9 sh
138
139
```

Michael Yang's avatar
Michael Yang committed
140
## Viewing logs
Jeffrey Morgan's avatar
Jeffrey Morgan committed
141
142
143

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

144
```shell
Mohamed A. Fouad's avatar
Mohamed A. Fouad committed
145
journalctl -e -u ollama
Jeffrey Morgan's avatar
Jeffrey Morgan committed
146
```
147
148
149
150

## Uninstall

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

152
```shell
Michael Yang's avatar
Michael Yang committed
153
154
155
sudo systemctl stop ollama
sudo systemctl disable ollama
sudo rm /etc/systemd/system/ollama.service
156
157
158
```

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

160
```shell
Michael Yang's avatar
Michael Yang committed
161
sudo rm $(which ollama)
162
163
```

164
Remove the downloaded models and Ollama service user and group:
165

166
```shell
Michael Yang's avatar
Michael Yang committed
167
168
sudo rm -r /usr/share/ollama
sudo userdel ollama
169
sudo groupdel ollama
170
```