# cudaDeviceSetSharedMemConfig not working for GTX1650Ti

**URL:** <https://forums.developer.nvidia.com/t/cudadevicesetsharedmemconfig-not-working-for-gtx1650ti/298927>\
**Category:** CUDA Programming and Performance\
**Created:** [July 7, 2024, 5:56am UTC](https://forums.developer.nvidia.com/t/cudadevicesetsharedmemconfig-not-working-for-gtx1650ti/298927 "2024-07-07T05:56:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![2301213250](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@2301213250](https://forums.developer.nvidia.com/u/2301213250)\
**Post date:** [July 7, 2024, 5:56am UTC](https://forums.developer.nvidia.com/t/cudadevicesetsharedmemconfig-not-working-for-gtx1650ti/298927/1 "2024-07-07T05:56:11Z")

</div>

```auto
#include <cuda_runtime.h>
#include <iostream>

int main() {
    cudaError_t err;
    int device_id = 0; // 使用设备 0

    // 设置当前设备
    err = cudaSetDevice(device_id);
    if (err != cudaSuccess) {
        std::cerr << "Failed to set device: " << cudaGetErrorString(err) << std::endl;
        return -1;
    }

    // 获取设备属性
    cudaDeviceProp deviceProp;
    err = cudaGetDeviceProperties(&deviceProp, device_id);
    if (err != cudaSuccess) {
        std::cerr << "Failed to get device properties: " << cudaGetErrorString(err) << std::endl;
        return -1;
    }

    std::cout << "Device Name: " << deviceProp.name << std::endl;
    std::cout << "Compute Capability: " << deviceProp.major << "." << deviceProp.minor << std::endl;

    // 检查设备是否支持更改共享内存 bank 大小
    if (deviceProp.major >= 2) {
        // 设置共享内存 bank 大小为 8 字节
        err = cudaDeviceSetSharedMemConfig(cudaSharedMemBankSizeEightByte);
        if (err != cudaSuccess) {
            std::cerr << "Failed to set shared memory configuration: " << cudaGetErrorString(err) << std::endl;
            return -1;
        }

        // 查询共享内存 bank 大小
        cudaSharedMemConfig config;
        err = cudaDeviceGetSharedMemConfig(&config);
        if (err != cudaSuccess) {
            std::cerr << "Failed to get shared memory configuration: " << cudaGetErrorString(err) << std::endl;
            return -1;
        }

        // 打印共享内存 bank 大小
        switch (config) {
        case cudaSharedMemBankSizeDefault:
            std::cout << "Shared memory bank size: Default" << std::endl;
            break;
        case cudaSharedMemBankSizeFourByte:
            std::cout << "Shared memory bank size: 4 bytes" << std::endl;
            break;
        case cudaSharedMemBankSizeEightByte:
            std::cout << "Shared memory bank size: 8 bytes" << std::endl;
            break;
        default:
            std::cout << "Unknown shared memory bank size" << std::endl;
        }
    }
    else {
        std::cerr << "Device does not support changing shared memory bank size" << std::endl;
    }

    // 重置设备
    cudaDeviceReset();

    return 0;
}

```

When I tried to change the width of the bank to 8 bytes, it didn’t work？

Device Name: NVIDIA GeForce GTX 1650 Ti with Max-Q Design  
Compute Capability: 7.5  
Shared memory bank size: 4 bytes

---

<div class="post-metadata">

**Author:** ![striker159](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@striker159](https://forums.developer.nvidia.com/u/striker159)\
**Post date:** [July 7, 2024, 8:54am UTC](https://forums.developer.nvidia.com/t/cudadevicesetsharedmemconfig-not-working-for-gtx1650ti/298927/2 "2024-07-07T08:54:20Z")

</div>

Only the old Kepler architecture supports a bank size of 8 bytes.  
Functions to get and set the shared memory configs are deprecated in the current CUDA version.  
[https://docs.nvidia.com/cuda/cuda-runtime-api/group\_\_CUDART\_\_DEVICE\_\_DEPRECATED.html](https://docs.nvidia.com/cuda/cuda-runtime-api/group __CUDART__ DEVICE__DEPRECATED.html)

---

<div class="post-metadata">

**Author:** ![Curefab](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Curefab](https://forums.developer.nvidia.com/u/Curefab)\
**Post date:** [July 7, 2024, 8:55am UTC](https://forums.developer.nvidia.com/t/cudadevicesetsharedmemconfig-not-working-for-gtx1650ti/298927/3 "2024-07-07T08:55:02Z")

</div>

The option to set the shared memory banks to a width of 8 bytes was only available up till Kepler (compute capability 3.x).  
See

> [@Do I need to set cudaSharedMemConfig anymore?](https://forums.developer.nvidia.com/t/do-i-need-to-set-cudasharedmemconfig-anymore/268248):
>
> When I got started in CUDA, a seasoned veteran told me that a big deal was to decide whether to interpret the \_\_shared\_\_ memory in chunks of four or eight bytes. The 32 banks and rule about one chunk per bank per clock cycle remains significant, I know, and I seem to recall back in 2018 I could definitely see a difference if the kernels were set to use cudaSharedMemBankSizeEightByte versus cudaSharedMemBankSizeFourByte. So, in my new code base, I have been pretty scrupulous about having functi…

---

<div class="post-metadata">

**Author:** ![2301213250](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@2301213250](https://forums.developer.nvidia.com/u/2301213250)\
**Post date:** [July 18, 2024, 7:31am UTC](https://forums.developer.nvidia.com/t/cudadevicesetsharedmemconfig-not-working-for-gtx1650ti/298927/4 "2024-07-18T07:31:01Z")

</div>

Thank you！
