amazon-science / patchcore-inspection

Apache License 2.0
779 stars 154 forks source link

[Question] Can this project be tested without gpu? #72

Open BIAOXYZ opened 1 year ago

BIAOXYZ commented 1 year ago

I had met this issue:

root@17b8a75dadc2:/patchcore-test# datapath=/tmp2/mvtec datasets=('bottle' 'cable' 'capsule' 'carpet' 'grid' 'hazelnut'
> 'leather' 'metal_nut' 'pill' 'screw' 'tile' 'toothbrush' 'transistor' 'wood' 'zipper')
root@17b8a75dadc2:/patchcore-test# dataset_flags=($(for dataset in "${datasets[@]}"; do echo '-d '$dataset; done))
root@17b8a75dadc2:/patchcore-test# python3 bin/run_patchcore.py --gpu 0 --seed 0 --save_patchcore_model \
> --log_group IM224_WR50_L2-3_P01_D1024-1024_PS-3_AN-1_S0 --log_project MVTecAD_Results results \
> patch_core -b wideresnet50 -le layer2 -le layer3 --faiss_on_gpu \
> --pretrain_embed_dimension 1024  --target_embed_dimension 1024 --anomaly_scorer_num_nn 1 --patchsize 3 \
> sampler -p 0.1 approx_greedy_coreset dataset --resize 256 --imagesize 224 "${dataset_flags[@]}" mvtec $datapath
INFO:__main__:Command line arguments: bin/run_patchcore.py --gpu 0 --seed 0 --save_patchcore_model --log_group IM224_WR50_L2-3_P01_D1024-1024_PS-3_AN-1_S0 --log_project MVTecAD_Results results patch_core -b wideresnet50 -le layer2 -le layer3 --faiss_on_gpu --pretrain_embed_dimension 1024 --target_embed_dimension 1024 --anomaly_scorer_num_nn 1 --patchsize 3 sampler -p 0.1 approx_greedy_coreset dataset --resize 256 --imagesize 224 -d bottle -d cable -d capsule -d carpet -d grid -d hazelnut -d leather -d metal_nut -d pill -d screw -d tile -d toothbrush -d transistor -d wood -d zipper mvtec /tmp2/mvtec
INFO:__main__:Evaluating dataset [mvtec_bottle] (1/15)...
Traceback (most recent call last):
  File "bin/run_patchcore.py", line 435, in <module>
    main()
  File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1689, in invoke
    return _process_result(rv)
  File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1626, in _process_result
    value = ctx.invoke(self._result_callback, value, **ctx.params)
  File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "bin/run_patchcore.py", line 78, in run
    with device_context:
  File "/usr/local/lib/python3.8/dist-packages/torch/cuda/__init__.py", line 316, in __enter__
    self.prev_idx = torch.cuda._exchange_device(self.idx)
  File "/usr/local/lib/python3.8/dist-packages/torch/cuda/__init__.py", line 247, in _lazy_init
    torch._C._cuda_init()
RuntimeError: Found no NVIDIA driver on your system. Please check that you have an NVIDIA GPU and installed a driver from http://www.nvidia.com/Download/index.aspx

Because I find the default value for --gpu is 0, so I would like to know if it can be run with only CPU. Thanks!

mincheoree commented 1 year ago

@BIAOXYZ I think you need to remove the option faiss_on_gpu

BIAOXYZ commented 1 year ago

@BIAOXYZ I think you need to remove the option faiss_on_gpu

thx, I will make a try later.