列出可用GPU

from tensorflow.python.client import device_lib
print(device_lib.list_local_devices())

from keras import backend as K
K.tensorflow_backend._get_available_gpus()

切换

import os
os.environ["CUDA_DEVICE_ORDER"]="PCI_BUS_ID"
# The GPU id to use, usually either "0" or "1"
os.environ["CUDA_VISIBLE_DEVICES"] = "0"   
os.environ["CUDA_VISIBLE_DEVICES"] = "-1" 为使用CPU     

 

相关文章:

  • 2021-08-22
  • 2021-12-03
  • 2021-12-03
  • 2022-01-08
  • 2022-12-23
  • 2022-12-23
  • 2022-01-06
猜你喜欢
  • 2022-12-23
  • 2021-12-14
  • 2021-08-30
  • 2021-04-21
  • 2021-10-27
  • 2021-11-20
相关资源
相似解决方案