Don't use gpu but cpu·

i use cuda 11.6 with pytorch 1.13, the question is very amazing!!!
the OS is ubuntu 18.04.6 with the GPU TITAN2080 Driver Version: 510.47.03
sometimes when i start a program, it will only use cpu instead of gpu, however, i can promise that the code is ok because it worked after i restart it

part of code are following:

with torch.no_grad():
    for file in data_loader:
        start = time.time()
        label, pic = file # return label and a imagenet pic (24,3,224,224)
        pred = model(pic.cuda()) # with resnet50
        for i in range(pred.shape[0]):
            max_index = pred[i].argmax()
            correct = label[i]
            if max_index == correct:
                ji += 1
        torch.cuda.synchronize()
        end = time.time()
        all_time += end - start

How did you verify that the CPU is only used?