Serverless AI 推理在实战中的应用

如果无法正常显示,请先停止浏览器的去广告插件。
分享至:
1. Serverless 与 AI 推理 如何在 Serverless 中使用 Wasm 进行高效 AI 推理 吕艺
2.
3. 在 5miles 用 AI 做什么 我们使用 TensorFlow 模型 + WebAssembly 来检测其他平台的 logo。 ● 提高效率 ● 高性能 ● 降低成本
4. 目录 ● Serverless 面临的新挑战 ● 大前端的 AI 推理 ● WebAssembly(Wasm) 的优势 ● 用 Wasm 进行 TensorFlow 推理的方法 ● Show me the code
5. Serverless 面临的新挑战
6. 先来说说 Vercel ● “最好用” 的网站托管服务 ● 前端业务通过编译生成 ● 支持部署云端 Serverless
7. 对 Serverless 的要求 ● 并发数量大 ● 启动快 ● 响应快
8. Serverless 面临 AI 的挑战 ● 模型文件大 ● 处理速度要求高 ● 跨平台计算能力
9. 大前端的 AI 推理
10. 前端 推理引擎 ● Web ○ ○ ○ ○ ○ TensorFlow.js(通过WebGL,WASM优化) MNN.js Paddle.js ONNX.js WebDNN tensorflow-js
11. 前端推理引擎 ● Android / iOS ○ ○ ○ ○ ○ TensorFlow Lite TNN(NCNN) MACE MNN Paddle Lite Google 腾讯 小米 阿里 百度
12. Serverless 推理实例 ● 基于腾讯云的 AI 示例 ○ https://github.com/second-state/tencent-tensorflow-scf
13. 在 Serverless 中基于 Wasm 的流式推理实践 业务系统 Docker( Node.js ) 接收数据 解析视频 调用 Wasm 返回结果 WasmEdge Js >> Pre & Post Process AWS Lambda Build
14. 前端推理 vs 后端推理 ● 前端推理 ○ ○ ○ ○ 离数据近 实时性好 个人隐私 节省流量
15. 前端推理 vs 后端推理 ● 前端推理 ○ ○ ○ ○ 离数据近 实时性好 个人隐私 节省流量 ● 后端推理 ○ ○ ○ ○ 适合较大模型 业务逻辑封闭 不需要实时反馈 需要更好的性能
16. WebAssembly (Wasm) 的优势
17. WebAssembly (Wasm) 的优势 ● 高性能 ● 沙盒安全 ● 基于能力的安全 ● 多种开发语言 ● Product-community fit Rust + Wasm(VM) ~ Java + JVM
18. WasmEdge(SSVM ) A popular WebAssembly VM optimized for high-performance applications Like � https://github.com/WasmEdge/WasmEdge
19. 用 Wasm 进行 TensorFlow 推理的方法
20. 在 CPU 上解释执行 ● 用 Rust 或 C/C++ 实现的 TensorFlow 操作符 ● 编译成 WebAssembly ● 在 CPU 上以解释器模式执行 ● 图像识别任务在现代 Intel CPU 上需要 10 分钟以上 Rust Tract crate � https://crates.io/crates/tract
21. Just-In-Time (JIT) ● 在 WebAssembly 中实现 TensorFlow 运算符 ● 在 v8 等 JIT 运行时中执行程序 ● 图像识别任务需要 2-3 秒 Tensorflow.js � https://github.com/tensorflow/tfjs
22. 把模型编译成 WebAssembly ● 将 AI 模型直接编译成 WebAssembly 字节码程序 ● 节省了在 runtime 将 TensorFlow 操作映射到 Wasm 操作所需的时间 ● 但是很难围绕模型推理进行前后处理 ● 图像识别任务需要 1-2 秒 TVM � https://github.com/apache/tvm 将 ONNX 编译成 Wasm � https://github.com/ONNC/onnc-wasm
23. Host function(WASI) ● 从 Wasm 调用原生的 TensorFlow 库 ○ 提供了调用 TensorFlow 的 Rust API ● Rust 编译的代码围绕 TensorFlow 调用进行数据准备 ● 图片识别任务在 CPU 上只要 0.5 秒 WasmEdge on Tencent Serverless � https://github.com/second-state/tencent-tensorflow-scf
24. AOT 与 GPU ● 使用 AOT 优化 Wasm 中的数据预处理的调用 ● 使用 WASI 在 GPU 上运行 TensorFlow 推理 ● 为特殊的硬件运行页数的 AI 库 ○ 如. AWS 的 Inferentia 芯片 ● 图片识别任务只需花费 0.05 秒 WasmEdge on Tencent Serverless � https://github.com/second-state/tencent-tensorflow-scf
25. Show me the code
26. Serverless AI 推理的Demo
27. Serverless AI 推理的Demo Code: https://github.com/second-state/tencent-tensorflow-scf Demo: https://sls-website-ap-hongkong-kfdilz-1302315972.cos-website.ap-hongkong.myqcloud.com/
28. Serverless 端代码
29. Serverless 端代码
30. Serverless 端代码
31. Serverless 部署 • 在 Codespaces 打开 Terminal 窗口, 然后运行下面的命令行来创建云函数。 $ rustwasmc build --enable-aot • 在 Terminal 窗口,运行下面的命令行将 TensorFlow 云函数部署到腾讯云上。 $ cp pkg/scf.so scf/ $ sls deploy
32. More samples ● Golang sample ○ https://github.com/second-state/WasmEdge-go- examples/tree/master/go_MobilenetFood ● fass samples ○ https://github.com/second-state/wasm- learning/tree/master/faas
33. 展望 ● 试验中的项目 ○ ○ Krustlet (https://github.com/deislabs/krustlet) containerd-shim-wasm (https://github.com/dippynark/containerd-shim-wasm) ● WasmEdge ○ WasmEdge 正在逐步支持 OCI (Open Container Initiative)规范,该规范将允许由 Cloud Native Orchestration 工具,如 Kubernetes,管理 SSVM 实例。 ■ WasmEdge 已经支持了 cri-o ■ 很快将支持 K8s
34. Thanks https://github.com/WasmEdge/WasmEdge

trang chủ - Wiki
Copyright © 2011-2024 iteam. Current version is 2.132.1. UTC+08:00, 2024-09-23 21:30
浙ICP备14020137号-1 $bản đồ khách truy cập$