(n_gpu_use)
return device, list_ids
setup GPU device if available, move model into configured device
    # 如果n_gpu_use为数字，则使用range生成list
    # 如果输入的是一个list，则默认使用list[0]作为controller
setup GPU device if available, move model into configured device
    # 如果n_gpu_use为数字，则使用range生成list
    # 如果输入的是一个list，则默认使用list[0]作为controller
setup GPU device if available move model into configured device # 如果n_gpu_use为数字，则使用range生成list # 如果输入的是一个list，则默认使用list [ 0 ] 作为controller
def prepare_device(n_gpu_use):
    """
    setup GPU device if available, move model into configured device
    # 如果n_gpu_use为数字，则使用range生成list
    # 如果输入的是一个list，则默认使用list[0]作为controller
     """
    if not n_gpu_use:
        device_type = 'cpu'
    else:
        n_gpu_use = n_gpu_use.split(",")
        device_type = f"cuda:{n_gpu_use[0]}"
    n_gpu = torch.cuda.device_count()
    if len(n_gpu_use) > 0 and n_gpu == 0:
        logger.warning("Warning: There\'s no GPU available on this machine, training will be performed on CPU.")
        device_type = 'cpu'
    if len(n_gpu_use) > n_gpu:
        msg = f"Warning: The number of GPU\'s configured to use is {n_gpu_use}, but only {n_gpu} are available on this machine."
        logger.warning(msg)
        n_gpu_use = range(n_gpu)
    device = torch.device(device_type)
    list_ids = n_gpu_use
    return device, list_ids
def prepare_device ( n_gpu_use ) : if not n_gpu_use : device_type = 'cpu' else : n_gpu_use = n_gpu_use . split ( "," ) device_type = f"cuda:{n_gpu_use[0]}" n_gpu = torch . cuda . device_count ( ) if len ( n_gpu_use ) > 0 and n_gpu == 0 : logger . warning ( "Warning: There\'s no GPU available on this machine, training will be performed on CPU." ) device_type = 'cpu' if len ( n_gpu_use ) > n_gpu : msg = f"Warning: The number of GPU\'s configured to use is {n_gpu_use}, but only {n_gpu} are available on this machine." logger . warning ( msg ) n_gpu_use = range ( n_gpu ) device = torch . device ( device_type ) list_ids = n_gpu_use return device , list_ids