Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Program to check CUDA presence needs CUDA?

I wrote a simple application that checks if NVIDIA CUDA is available on the computer. It simply displays true if a CUDA-capable device is found.

I send the app to a second PC, and the application didn't run - a dialog box showed up that cudart.dll was not found. I want to check if CUDA is present and it requires CUDA to do that :)

I am using CUDA 5.0, VS2012, VC++11, Windows 7.

Can I compile the application in a way, that all CUDA libraries are inside the executable?


So the scenario is:

  1. My app is compiled & sent to a computer
  2. The computer can:
    1. be running windows, linux (my app is compatible with the system)
    2. have a gpu or not
    3. have an nvidia gpu or not
    4. have CUDA installed or not
  3. My app should return true only if 2.3 and 2.4 are positive (GPU with CUDA)
like image 653
Xlaudius Avatar asked Sep 14 '25 20:09

Xlaudius


1 Answers

As an opening comment, I think the order and number of steps in your edit is incorrect. It should be:

  1. Programs starts and attempts to load the runtime API library
  2. If the runtime library is present, attempt to use it to enumerate devices.

If step 1 fails, you do not have the necessary runtime support, and CUDA cannot be used. If 2 fails, there is not a compatible driver and GPU present in the system and CUDA cannot be used. If they both pass, you are good to go.

In step 1 you want to use something like dlopen on Linux and handle the return status. On Windows, you probably want to use the DLL delay loading mechanism (Sorry, not a Windows programmer, can't tell you more than that).

In both cases, if the library loads, then fetch the address of cudaGetDeviceCount via the appropriate host OS API and call it. That tells you whether there are compatible GPUs which can be enumerated. What you do after you find an apparently usable GPU is up to you. I would check for compute status and try establishing a context on it. That will ensure that a fully functional runtime/driver combination is present and everything works.

like image 125
talonmies Avatar answered Sep 17 '25 09:09

talonmies