AI资讯
掌握人工智能AI动态,领略未来风采!
如何在安卓系统上离线运行 AI 大语言模型
一、参考文档:
termux 使用指南:
https://zhuanlan.zhihu.com/p/612865403?utm_id=0
安卓手机上安装 Linux 开源模拟器-Termux:
https://cloud.tencent.com/developer/article/2025280
termux 本地部署 ollama 与 gemma,让你的手机离线跑 ai
https://www.bilibili.com/read/cv32453978/?jump_opus=1
二、安装指南
1、安装 termux 安卓应用
https://github.com/termux/termux-app/releases
下载 arm64 版本安装
2、设置存储权限与换软件源
在 termux 里输入 termux-setup-storage 回车,然后再 y 确定回车,接着会有弹窗请求存储权限,点允许就行
如果没有阿里巴巴的,就选择清华的数据源
3、用 proot-distro 安装 debian
先执行安装
pkg install proot-distro
再安装 debian (也可以是 ubuntu)
proot-distro install debian
安装成功界面如下:
4、登录 debian 系统安装软件包
进入 debian
proot-distro login debian
安装大语言应用工具:ollama
curl -L -o install.sh https://ollama.com/install.sh
bash install.sh
安装完成后,你可以通过运行以下命令来验证 Ollama 是否正确安装:
ollama --version
这里会发现它提示连接不上 ollama 服务
先执行命令启动服务
ollama serve
新建会话窗口(在 termux 左上角往右划,左下角有个新建窗口,如果不行就右键长按 termux 应用新建 session)
登录 debian:
proot-distro login debian
然后拉取 gemma 预训练数据:
ollama run gemma:2b
等进度条跑完下载就行了
测试:
curl http://localhost:11434/api/generate -d '{ "model": "gemma:2b", "prompt": "What is your name?" }' 如果一切正常,你应该会收到一个包含 Gemma 模型回答的 JSON 响应。