dhkdnduq / PatchCore_anomaly_detection

Unofficial implementation of PatchCore anomaly detection
Apache License 2.0
25 stars 4 forks source link

During the test, the GPU usage is large. #7

Closed leolv131 closed 2 years ago

leolv131 commented 3 years ago

it can trained, but it cant test info: File "C:\Users\l00586461.conda\envs\patchcore\lib\site-packages\pytorch_lightning\plugins\training_type\training_type_plugin.py", line 164, in test_step return self.lightning_module.test_step(*args, kwargs) File "train_frd_v1.1_no_gt.py", line 393, in test_step score_patches = knn(torch.from_numpy(embedding_test).cuda())[0].cpu().detach().numpy() File "train_frd_v1.1_no_gt.py", line 217, in call return self.predict(x) File "train_frd_v1.1_no_gt.py", line 241, in predict dist = distance_matrix(x, self.train_pts, self.p) (1 / self.p) File "train_frd_v1.1_no_gt.py", line 201, in distance_matrix dist = torch.pow(x - y, p).sum(2) RuntimeError: CUDA out of memory. Tried to allocate 11.25 GiB (GPU 0; 16.00 GiB total capacity; 11.54 GiB already allocated; 2.35 GiB free; 11.56 GiB reserved in total by PyTorch)

leolv131 commented 3 years ago

input size 196*196, coreset_sampling_ratio 0.01, n_neighbors 9

dhkdnduq commented 3 years ago

1.If reducing the number of training data ,pickle size and required gpu capacity are reduced. 2.If PC memory is bigger than GPU memory, use the cpu. but it will be slow.

leolv131 commented 3 years ago

1.If reducing the number of training data ,pickle size and required gpu capacity are reduced. 2.If PC memory is bigger than GPU memory, use the cpu. but it will be slow.

thank you for your reply, i reduce the input size,and it can test now