Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about cuda compatibility #18

Open
pokerfaceSad opened this issue Mar 8, 2024 · 2 comments
Open

Question about cuda compatibility #18

pokerfaceSad opened this issue Mar 8, 2024 · 2 comments

Comments

@pokerfaceSad
Copy link
Contributor

With the upgrade of CUDA and NVML versions, some functions have emerged with a "_v2" suffix, such as nvmlDeviceGetMemoryInfo and nvmlDeviceGetMemoryInfo_v2. When upper-level applications call these functions, they may preferentially invoke the v2 functions. If libcuda.so or libnvidia-ml.so does not declare the v2 functions, then the v1 version will be called, as in this code snippet https://github.com/XuehaiPan/nvitop/blob/470245dc3da0d9f4e3106b2c981d63d23440a5a5/nvitop/api/libnvml.py#L861-L879 .

However, when we implement a hook library like nvshare, if we provide a declaration for the v2 version of the function to be compatible with higher versions and attempt to call the v2 version in the real library, there could be an issue if the real library is a lower version that does not have the v2 function, potentially leading to an exception.

For instance, in this code at https://github.com/grgalex/nvshare/blob/main/src/hook.c#L598 , it returns CUDA_ERROR_NOT_INITIALIZED when real libcuda.so has no cuGetProcAddress_v2 function, which might cause the user program to malfunction.

@grgalex
Copy link
Owner

grgalex commented Mar 20, 2024

@pokerfaceSad I see the problem.

Do you have any thoughts on how we can handle it?

@pokerfaceSad
Copy link
Contributor Author

@pokerfaceSad I see the problem.

Do you have any thoughts on how we can handle it?

I haven't thought of a good way yet.

If we can't solve this problem inside the library, maybe solve it by bypassing.

A simple and inelegant idea is, we can try to recognize the CUDA/NVML version during container or CUDA process start, then set a matched hook library into library path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants