---
title: 函数：unload
description: "系统完成模型推理后，可调用该接口卸载模型，释放资源。"
url: https://www.hiascend.com/document/detail/zh/canncommercial/latest/API/ascendgraphapi/aclpythondevg_01_0148.html
sourcePath: /source/zh/canncommercial/900/API/ascendgraphapi/aclpythondevg_01_0148.html
indexId: b290fa975e0e64727a133464b579931761c205584dc09941e29f99824847783d75
---
# 函数：unload

#### 功能说明

系统完成模型推理后，可调用该接口卸载模型，释放资源。


#### 函数原型

- C函数原型
  1 aclError aclmdlUnload(uint32_t modelId)

- python函数
  1 ret = acl.mdl.unload(model_id)


#### 参数说明

| 参数名 | 说明 |
| --- | --- |
| model\_id | int，指定需卸载的模型的ID。 |


#### 返回值说明

| 返回值 | 说明 |
| --- | --- |
| ret | int，错误码，返回0表示成功，返回其它值表示失败。 |


#### 约束说明

- 在调用acl.mdl.unload接口卸载指定模型时，需确保该模型当前未被其他接口使用。
- 模型加载、模型执行、模型卸载的操作必须在同一个Context下（关于Context的创建请参见  acl.rt.set_device(https://www.hiascend.comdocument/detail/zh/canncommercial/900/API/runtimeapi/aclpythondevg_01_0062.html)
、  acl.rt.create_context(https://www.hiascend.comdocument/detail/zh/canncommercial/900/API/runtimeapi/aclpythondevg_01_0072.html)
）。


#### 资源参考

接口调用流程，参见接口调用流程(https://www.hiascend.comdocument/detail/zh/canncommercial/900/programug/acldevg/aclpythondevg_0005.html)。
