socket
socket

Reputation: 1203

how to choose designated GPU to run CUDA program?

My PC (ubuntu 12.04 x86 with CUDA 6.0) have 2 GPUs, I have some CUDA programs, and I have a program written in python to manage them.

For example, I want to select one GPU to run some CUDA programs and select the other one to run the other CUDA programs. But the management process is outside the CUDA code, so I can not use "cudaSetDevice" API inside CUDA programs. That is, the CUDA programs are unalterable, I can only select GPU outside them.

Is it possible to do that?

Upvotes: 2

Views: 6799

Answers (1)

damienfrancois
damienfrancois

Reputation: 59300

One option is to use the CUDA_VISIBLE_DEVICE in the environment of the program to restrict which devices it sees:

$ deviceQuery |& grep ^Device
Device 0: "Tesla M2090"
Device 1: "Tesla M2090"
$ CUDA_VISIBLE_DEVICES=0 deviceQuery |& grep ^Device
Device 0: "Tesla M2090"
$

See more information on the CUDA developer zone website.

Upvotes: 2

Related Questions