coolzhao / Geo-SAM

A QGIS plugin tool using Segment Anything Model (SAM) to accelerate segmenting or delineating landforms in geospatial raster images.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Image encoder on the CPU.

OMilosh opened this issue · comments

Hello! Thanks for your work.
I can’t run the image encoder on the CPU due to the error in the screenshot below.
Screenshot_1
Where could the error be? All dependencies are installed according to the tutorial.

Traceback (most recent call last):
File "C:\Users/User/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\Geo-SAM\tools\sam_processing_algorithm.py", line 491, in processAlgorithm
self.sam_model = self.initialize_sam(
File "C:\Users/User/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\Geo-SAM\tools\sam_processing_algorithm.py", line 627, in initialize_sam
sam_model = sam_model_registry[model_type](
File "C:\Users\User\AppData\Roaming\Python\Python39\site-packages\segment_anything\build_sam.py", line 28, in build_sam_vit_l
return _build_sam(
File "C:\Users\User\AppData\Roaming\Python\Python39\site-packages\segment_anything\build_sam.py", line 105, in _build_sam
state_dict = torch.load(f)
File "C:\PROGRA1\QGIS331.2\apps\Python39\lib\site-packages\torch\serialization.py", line 809, in load
return _load(opened_zipfile, map_location, pickle_module, **pickle_load_args)
File "C:\PROGRA1\QGIS331.2\apps\Python39\lib\site-packages\torch\serialization.py", line 1172, in _load
result = unpickler.load()
File "C:\PROGRA1\QGIS331.2\apps\Python39\lib\site-packages\torch\serialization.py", line 1142, in persistent_load
typed_storage = load_tensor(dtype, nbytes, key, _maybe_decode_ascii(location))
File "C:\PROGRA1\QGIS331.2\apps\Python39\lib\site-packages\torch\serialization.py", line 1116, in load_tensor
wrap_storage=restore_location(storage, location),
File "C:\PROGRA1\QGIS331.2\apps\Python39\lib\site-packages\torch\serialization.py", line 217, in default_restore_location
result = fn(storage, location)
File "C:\PROGRA1\QGIS331.2\apps\Python39\lib\site-packages\torch\serialization.py", line 182, in _cuda_deserialize
device = validate_cuda_device(location)
File "C:\PROGRA1\QGIS331.2\apps\Python39\lib\site-packages\torch\serialization.py", line 166, in validate_cuda_device
raise RuntimeError('Attempting to deserialize object on a CUDA '
RuntimeError: Attempting to deserialize object on a CUDA device but torch.cuda.is_available() is False. If you are running on a CPU-only machine, please use torch.load with map_location=torch.device('cpu') to map your storages to the CPU.

This is strange. Have you tried to uncheck the 'using CUDA' option?

Yes.
image

Sorry, it turned out to be my mistake. I used the wrong checkpoint. Thanks!

Hello ! I have the same problem when unchecking the box and it doesn't matter which checkpoint I use... Do you know why?

Hi @poitevie, did you download the SAM checkpoint or just use the checkpoint included in the plugin? They are for different purposes.
Please follow the link below to download the SAM checkpoint for encoding.
https://geo-sam.readthedocs.io/en/latest/Usage/encoding.html