Fix redundant outputs via Logging in DDP training (#500)
* Change print to logging * Clean function set_logging * Add line spacing * Change leftover prints to log * Fix scanning labels output * Fix rank naming * Change leftover print to logging * Reorganized DDP variables * Fix type error * Make quotes consistent * Fix spelling * Clean function call * Add line spacing * Update datasets.py * Update train.py Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
This commit is contained in:
1 parent
542833c997
commit
4949401a94
5 files changed
+56
-39
No files matched your search
@@ -1,6 +1,7 @@
|
||||
import math
|
||||
import os
|
||||
import time
|
||||
import logging
|
||||
from copy import deepcopy
|
||||
|
||||
import torch
|
||||
@@ -9,6 +10,7 @@ import torch.nn as nn
|
||||
import torch.nn.functional as F
|
||||
import torchvision.models as models
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
def init_seeds(seed=0):
|
||||
torch.manual_seed(seed)
|
||||
@@ -40,12 +42,12 @@ def select_device(device='', batch_size=None):
|
||||
for i in range(0, ng):
|
||||
if i == 1:
|
||||
s = ' ' * len(s)
|
||||
print("%sdevice%g _CudaDeviceProperties(name='%s', total_memory=%dMB)" %
|
||||
logger.info("%sdevice%g _CudaDeviceProperties(name='%s', total_memory=%dMB)" %
|
||||
(s, i, x[i].name, x[i].total_memory / c))
|
||||
else:
|
||||
print('Using CPU')
|
||||
logger.info('Using CPU')
|
||||
|
||||
print('') # skip a line
|
||||
logger.info('') # skip a line
|
||||
return torch.device('cuda:0' if cuda else 'cpu')
|
||||
|
||||
|
||||
@@ -142,7 +144,7 @@ def model_info(model, verbose=False):
|
||||
except:
|
||||
fs = ''
|
||||
|
||||
print('Model Summary: %g layers, %g parameters, %g gradients%s' % (len(list(model.parameters())), n_p, n_g, fs))
|
||||
logger.info('Model Summary: %g layers, %g parameters, %g gradients%s' % (len(list(model.parameters())), n_p, n_g, fs))
|
||||
|
||||
|
||||
def load_classifier(name='resnet101', n=2):
|
||||
|
||||
Reference in new issue
Block a user