cancel
Showing results for 
Search instead for 
Did you mean: 

OpenCL

tdchen
Journeyman III

How can I know which gpu is used by the OS?

If I have multi GPUs in my system, how can I know which gpu is used by the OS.

I am using OpenCL to do computing, and I don't want do use this gpu to do gpgpu.

thanks in advance.

0 Likes
8 Replies
jungle
Adept II

Which OS are you on ?

0 Likes

windows.

Sir.

0 Likes

Hi tdchen​,

1) both conditions "gpgpu" and "OpenCL to do computing",  are similar

2) For OpenCL 1.2 has no any tools to choice free Device, for example the result of call clGetDeviceInfo(.., CL_DEVICE_AVAILABLE,...) can be returned as "true", even if this device is not connected to Monitor

you can choice

3) You can create a temporary OpenGL context or Direct3D11 device and try to choice free device is not associated to this OpenGL Context or Direct3D11 device.

dipak​, what do you think about it ?

Hi Andrey,

I completely agree with your points. AFAIK, OpenCL doesn't provide any device query parameter to know that information. The 3rd option can be a way to identify the active device.

On the other hand, GPU_DEVICE_ORDINAL environment parameter can be used to mask the visibility of the GPUs seen by the OpenCL application. For example, on a 3-GPU system, one GPU is using regular graphics operations and we want that OpenCL should use other two GPUs for compute jobs. To do that, on Windows, we can set this parameter as: set GPU_DEVICE_ORDINAL=1,2

Thanks.

Yes, I was told to use OpenGL context, specifically glGetString(GL_VENDOR).

On my computer, it returns "NVIDIA Corporation".

I wonder if I have several GPUs of the same brand, how to decide?

My computer only has one GPU, But i was asked to make a program who can deal with any number of GPUs and brands.

Thanks.

0 Likes

I think, clGetGLContextInfoKHR  can be used to query the CL device currently associated with the specified OpenGL context. Later while creating the OpenCL context for computing, you can avoid this device.

Please note, OpenCL context is associated with a single platform only and it is created with one or more OpenCL devices available on the platform. Thus, on a multi-vendor multi-GPU setup, first you need to list all the platforms discovered by the clGetPlatformIDs  and then get the list of devices available on each platform using clGetDeviceIDs .

0 Likes

I think this is the function I am looking for.

Thank you so much dipak!

0 Likes
jungle
Adept II

If you know the PCI bus number and your code isn't being deployed on lots of machines you can just hard code the application not to run on that device. You can get the PCI bus number in Open CL as long as you are using the AMD version, using clGetDeviceInfo and CL_DEVICE_TOPOLOGY_AMD.

If you need to discover the PCI bus number of GPUs with a display attached you could use the Windows AMD Display Library method (ADL_Adapter_Active_Get). First you would do a ADL_Adapter_AdapterInfo_Get to get a LPAdapterInfo which contains the PCI Bus number.

GitHub - GPUOpen-LibrariesAndSDKs/display-library: AMD Display Library SDK

The samples in here have all the relevant code.

Docs:

ADL (AMD Display Library) Public APIs