Linux安装ollama方法(自动或手动安装)

一、自动安装ollama

ollama官网https://ollama.com/download/linux提供了直接安装的方法,一行命令即可完成安装

curl -fsSL https://ollama.com/install.sh | sh

二、手工安装ollama

实际使用中可能由于网速问题,非常慢,超时中断。
ollama也可以手工安装:https://github.com/ollama/ollama/blob/main/docs/linux.md

1. 安装ollama

下载包:
命令行
curl -L https://ollama.com/download/ollama-linux-amd64.tgz -o ollama-linux-amd64.tgz
或者点击https://ollama.com/download/ollama-linux-amd64.tgz下载安装包(大约1.54GB)

解压到/usr目录
sudo tar -C /usr -xzf ollama-linux-amd64.tgz

如果报错:bash: sudo: command not found
apt-get update
apt-get install sudo

测试是否安装成功
Start Ollama:
ollama serve
出现以下结果即为安装成功:
在这里插入图片描述

In another terminal, verify that Ollama is running:
ollama -v
结果如下:
在这里插入图片描述

2. AMD GPU和ARM64架构的Linux系统

查看当前的Linux系统架构
uname -m

输出
(1)x86_64
这是 64 位的 Intel 或 AMD 架构(也称为 AMD64)。
命令行curl -L https://ollama.com/download/ollama-linux-amd64.tgz -o ollama-linux-amd64.tgz
或者点击https://ollama.com/download/ollama-linux-amd64.tgz下载安装包(大约1.54GB)
(2)aarch64
这是 64 位的 ARM 架构。
sudo tar -C /usr -xzf ollama-linux-arm64.tgz
命令行或者点击https://ollama.com/download/ollama-linux-arm64.tgz下载安装包

3. 将Ollama设置为系统启动时自动运行(建议)

创建系统用户和用户组
sudo useradd -r -s /bin/false -U -m -d /usr/share/ollama ollama
sudo usermod -a -G ollama $(whoami)

创建服务文件
创建一个 systemd 服务文件来管理 Ollama 作为后台服务运行。该文件通常位于 /etc/systemd/system/ollama.service
文件内容如下:

[Unit]
Description=Ollama Service
After=network-online.target

[Service]
ExecStart=/usr/bin/ollama serve
User=ollama
Group=ollama
Restart=always
RestartSec=3
Environment="PATH=$PATH"

[Install]
WantedBy=default.target

启动服务
sudo systemctl daemon-reload
sudo systemctl enable ollama

4. 安装cuda(可选)

5. 安装AMD的ROCm(Radeon Open Compute)驱动程序(可选

ROCm 是 AMD 专为其 GPU 开发的开放计算平台,它允许你在 AMD GPU 上运行高性能计算、深度学习和机器学习的工作负载。如果你的系统配备了 AMD GPU,且你希望利用 AMD GPU 加速计算任务,那么你可以选择安装 ROCm v6(Radeon Open Compute Version 6)驱动程序。

下载安装ROCm v6.
https://rocm.docs.amd.com/projects/install-on-linux/en/latest/install/quick-start.html

查看ubuntu版本
uname -m && cat /etc/*release
lsb_release -a查看核版本
uname -srmv
在这里插入图片描述

6. Start Ollama

Start Ollama and verify it is running:
sudo systemctl start ollama
sudo systemctl status ollama

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.

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值