C++ API to choose GPU from multiple gpus

Hi All,

I want to select GPU in the c++ program(Not through env vars) in caffe2. I am trying to infer in multithreading approach where each image should run on different GPU. I am not sure how can I achieve this using c++ APIs. I came across CaffeCudaSetDevice API but it doesn’t seem like working for me!

Currently, I am modifying env variables (CUDA_VISIBLE_DEVICES) in the code to achieve this which is big hack!