How does CUDA assign device IDs to GPUs?

后端 未结 4 652
我在风中等你
我在风中等你 2020-11-30 07:41

When a computer has multiple CUDA-capable GPUs, each GPU is assigned a device ID. By default, CUDA kernels execute on device ID 0. You can use

4条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-30 08:05

    The best solution I have found (tested in tensorflow==2.3.0) is to add the following before anything that may import tensorflow:

    import os
    os.environ["CUDA_DEVICE_ORDER"]="PCI_BUS_ID"
    os.environ["CUDA_VISIBLE_DEVICES"]="0,3"  # specify which GPU(s) to be used
    

提交回复
热议问题