---
title: 函数：set_stream_res_limit
description: "| 产品 | 是否支持 |"
url: https://www.hiascend.com/document/detail/zh/canncommercial/latest/API/runtimeapi/aclpythondevg_01_1136.html
sourcePath: /source/zh/canncommercial/900/API/runtimeapi/aclpythondevg_01_1136.html
indexId: 7436fac5d577b6608676d2cb0c75ea4c3a9faea77c1cc615c5f900447a30770f71
---
# 函数：set_stream_res_limit

#### 产品支持情况

| 产品 | 是否支持 |
| --- | --- |
| Atlas 350 加速卡 | √ |
| Atlas A3 训练系列产品 / Atlas A3 推理系列产品 | √ |
| Atlas A2 训练系列产品 / Atlas A2 推理系列产品 | √ |
| Atlas 训练系列产品 | √ |
| Atlas 推理系列产品 | √ |
| Atlas 200I/500 A2 推理产品 | √ |


#### 功能说明

设置指定Stream的Device资源限制。

本接口应在调用acl.rt.set_device接口之后且在执行算子之前使用。如果对同一Stream进行多次设置，将以最后一次设置为准。

调用本接口设置指定Stream的Device资源限制后，需配合调用acl.rt.use_stream_res_in_current_thread接口，设置在当前线程中使用指定Stream上的Device资源限制。可通过acl.rt.get_stream_res_limit接口查询默认的资源限制。


#### 函数原型

- C函数原型

```
aclError aclrtSetStreamResLimit(aclrtStream stream, aclrtDevResLimitType type, uint32_t value)
```


- python函数
  1 ret = acl.rt.set_stream_res_limit(stream, type , value)


#### 参数说明

| 参数名 | 说明 |
| --- | --- |
| stream | int，指定Stream, 若传入0，则表示默认Stream。 |
| type | int，资源类型，当前支持Cube Core、Vector Core，具体请参见新增数据结构aclrtDevResLimitType。 |
| value | int，资源限制的大小。 |


#### 返回值说明

| 返回值 | 说明 |
| --- | --- |
| ret | int，返回0表示成功，返回其他值表示失败。 |
