My device has cuda but when i run the code it gives me this error " raise AssertionError("Torch not compiled with CUDA enabled")"

Hamza_Malik: <p>Here is the part of code</p>
<pre><code class="lang-auto">os.environ["KMP_DUPLICATE_LIB_OK"]="TRUE"
parser = argparse.ArgumentParser()
parser.add_argument('-j', '--workers', default=12, type=int, metavar='N', help='number of data loading workers')
parser.add_argument('--epochs', default=1000, type=int, metavar='N', help='number of total epochs to run')
parser.add_argument('--start-epoch', default=0, type=int, metavar='N', help='manual epoch number (useful on restarts)')
parser.add_argument('-b', '--batch-size', default=40, type=int, metavar='N')
parser.add_argument('--lr', '--learning-rate', default=0.001, type=float, metavar='LR', dest='lr')
parser.add_argument('--momentum', default=0.9, type=float, metavar='M')
parser.add_argument('--wd', '--weight-decay', default=1e-1, type=float, metavar='W', dest='weight_decay')
parser.add_argument('-p', '--print-freq', default=10, type=int, metavar='N', help='print frequency')
parser.add_argument('--resume', default=None, type=str, metavar='PATH', help='path to latest checkpoint')
parser.add_argument('--data_set', type=int, default=1)
parser.add_argument('--gpu', type=str, default='0')

args = parser.parse_args()
now = datetime.datetime.now()
time_str = now.strftime("[%m-%d]-[%H:%M]-")
project_path = './'
log_txt_path = project_path + 'log/' + time_str + 'set' + str(args.data_set) + '-log.txt'
log_curve_path = project_path + 'log/' + time_str + 'set' + str(args.data_set) + '-log.png'
checkpoint_path = project_path + 'checkpoint/' + time_str + 'set' + str(args.data_set) + '-model.pth'
best_checkpoint_path = project_path + 'checkpoint/' + time_str + 'set' + str(args.data_set) + '-model_best.pth'
os.environ["CUDA_VISIBLE_DEVICES"] = args.gpu
pretrained_checkpoint_path = './pretrain_DFEW.pth'
def SoftCrossEntropy(inputs, target, reduction='average'):
    log_likelihood = -torch.log_softmax(inputs, dim=1)
    batch = inputs.shape[0]
    if reduction == 'average':
        loss = torch.sum(torch.mul(log_likelihood, target)) / batch
    else:
        loss = torch.sum(torch.mul(log_likelihood, target))
    return loss

def main():
    best_acc = 0
    recorder = RecorderMeter(args.epochs)
    print('The training time: ' + now.strftime("%m-%d %H:%M"))
    print('The training set: set ' + str(args.data_set))
    with open(log_txt_path, 'a') as f:
        f.write('The training set: set ' + str(args.data_set) + '\n')

    # create model and load pre_trained parameters
    model = GenerateModel()
    model = torch.nn.DataParallel(model).cuda()
    ##CE_LOSS, keepdim
    criterion = nn.CrossEntropyLoss(reduction='none').cuda()
    optimizer = torch.optim.SGD(model.parameters(), args.lr, momentum=args.momentum, weight_decay=args.weight_decay)
    #lr_decay
    scheduler = torch.optim.lr_scheduler.StepLR(optimizer, step_size=7, gamma=0.5)
    #scheduler = torch.optim.lr_scheduler.CosineAnnealingWarmRestarts(optimizer, T_0=10)
</code></pre>
<p>can anyone please tell me where is the error?</p>
<p>I also have the updated driver of my cuda<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/2/5/257e79c49dd2c5815e84d2ababd3bd27b0b9e258.png" data-download-href="https://discuss.pytorch.org/uploads/default/257e79c49dd2c5815e84d2ababd3bd27b0b9e258" title="image"><img src="https://discuss.pytorch.org/uploads/default/original/3X/2/5/257e79c49dd2c5815e84d2ababd3bd27b0b9e258.png" alt="image" data-base62-sha1="5lGDDhl3B0hPsbrfvbIJpbfZHGo" width="690" height="331" data-dominant-color="181818"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">715×343 9.02 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>

ptrblck: <p>What is <code>print(torch.__version__)</code> and <code>print(torch.version.cuda)</code> returning?</p>

Hamza_Malik: <p>it’s giving me this when i run it on my main code<br>
<img src="https://discuss.pytorch.org/uploads/default/original/3X/9/1/913d95d6703c107de927800faba82b60fe67ab25.png" alt="image" data-base62-sha1="kIRb6x3M0xfC1c7xEYelxh94SWN" width="492" height="83"></p>

ptrblck: <p>Thanks for the output (you can post code snippets by wrapping them into three backticks ``` instead of posting pictures).<br>
This would mean you’ve installed the CPU-only binaries and you would need to install the binaries shipping with the CUDA dependencies.</p>