Felix
Felix

Reputation: 3581

How to execute CUDA kernel on given GPU?

I have two NVIDIA cards on my machine. I want to execute a CUDA kernel on one of them (for example, on the second). Alas, in the tutorials I didn't find the device selection for memory allocation and kernel execution, like it is done for OpenCL.

Cannot you tell me, how can I choose the video device to execute kernels and allocate memory on?

Upvotes: 0

Views: 268

Answers (1)

void_ptr
void_ptr

Reputation: 628

This is probably what you are looking for:

cudaError_t cudaSetDevice (int device)  

Link to NVIDIA API documentation:

http://developer.download.nvidia.com/compute/cuda/4_1/rel/toolkit/docs/online/group__CUDART__DEVICE_g418c299b069c4803bfb7cab4943da383.html

Quote from the above link:

Any device memory subsequently allocated from this host thread using cudaMalloc(), cudaMallocPitch() or cudaMallocArray() will be physically resident on device. Any host memory allocated from this host thread using cudaMallocHost() or cudaHostAlloc() or cudaHostRegister() will have its lifetime associated with device. Any streams or events created from this host thread will be associated with device. Any kernels launched from this host thread using the <<<>>> operator or cudaLaunch() will be executed on device.

Upvotes: 1

Related Questions