I have a windows system with 2 Nvidia GPUs. Can someone tell me which GPU is the CUDA compiler using? Is it possible to switch the GPUs or use both together for same process?
Asked
Active
Viewed 527 times
-1
-
2The compiler had absolutely nothing to do with what GPU your code will run on. You decide that, either in code or via runtime settings or a mixture of both – talonmies Jul 18 '17 at 17:55
2 Answers
0
The CUDA_VISIBLE_DEVICES
environment variable will allow you to modify this enabling/ordering.
CUDA_VISIBLE_DEVICES="0,1"
will enable both GPU devices to be available to your program.
Possible duplicate of CUDA GPU selected by position, but how to set default to be something other than device 0?

Billy Ferguson
- 1,429
- 11
- 23
0
Use 'cudaGetDeviceCount' to get the number of devices. If deviceCount is 2, then device index 0 and device index 1 refer to the two current devices.
And 'cudaGetDeviceProperties' can be used to get many properties of the device.
For example,
cudaDeviceProp deviceProp;
cudaGetDeviceProperties(&deviceProp, 1);
can be used to get many properties of device 1.
And the way to switch to different GPUs is easy. After initialization, use
'cudaSetDevice(0)'
and
'cudaSetDevice(1)'
to switch to different GPUs.

Tom
- 3,168
- 5
- 27
- 36