ollama升级下载很慢的手动安装办法(Ubuntu系统)
·
ollama升级下载很慢的手动安装办法(Ubuntu系统)
本文指包括Ubuntu系统下的ollama安装升级。
官方给出的一键安装命令:
curl -fsSL https://ollama.com/install.sh | sh
其中主要问题在于下载的时候,非常容易因为网络问题卡死或者失败,而即使是使用了一些妙妙工具,在这个脚本下似乎也没法正常起效。
此处,给出手动方式
1. 前往github下载安装包
进入页面:https://github.com/ollama/ollama/releases
因为是在ubuntu系统的PC上安装,所以下载文件:ollama-linux-amd64.tar.zst
2. 拉取官方的安装脚本
curl -fsSL -o install.sh https://ollama.com/install.sh
这会把脚本下载到当前路径,名字是install.sh
再将下载好的ollama-linux-amd64.tar.zst也放到相同的路径下。
3. 将脚本中的下载函数改成从本地解压
打开install.sh,找到其中的函数download_and_extract()
将原代码:
# Function to download and extract with fallback from zst to tgz
download_and_extract() {
local url_base="$1"
local dest_dir="$2"
local filename="$3"
# Check if .tar.zst is available
if curl --fail --silent --head --location "${url_base}/${filename}.tar.zst${VER_PARAM}" >/dev/null 2>&1; then
# zst file exists - check if we have zstd tool
if ! available zstd; then
error "This version requires zstd for extraction. Please install zstd and try again:
- Debian/Ubuntu: sudo apt-get install zstd
- RHEL/CentOS/Fedora: sudo dnf install zstd
- Arch: sudo pacman -S zstd"
fi
status "Downloading ${filename}.tar.zst"
curl --fail --show-error --location --progress-bar \
"${url_base}/${filename}.tar.zst${VER_PARAM}" | \
zstd -d | $SUDO tar -xf - -C "${dest_dir}"
return 0
fi
# Fall back to .tgz for older versions
status "Downloading ${filename}.tgz"
curl --fail --show-error --location --progress-bar \
"${url_base}/${filename}.tgz${VER_PARAM}" | \
$SUDO tar -xzf - -C "${dest_dir}"
}
替换为从本地解压并安装:
# Function to download and extract with fallback from zst to tgz
download_and_extract() {
local url_base="$1"
local dest_dir="$2"
local filename="$3"
# 检查系统中是否安装了 zstd
if ! available zstd; then
error "This version requires zstd for extraction. Please install zstd and try again:
- Debian/Ubuntu: sudo apt-get install zstd
- RHEL/CentOS/Fedora: sudo dnf install zstd
- Arch: sudo pacman -S zstd"
fi
status "Extracting local ${filename}.tar.zst"
# 删除了网络下载逻辑,直接从当前目录读取并解压本地的 .tar.zst 文件
cat "./${filename}.tar.zst" | zstd -d | $SUDO tar -xf - -C "${dest_dir}"
}
4. 运行安装脚本
给予脚本运行权限:
chmod +x install.sh
运行安装脚本:
./install.sh
安装完成后,新版本的ollama就成功安装好了,可以正常使用。
更多推荐
所有评论(0)