Dear all,
I am trying to activate the GPU (nvidia P4000) but it keeps at 5% usage whatever I am doing.
I have started the code with that :
use_cuda = torch.cuda.is_available()
device = torch.device(“cuda:0” if use_cuda else “cpu”)
and I get a correct answer from command ‘device’
==> device(type=‘cuda’, index=0)
From command ‘torch.cuda.get_device_name(0)’ I get
==> ‘Quadro P4000’
So everything seems OK.
Then I am loading all the tensors to the GPU :
MyLoss = torch.nn.MSELoss()
batch_size = 10
YCost = Y_tensor(‘this_forecast’,df,indY)
YCost = YCost.to(device)
model = torch.nn.Sequential(torch.nn.Linear(Xdim,Midsize),torch.nn.Tanh(),torch.nn.Linear(Midsize,Ydim))
model = model.to(device)
optim = torch.optim.SGD(params=model.parameters(),lr=EPS)
tensorX = torch.tensor(df[indX].values)
tensorX = tensorX.to(device)
tensorY = Y_tensor(‘last_forecast’,df,indY)
tensorY = tensorY.to(device)








train_tensor_data = torch.utils.data.TensorDataset(tensorX, tensorY)








indices_train, indices_valid = split_indice_block(0.7, 20, len(train_tensor_data))
train_data = torch.utils.data.Subset(train_tensor_data, indices_train)
valid_data = torch.utils.data.Subset(train_tensor_data, indices_valid)








train_loader = DataLoader(train_data,batch_size,shuffle=True)
valid_loader = DataLoader(valid_data, batch_size)
for epoch in range(NB_EPOCH):


   model.train()*



   for xbatch, ybatch in train_loader:*



       xbatch, ybatch = xbatch.float().to(device), ybatch.float().to(device)*



       outputs = model(xbatch).to(device)*



       loss = MyLoss(outputs,ybatch)*



       optim.zero_grad()*



       loss.backward()*



       optim.step()*



…
CPU is actually asleep at 1% usage.
But the GPU keeps loaded 5% only and running time is incredibly slow.
So what can possibly be wrong ?
Thanks !