Rico.Wu
Rico.Wu

Reputation: 11

Pycuda how to know which device is running

We only have 4 GPU devices. and we have more than 4 users to run cuda program ,so before I run my program I want to check which device is not busy, or it will alloc memory fail. But I havent found a function to get this tag. I know when we want to use device we call "cudaSetDevice()" , so there must be a tag for each device. and that "nvidia-smi" can get more detail, include which proccess is using which device and how much memory it used. So who can help me?

Upvotes: 1

Views: 990

Answers (1)

James Sharpe
James Sharpe

Reputation: 627

The values for cudaSetDevice start at 0 and then increase monotonically for each additional device. Alternatively you can set the environment variable CUDA_VISIBLE_DEVICES to select which device to use. (see https://devblogs.nvidia.com/parallelforall/cuda-pro-tip-control-gpu-visibility-cuda_visible_devices/).

To get information about what is using the device you need to use the driver API: http://docs.nvidia.com/cuda/cuda-driver-api/index.html

Upvotes: 1

Related Questions