marco-rudolph / AST

This is the code to the WACV 2023 paper "Asymmetric Student-Teacher Networks for Industrial Anomaly Detection" by Marco Rudolph, Tom Wehrbein, Bodo Rosenhahn and Bastian Wandt.
72 stars 10 forks source link

Torch not compiled with CUDA enabled #4

Closed danielsoy closed 1 year ago

danielsoy commented 1 year ago

Hi Marco, thanks for sharing your project.

I was trying to run train_student.py from CPU with device=cpu in config.py, but I have got:

Torch not compiled with CUDA enabled error.

Is there another device config that i should change, to train the model from CPU?

I could run all the scripts in colab, from GPU by the way.

marco-rudolph commented 1 year ago

Hey,

sorry for the inconvenience. There were ".cuda()"s which I changed to ".to(c.devices)"s in the latest commit. Please report if there are still issues with this.

With "cpu" for device in config.py everything should be set.

Hope that helps, Marco

danielsoy commented 1 year ago

the error poped, training with the latest commit. the one with :(c.devices).

running on colab with cpu enabled in config.py, and cpu as resource from google, fails too and shows: RuntimeError: No CUDA GPUs are available.

As it was trying to train with gpu, despite the selected device is cpu.

danielsoy commented 1 year ago

heres the full log:

Train class cable_gland Traceback (most recent call last): File "train_student.py", line 109, in train_dataset(train) File "/content/AST/utils.py", line 25, in train_dataset mean_sc, max_sc = train_function(train_loader, test_loader) File "train_student.py", line 13, in train student = Model(nf=not c.asymmetric_student, channels_hidden=c.channels_hidden_student, n_blocks=c.n_st_blocks) File "/content/AST/model.py", line 95, in init self.pos_enc = positionalencoding2d(c.pos_enc_dim, c.map_len, c.map_len) File "/content/AST/model.py", line 79, in positionalencoding2d return P.cuda()[None] File "/usr/local/lib/python3.8/dist-packages/torch/cuda/init.py", line 229, in _lazy_init torch._C._cuda_init() RuntimeError: No CUDA GPUs are available

marco-rudolph commented 1 year ago

It seems like you don't use the latest commit. line 79 in model.py is https://github.com/marco-rudolph/AST/blob/47adbdce2f17ffe238a52e0bcb4c277b87652e8b/model.py#L79

danielsoy commented 1 year ago

bingo! mine says CUDA instead of c.device. Thanks , I see how it goes now...

marco-rudolph commented 1 year ago

no problem :)