当前位置: 首页 > news >正文

LocalAI 部署(主要针对 mac m2 启动)

LocalAI 部署

介绍

LocalAI 是免费的开源 OpenAI 替代方案。 LocalAI 充当 REST API 的直接替代品,与本地推理的 OpenAI API 规范兼容。 它无需 GPU,还有多种用途集成,允许您使用消费级硬件在本地或本地运行 LLM、生成图像、音频等等,支持多个模型系列。

启动方式

1. Linux AMD64 docker 启动

helm repo add go-skynet https://go-skynet.github.io/helm-charts/
helm search repo go-skynet
helm pull go-skynet/local-ai
tar -xvf local-ai-3.1.0.tgz && cd local-ai
vim value.yaml
# 取消下面截图的注释

在这里插入图片描述

helm install --create-namespace local-ai . -n local-ai -f values.yaml

2. Mac M2 手动启动

# install build dependencies
brew install abseil cmake go grpc protobuf wget# clone the repo
git clone https://github.com/go-skynet/LocalAI.gitcd LocalAI# build the binary
make build
# make BUILD_TYPE=metal build
## Set `gpu_layers: 1` to your YAML model config file and `f16: true`
## Note: only models quantized with q4_0 are supported!# Download gpt4all-j to models/
wget https://gpt4all.io/models/ggml-gpt4all-j.bin -O models/ggml-gpt4all-j# Use a template from the examples
cp -rf prompt-templates/ggml-gpt4all-j.tmpl models/# Run LocalAI
./local-ai --models-path=./models/ --debug=true
使用
# Now API is accessible at localhost:8080
curl http://localhost:8080/v1/models
curl http://localhost:8080/v1/chat/completions -H "Content-Type: application/json" -d '{"model": "ggml-gpt4all-j","messages": [{"role": "user", "content": "How are you?"}],"temperature": 0.9}'

在这里插入图片描述

官方编译启动文档

FQA

Q1: 编译报错日志 sources/go-llama/llama.go:372:13: undefined: min
binding.cpp:333:67: warning: format specifies type 'size_t' (aka 'unsigned long') but the argument has type 'int' [-Wformat]
binding.cpp:809:5: warning: deleting pointer to incomplete type 'llama_model' may cause undefined behavior [-Wdelete-incomplete]
sources/go-llama/llama.cpp/llama.h:60:12: note: forward declaration of 'llama_model'
# github.com/go-skynet/go-llama.cpp
sources/go-llama/llama.go:372:13: undefined: min
note: module requires Go 1.21
make: *** [backend-assets/grpc/llama] Error 1

需要使用 go 1.21 版本

brew install mercurial
# 安装 gvm
bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)
# gvm直接生效
source ~/.gvm/scripts/gvm
# 查看版本
gvm install go1.21.7
gvm use go1.21.7
Q2: The link interface of target “protobuf::libprotobuf” contains: absl::absl_check, but the target was not found
CMake Error at /opt/homebrew/lib/cmake/protobuf/protobuf-targets.cmake:71 (set_target_properties):The link interface of target "protobuf::libprotobuf" contains:absl::absl_checkbut the target was not found.  Possible reasons include:* There is a typo in the target name.* A find_package call is missing for an IMPORTED target.* An ALIAS target is missing.Call Stack (most recent call first):/opt/homebrew/lib/cmake/protobuf/protobuf-config.cmake:16 (include)examples/grpc-server/CMakeLists.txt:34 (find_package)

需要更新一下 protobuf 和 abseil 版本

brew uninstall protobuf abseil
sudo port install re2 grpc abseil
http://www.lryc.cn/news/298972.html

相关文章:

  • Swift Combine 管道 从入门到精通三
  • 【RISC-V DSP设计】基于CEVA DSP架构的指令集分析(二)-函数列表
  • 蓝桥杯(Web大学组)2022国赛真题:水果消消乐
  • LeetCode--代码详解 155.最小栈
  • 第6讲后端鉴权拦截器实现
  • uniapp从入门到进阶
  • CDN缓存404、403状态码
  • 【Python网络编程之DHCP服务器】
  • 【MySQL】:深入理解并掌握DML和DCL
  • CSP-动态规划-最长公共子序列(LCS)
  • 安装nodejs2011并配置npm仓库
  • 排序C++代码(已更:快速排序,归并排序)
  • CentOS 7.9安装Tesla M4驱动、CUDA和cuDNN
  • Java设计模式——策略
  • 线性代数的本质 1 向量
  • 基于JAVA的贫困地区人口信息管理系统 开源项目
  • 【后端高频面试题--Mybatis篇】
  • 【笔记】Helm-5 Chart模板指南-12 .helmignore文件
  • 【MySQL】表的增删改查(基础)
  • Android矩阵Matrix动画缩放Bitmap移动手指触点到ImageView中心位置,Kotlin
  • C语言:表达式求值
  • GO 的 Web 开发系列(五)—— 使用 Swagger 生成一份好看的接口文档
  • 【极数系列】Flink集成KafkaSink 实时输出数据(11)
  • 我为什么选择Xamarin开发ios app安卓app
  • 安全基础~通用漏洞4
  • 2024/2/12 图的基础知识 2
  • 无人机飞行原理,多旋翼无人机飞行原理详解
  • docker本地目录挂载
  • 使用C++从零开始,自己写一个MiniWeb
  • Android Graphics 图像显示系统 - 开篇