Thank you very much,
mean while I added some print() to the train function and here is the log I get:
def train(train_loader, model, criterion, optimizer, epoch, log):
    batch_time = AverageMeter()
    data_time = AverageMeter()
    losses = AverageMeter()
    top1 = AverageMeter()
    top5 = AverageMeter()

    # switch to train mode
    model.train()

    end = time.time()
    for i, (input, target) in enumerate(train_loader):
        # measure data loading time
        data_time.update(time.time() - end)

        target = target.cuda(async=True)
        input_var = torch.autograd.Variable(input)
        target_var = torch.autograd.Variable(target)

        # compute output
        output = model(input_var)
        print('output: ',output.shape)
        print('output(target_var): ',target_var.shape)
        loss = criterion(output, target_var)
        
        print('loss: ',loss.shape)  
        
        # measure accuracy and record loss
        prec1, prec5 = accuracy(output.data, target, topk=(1, 5))
        print('input.size(): ', input.size(0))
        print('loss.data[0]: ', loss.data[0])

        losses.update(loss.data[0], input.size(0))
        top1.update(prec1[0], input.size(0))
        top5.update(prec5[0], input.size(0))

        # compute gradient and do SGD step
        optimizer.zero_grad()
        loss.backward()
        optimizer.step()

        # measure elapsed time
        batch_time.update(time.time() - end)
        end = time.time()

        if i % args.print_freq == 0:
            print_log('Epoch: [{0}][{1}/{2}]\t'
                  'Time {batch_time.val:.3f} ({batch_time.avg:.3f})\t'
                  'Data {data_time.val:.3f} ({data_time.avg:.3f})\t'
                  'Loss {loss.val:.4f} ({loss.avg:.4f})\t'
                  'Prec@1 {top1.val:.3f} ({top1.avg:.3f})\t'
                  'Prec@5 {top5.val:.3f} ({top5.avg:.3f})'.format(
                   epoch, i, len(train_loader), batch_time=batch_time,
                   data_time=data_time, loss=losses, top1=top1, top5=top5), log)

Log :
/home/ShishoSama/anaconda3/lib/python3.6/site-packages/torchvision/transforms/transforms.py:397: UserWarning: The use of the transforms.RandomSizedCrop transform is deprecated, please use transforms.RandomResizedCrop instead.
  "please use transforms.RandomResizedCrop instead.")
/home/ShishoSama/anaconda3/lib/python3.6/site-packages/torchvision/transforms/transforms.py:156: UserWarning: The use of the transforms.Scale transform is deprecated, please use transforms.Resize instead.
  "please use transforms.Resize instead.")
 [resnet18] ::   0/100 ----- [[2018-05-03 15:03:49]] [Need: 00:00:00]
output:  torch.Size([128, 1000])
output(target_var):  torch.Size([128])
loss:  torch.Size([1])
input.size():  128
loss.data[0]:  7.064196586608887
Epoch: [0][0/10010]	Time 8.969 (8.969)	Data 7.235 (7.235)	Loss 7.0642 (7.0642)	Prec@1 0.000 (0.000)	Prec@5 0.000 (0.000)
output:  torch.Size([128, 1000])
output(target_var):  torch.Size([128])
loss:  torch.Size([1])
input.size():  128
loss.data[0]:  7.059842586517334
output:  torch.Size([128, 1000])
output(target_var):  torch.Size([128])
loss:  torch.Size([1])
input.size():  128
loss.data[0]:  7.111576080322266
output:  torch.Size([128, 1000])
output(target_var):  torch.Size([128])
loss:  torch.Size([1])
input.size():  128
loss.data[0]:  7.147580146789551
output:  torch.Size([128, 1000])
output(target_var):  torch.Size([128])
loss:  torch.Size([1])
input.size():  128
loss.data[0]:  7.028686046600342
output:  torch.Size([128, 1000])
output(target_var):  torch.Size([128])
loss:  torch.Size([1])
input.size():  128
loss.data[0]:  7.062038421630859
output:  torch.Size([128, 1000])
output(target_var):  torch.Size([128])
loss:  torch.Size([1])
input.size():  128
loss.data[0]:  7.18644380569458
output:  torch.Size([128, 1000])
output(target_var):  torch.Size([128])
loss:  torch.Size([1])
input.size():  128
loss.data[0]:  7.259083271026611
output:  torch.Size([128, 1000])
output(target_var):  torch.Size([128])
loss:  torch.Size([1])
input.size():  128
loss.data[0]:  7.360715866088867
output:  torch.Size([128, 1000])
output(target_var):  torch.Size([128])
loss:  torch.Size([1])
input.size():  128
loss.data[0]:  7.253360748291016
output:  torch.Size([128, 1000])
output(target_var):  torch.Size([128])
loss:  torch.Size([1])
input.size():  128
loss.data[0]:  7.305577278137207
output:  torch.Size([128, 1000])
output(target_var):  torch.Size([128])
loss:  torch.Size([1])
input.size():  128
loss.data[0]:  7.355863094329834
output:  torch.Size([128, 1000])
output(target_var):  torch.Size([128])
loss:  torch.Size([1])
input.size():  128
loss.data[0]:  7.292840003967285
output:  torch.Size([128, 1000])
output(target_var):  torch.Size([128])
loss:  torch.Size([1])
input.size():  128
loss.data[0]:  7.266591548919678
output:  torch.Size([128, 1000])
output(target_var):  torch.Size([128])
loss:  torch.Size([1])
input.size():  128
/pytorch/torch/lib/THCUNN/ClassNLLCriterion.cu:101: void cunn_ClassNLLCriterion_updateOutput_kernel(Dtype *, Dtype *, Dtype *, long *, Dtype *, int, int, int, int, long) [with Dtype = float, Acctype = float]: block: [0,0,0], thread: [9,0,0] Assertion `t >= 0 && t < n_classes` failed.
THCudaCheck FAIL file=/pytorch/torch/lib/THC/generic/THCStorage.c line=36 error=59 : device-side assert triggered
Traceback (most recent call last):
  File "imagenet_train.py", line 313, in <module>
    main()
  File "imagenet_train.py", line 140, in main
    train(train_loader, model, criterion, optimizer, epoch, log)
  File "imagenet_train.py", line 191, in train
    print('loss.data[0]: ', loss.data[0])
RuntimeError: cuda runtime error (59) : device-side assert triggered at /pytorch/torch/lib/THC/generic/THCStorage.c:36
terminate called after throwing an instance of 'std::runtime_error'
  what():  cuda runtime error (59) : device-side assert triggered at /pytorch/torch/lib/THC/generic/THCStorage.c:184
Aborted (core dumped)

It seems it runs for several iterations and then it crashes!
Concerning running on CPU mode only, how should I do that? I’m a newbie in pytorch. I would greatly appreciate if you tell me what to change. would simply removing cuda() part do it?