How to enable/disable a specific graphic card?

后端 未结 1 1182
名媛妹妹
名媛妹妹 2021-01-15 01:47

I\'m working on a \"fujitsu\" machine. It has 2 GPUs installed: Quadro 2000 and Tesla C2075. The Quadro GPU has 1 GB RAM and Tesla GPU has 5GB of it. (I checked using the ou

相关标签:
1条回答
  • 2021-01-15 02:33

    You can control access to CUDA GPUs either using the environment or programmatically.

    You can use the environment variable CUDA_VISIBLE_DEVICES to specify a list of 1 or more GPUs that will be visible to any application, as well as their order of visibility. For example if nvidia-smi reports your Tesla GPU as GPU 1 (and your Quadro as GPU 0), then you can set CUDA_VISIBLE_DEVICES=1 to enable only the Tesla to be used by CUDA code.

    See my blog post on the subject.

    To control what GPU your application uses programmatically, you should use the device management API of CUDA. Query the number of devices using cudaGetDeviceCount, then you can cudaSetDevice to each device, query its properties using cudaGetDeviceProperties, and then select the device that fits your application criteria. You can also use cudaChooseDevice to select the device that most closely matches the device properties you specify.

    0 讨论(0)
提交回复
热议问题