尧图网站建设 尧图网络
  • 首页
  • 关于我们
  • 服务项目
  • 案例展示
  • 建站流程
  • 资讯中心
  • 联系我们
首页/资讯中心/详情

CANN/runtime模型流切换示例

CANN/runtime模型流切换示例
📅 发布时间:2026/6/24 6:21:38

2_model_switch

【免费下载链接】runtime本项目提供CANN运行时组件和维测功能组件。项目地址: https://gitcode.com/cann/runtime

Description

This sample demonstrates how to use aclmdlRIBuildBegin interface to create a model instance, and implements Stream jumping and Stream activation in tasks.

Product Support

Key interfaces in this sample have the following support status on different products:

InterfaceAtlas A3 training series products/Atlas A3 inference series productsAtlas A2 training series products/Atlas A2 inference series products
aclmdlRIBuildBeginYesYes
aclmdlRIBindStreamYesYes
aclmdlRIEndTaskYesYes
aclmdlRIBuildEndYesYes
aclmdlRIUnbindStreamYesYes
aclmdlRIExecuteAsyncYesYes
aclrtSwitchStreamNoYes
aclrtActiveStreamNoYes

Build and Run

For environment installation details and running details, see README in the example directory.

Run steps:

# Replace ${install_root} with CANN installation root directory, default installation at /usr/local/Ascend source ${install_root}/cann/set_env.sh export ASCEND_INSTALL_PATH=${install_root}/cann # Replace ${ascend_name} with Ascend AI processor model, obtained by checking Name field using npu-smi info and removing spaces, for example ascend910b3 export SOC_VERSION=${ascend_name} # Some samples involve calling AscendC operators, need to configure AscendC compiler ascendc.cmake path, for example ${install_root}/cann/aarch64-linux/tikcpp/ascendc_kernel_cmake # Find ascendc_kernel_cmake under CANN package installation path, for example find ./ -name ascendc_kernel_cmake, and replace ${cmake_path} with ascendc_kernel_cmake directory path export ASCENDC_CMAKE_DIR=${cmake_path} # Build and run bash run.sh

CANN RUNTIME API

Key features and interfaces in this sample:

  • Initialization
    • Call aclInit interface to initialize AscendCL configuration.
    • Call aclFinalize interface to deinitialize AscendCL.
  • Device Management
    • Call aclrtSetDevice interface to specify Device for computation.
    • Call aclrtResetDeviceForce interface to forcibly reset current computation Device and reclaim Device resources.
  • Context Management
    • Call aclrtCreateContext interface to create Context.
    • Call aclrtDestroyContext interface to destroy Context.
  • Stream Management
    • Call aclrtCreateStream interface to create Stream.
    • Call aclrtSynchronizeStream interface to block waiting for Stream task completion.
    • Call aclrtDestroyStreamForce interface to forcibly destroy Stream, discarding all tasks.
    • Call aclrtCreateStreamWithConfig interface to create Stream with special config.
    • Call aclrtSwitchStream interface to jump between Streams based on condition.
    • Call aclrtActiveStream interface to activate Stream.
  • Model Management
    • Call aclmdlRIBuildBegin interface to start building a model runtime instance.
    • Call aclmdlRIBindStream interface to bind model runtime instance to Stream.
    • Call aclmdlRIEndTask interface to mark task dispatch end.
    • Call aclmdlRIBuildEnd interface to finish building model runtime instance.
    • Call aclmdlRIUnbindStream interface to unbind model runtime instance from Stream.
    • Call aclmdlRIExecuteAsync interface to asynchronously execute model inference.
    • Call aclmdlRIDestroy interface to destroy model runtime instance.
  • Memory Management
    • Call aclrtMalloc interface to allocate Device memory.
    • Call aclrtFree interface to release Device memory.
  • Data Transfer
    • Call aclrtMemcpy interface to implement data transfer by memory copy.
    • Call aclrtMemcpyAsync interface to perform asynchronous memory copy.

Known Issues

None

【免费下载链接】runtime本项目提供CANN运行时组件和维测功能组件。项目地址: https://gitcode.com/cann/runtime

创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考

相关新闻

  • TruecallerJS错误处理与调试指南:常见问题排查与解决方案
  • 7-Zip DLL选择指南:bit7z兼容的7z.dll/7za.dll功能对比
  • 终极iOS越狱指南:使用palera1n轻松解锁iPhone系统权限

最新新闻

  • VILA视觉大模型INT4量化实战:AWQ技术实现2.9倍推理加速
  • Burp Suite安装与配置指南:从零搭建Web渗透测试环境
  • Python虚拟环境实战:venv、conda与requirements.txt全解析
  • MPC860 SCC以太网控制器:CSMA/CD协议实现与CAM接口应用
  • OpenClaw:可编程命令行技能调度器,统一管理网关与CLI自动化
  • Windows本地AI开发环境:WSL2+Ubuntu24.04+Ollama+1panel+copaw全链路部署

日新闻

  • 终极指南:如何用shadPS4在电脑上免费畅玩PS4游戏
  • 打造个性化Instagram Clone:主题定制与用户体验优化技巧
  • 未来展望:RoseTTAFold-All-Atom的发展路线图与社区支持资源汇总

周新闻

  • Visual C++运行库修复终极指南:5分钟快速解决Windows软件启动错误
  • 手把手教你构建统计局地区经济数据爬虫:从环境搭建到数据持久化全指南
  • 2026多Agent深度解析:用AI团队替代单一模型,四种架构实战落地

月新闻

  • 【总结】入门篇:50句话让你记住架构核心概念
  • WeChatMsg技术方案解析:实现Mac微信数据自主管理的完整解决方案
  • WeChatMsg:革新性微信数据备份方案,打造你的专属数字记忆库

关于尧图

  • 公司简介
  • 团队介绍
  • 企业文化
  • 荣誉资质

服务项目

  • 定制开发
  • 电商建站
  • UI 设计
  • 运维服务

快速链接

  • 案例展示
  • 建站流程
  • 常见问题
  • 资讯中心

联系方式

  • 📍北京市朝阳区互联网产业园 A 座 10 层
  • 📞400-888-8888
  • ✉️contact@rkmt.cn
  • 🕐周一至周日 9:00-21:00

© 2024 北京尧图网络科技有限公司 版权所有 | 京 ICP 备 XXXXXXXX 号