---
title: 函数：bundle_load_from_mem
description: "模型执行阶段若涉及动态更新变量的场景，从内存加载离线模型数据，由系统内部管理模型运行的内存。"
url: https://www.hiascend.com/document/detail/zh/canncommercial/latest/API/ascendgraphapi/aclpythondevg_01_1097.html
sourcePath: /source/zh/canncommercial/900/API/ascendgraphapi/aclpythondevg_01_1097.html
indexId: 20ca9b5ed4f0a9c62434f078c9ebd29892a7aa7026943ae2760fcc25b5adc28a75
---
# 函数：bundle_load_from_mem

#### 功能说明

模型执行阶段若涉及动态更新变量的场景，从内存加载离线模型数据，由系统内部管理模型运行的内存。

本接口需与以下其它接口配合使用，以便实现动态更新变量的目的，请参见acl.mdl.bundle_load_from_file处的说明。


#### 函数原型

- C函数原型
  1 aclError aclmdlBundleLoadFromMem(const void *model,  size_t modelSize, uint32_t *bundleId)

- python函数
  1 bundle_id, ret = acl.mdl.bundle_load_from_mem(model, model_size)


#### 参数说明

| 参数名 | 说明 |
| --- | --- |
| model | int，存放模型数据的指针地址。 此处的模型文件是基于构图方式构建出来的，调用aclgrphBundleBuildModel接口编译模型、调用aclgrphBundleSaveModel接口保存模型，再由用户自行将保存出来的om模型文件读入内存，构图接口详细描述参见《图开发(https://www.hiascend.com/document/detail/zh/canncommercial/900/programug/graphdevg/atlasag\_25\_0081.html)》。 应用运行在Host时，此处需申请Host上的内存；应用运行在Device时，此处需申请Device上的内存。内存申请接口请参见内存管理(https://www.hiascend.comdocument/detail/zh/canncommercial/900/API/runtimeapi/aclpythondevg\_01\_0108.html)。 |
| model\_size | int，内存中的模型数据长度，单位Byte。 |


#### 返回值说明

| 返回值 | 说明 |
| --- | --- |
| bundle\_id | int，系统成功加载模型后，返回bundle\_id作为后续操作时识别模型的标志。 |
| ret | int，错误码，返回0表示成功，返回其它值表示失败。 |
