(n_gpu, model)
return model, device
判断环境 cpu还是gpu
    支持单机多卡
    :param n_gpu:
    :param model:
    :return:
判断环境 cpu还是gpu
    支持单机多卡
    :param n_gpu:
    :param model:
    :return:
判断环境 cpu还是gpu 支持单机多卡 : param n_gpu : : param model : : return :
def model_device(n_gpu, model):
    '''
    判断环境 cpu还是gpu
    支持单机多卡
    :param n_gpu:
    :param model:
    :return:
    '''
    device, device_ids = prepare_device(n_gpu)
    if len(device_ids) > 1:
        logger.info(f"current {len(device_ids)} GPUs")
        model = torch.nn.DataParallel(model, device_ids=device_ids)
    if len(device_ids) == 1:
        os.environ['CUDA_VISIBLE_DEVICES'] = str(device_ids[0])
    model = model.to(device)
    return model, device
def model_device ( n_gpu , model ) : device , device_ids = prepare_device ( n_gpu ) if len ( device_ids ) > 1 : logger . info ( f"current {len(device_ids)} GPUs" ) model = torch . nn . DataParallel ( model , device_ids = device_ids ) if len ( device_ids ) == 1 : os . environ [ 'CUDA_VISIBLE_DEVICES' ] = str ( device_ids [ 0 ] ) model = model . to ( device ) return model , device