CPU only pytorch is crashing with error AssertionError: Torch not compiled with CUDA enabled
I'm trying to run the code from this repository and I need to use Pytorch 1.4.0. I've installed the CPU only version of pytorch with pip install torch==1.4.0+cpu torchvision==0.5.0+cpu -f https://download.pytorch.org/whl/torch_stable.html.
I ran the program by doing py -m train_Kfold_CV --device 0 --fold_id 10 --np_data_dir &quot;C:\Users\username\OneDrive\Desktop\emadeldeen\AttnSleep\prepare_datasets\edf_20_npz&quot; but I'm getting this error:
  File &quot;C:\Users\username\AppData\Local\Programs\Python\Python37\lib\runpy.py&quot;, line 193, in _run_module_as_main
    &quot;__main__&quot;, mod_spec)
  File &quot;C:\Users\username\AppData\Local\Programs\Python\Python37\lib\runpy.py&quot;, line 85, in _run_code
    exec(code, run_globals)
  File &quot;C:\Users\username\OneDrive\Desktop\emadeldeen\AttnSleep\train_Kfold_CV.py&quot;, line 94, in &lt;module&gt;
    main(config, fold_id)
  File &quot;C:\Users\username\OneDrive\Desktop\emadeldeen\AttnSleep\train_Kfold_CV.py&quot;, line 65, in main
    trainer.train()
  File &quot;C:\Users\username\OneDrive\Desktop\emadeldeen\AttnSleep\base\base_trainer.py&quot;, line 66, in train
    result, epoch_outs, epoch_trgs = self._train_epoch(epoch, self.epochs)
  File &quot;C:\Users\username\OneDrive\Desktop\emadeldeen\AttnSleep\trainer\trainer.py&quot;, line 49, in _train_epoch
    loss = self.criterion(output, target, self.class_weights)
  File &quot;C:\Users\username\OneDrive\Desktop\emadeldeen\AttnSleep\model\loss.py&quot;, line 6, in weighted_CrossEntropyLoss
    cr = nn.CrossEntropyLoss(weight=torch.tensor(classes_weights).cuda())
  File &quot;C:\Users\username\AppData\Local\Programs\Python\Python37\lib\site-packages\torch\cuda\__init__.py&quot;, line 196, in _lazy_init
    _check_driver()
  File &quot;C:\Users\username\AppData\Local\Programs\Python\Python37\lib\site-packages\torch\cuda\__init__.py&quot;, line 94, in _check_driver
    raise AssertionError(&quot;Torch not compiled with CUDA enabled&quot;)
AssertionError: Torch not compiled with CUDA enabled

I've changed the number of GPU in the config to 0 and tried adding device = torch.device('cpu') at the begining of the program, but it's not doing anything. How can I fix this error? I'm using windows 10 with python 3.7.9 if it helps
Thanks

You are using CPU only pytorch, but your code has statement like cr = nn.CrossEntropyLoss(weight=torch.tensor(classes_weights).cuda()) which is trying to move the tensor to GPU.
To fix it,
remove all the .cuda() operations.
