I am trying to finetune Densenet-121.
My dataloader looks like this
class gamma_corr:
def __init__(self,gamma):
self.gamma = gamma
def __call__(self,x):
return transforms.functional.adjust_gamma(x,self.gamma)
class resize:
def __init__(self,factor):
self.factor = factor
def __call__(self,img):
h,w = img.size
return img.resize([round(h*self.factor),round(w*self.factor)],PIL.Image.BICUBIC)
resize = transforms.RandomChoice([resize(0.5),resize(0.8),resize(1.5),resize(2.0)])
gamma = transforms.RandomChoice([gamma_corr(0.8),gamma_corr(1.2)])
alt = transforms.RandomOrder([resize,gamma])
img = transforms.RandomChoice([alt,lambda x: x])
transformations = transforms.Compose([transforms.RandomCrop(960,960),img,transforms.RandomCrop(256,256),
transforms.ToTensor(),transforms.Normalize([0.5,0.5,0,5],[0.5,0.5,0.5])])
dataset = datasets.ImageFolder('./train/',transform=transformations)
loader = DataLoader(dataset,batch_size=32,shuffle=True,num_workers=8,pin_memory=True,drop_last=True)
I have an 8 core CPU, the CPU utilization is always 100%
I guess the GPU consumes data a faster rate than the CPU can produce and thus has to wait.
How can I improve it ?.