当你想开展AI业务,却没有GPU,你该怎么办?
可以考虑用Cog,将AI服务部署在云上,serverless。
我们来看下,如何用Cog将其上云。
找一台开发服务器
Cog
安装
验证
这一步可以省略,非必须。主要用于验证你的环境是否ok。
初始化
生成主要文件
写代码
修改代码如下
cog.yaml
类似 docker file,定义环境
predict.py
定义了输入(name: str, scale: float),输出(str),推理过程
本地测试
测试一下
输出
部署
在云上 create model
push model 到云上
云上测试
测试成功!
之后,就可以用 api 调用
结论
本文主要演示如何用 Cog 上云的整个流程。
文中的例子,未使用 GPU 。如有需要,可查文档。