How to set function attributes for kernels loaded from .cubin file.

Now I have a cubin file, target at Turing (sm_75).

I loaded it with runtime api:

cuModuleLoad(&module, "a.cubin");
cuModuleGetFunction(&kernel, module, "kenrel");

The problem is I cannot set function attributes with cudaFuncSetAttributes. It returns 98 (cudaErrorInvalidDeviceFunction).

How can I fix this?

Thanks!

BTW, I can launch this kernel with cuLaunchKernel and get the correct result.

There is no function cudaFuncSetAttributes

I assume you meant cudaFuncSetAttribute

It’s evident you’re using the driver API. Why would you switch to the runtime API for this?

Did you try cuFuncSetAttribute?

https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__EXEC.html#group__CUDA__EXEC

Hi @Robert_Crovella,

Switching to cuFuncSetAttribute solved this issue.

I just came across an example using cudaFuncSetAttribute, and did not aware of the difference between runtime API and driver API.

Thank you.