作为平台管理员,你可以以管理员的角色登录到 GPUStack 并导航到菜单中的资源,在这里查看你当前的 GPU 资源状态和容量。
然后你可以导航到模型,将任何开源的大模型部署到你的 GPU 集群中。这使得平台管理员可以快速在任意 GPU 之上运行大模型并向普通用户提供大模型服务,以便集成到他们的应用程序中。
这种方法可以帮助你有效地利用现有的资源,为各种需求和场景提供私有的大模型服务。
- 访问 GPUStack,在模型中部署你需要的大模型,选择从 Hugging Face (注意当前仅支持 GGUF 格式的模型文件)或 Ollama Library 下载模型文件到本地并运行大模型:
编辑
- GPUStack 会自动将模型调度到适当的 Worker 上运行:
编辑
- 你可以查看大模型服务的 API 请求、Token 使用量、Token 吞吐量、资源利用状态和其他指标。这些指标可以有效地帮助你决定是否要对大模型进行扩容或升级,以确保大模型服务的稳定性。
编辑
集成到你的应用中
作为一个 AI 应用开发人员,你可以以普通用户的角色登录到 GPUStack 并导航到菜单中的试验场,你可以在这里通过 UI 跟大模型进行交互。
编辑
下一步,你可以访问到 API 秘钥生成并保存你的 API 秘钥。然后回到试验场,在这里自定义你的大模型,例如调整系统 prompt,添加小样本学习样例,或调整 prompt 参数。
当你完成了自定义设置,点击查看代码选择你期望的调用代码格式(curl, Python, Node.js),并加入之前的 API 秘钥,然后在你的应用中使用这段调用代码来让应用与你的私有大模型通信。
现在你已经可以访问 OpenAI 兼容的大模型 API。例如,通过 curl 访问的示例如下:
export GPUSTACK_API_KEY=myapikey``curl http://myserver/v1-openai/chat/completions `` -H "Content-Type: application/json" \ `` -H "Authorization: Bearer $GPUSTACK_API_KEY" \ `` -d '{ `` "model": "llama3", `` "messages": [ `` { `` "role": "system", `` "content": "You are a helpful assistant." `` }, `` { `` "role": "user", `` "content": "Hello!" `` } `` ], `` "stream": true `` }'
管理 GPUStack 服务
MacOS 系统
在 MacOS 中,GPUStack 作为 launchd 服务运行。可以使用 launchctl 来管理 GPUStack 服务:
查看服务配置:sudo launchctl print system/ai.gpustack
停止服务:sudo launchctl unload /Library/LaunchDaemons/ai.gpustack.plist``ps -ef | grep gpustack
启动服务:sudo launchctl load /Library/LaunchDaemons/ai.gpustack.plist``ps -ef | grep gpustack
编辑配置并重启服务:sudo launchctl unload /Library/LaunchDaemons/ai.gpustack.plist``sudo vim /Library/LaunchDaemons/ai.gpustack.plist``sudo launchctl load /Library/LaunchDaemons/ai.gpustack.plist``ps -ef | grep gpustack
查看日志
查看 GPUStack 日志的路径和命令如下:tail -200f /var/log/gpustack.log
卸载
运行以下命令卸载 GPUStack:/var/lib/gpustack/uninstall.sh
Linux 系统
在 Linux 中,GPUStack 作为 systemd 服务运行。可以使用 systemctl 来管理 GPUStack 服务:
查看服务配置:sudo cat /etc/systemd/system/gpustack.service
停止服务:sudo systemctl stop gpustackps -ef | grep gpustack
启动服务:sudo systemctl start gpustack``ps -ef | grep gpustack
编辑配置并重启服务:sudo vim /etc/systemd/system/gpustack.service``sudo systemctl daemon-reload``sudo systemctl restart gpustack``ps -ef | grep gpustack
查看日志
查看 GPUStack 日志的路径和命令如下:tail -200f /var/log/gpustack.log
卸载
运行以下命令卸载 GPUStack:/var/lib/gpustack/uninstall.sh