coolzhao / Geo-SAM

A QGIS plugin tool using Segment Anything Model (SAM) to accelerate segmenting or delineating landforms in geospatial raster images.
MIT License
199 stars 26 forks source link

trouble running Geo-SAM Image Encoder! #34

Open MohammadMr opened 4 months ago

MohammadMr commented 4 months ago

i'm using .tif file as input and my laptop doesn't have cuda installed on it. the 'Use GPU if CUDA is available' box is unchecked I'm getting the fallowing error:

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.

what can i do? should i install CUDA?

Fanchengyan commented 4 months ago

Hi @MohammadMr ,

Could you please post the original error log? Based on your current information, I am unable to pinpoint the issue.

MohammadMr commented 4 months ago

sure, here it is:

Traceback (most recent call last): File "C:\Users/MrMe/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/MrMe/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\MrMe\AppData\Roaming\Python\Python39\site-packages\segment_anything\build_sam.py", line 38, in build_sam_vit_b return _build_sam( File "C:\Users\MrMe\AppData\Roaming\Python\Python39\site-packages\segment_anything\build_sam.py", line 105, in _build_sam state_dict = torch.load(f) File "C:\Users\MrMe\AppData\Roaming\Python\Python39\site-packages\torch\serialization.py", line 1026, in load return _load(opened_zipfile, File "C:\Users\MrMe\AppData\Roaming\Python\Python39\site-packages\torch\serialization.py", line 1438, in _load result = unpickler.load() File "C:\Users\MrMe\AppData\Roaming\Python\Python39\site-packages\torch\serialization.py", line 1408, in persistent_load typed_storage = load_tensor(dtype, nbytes, key, _maybe_decode_ascii(location)) File "C:\Users\MrMe\AppData\Roaming\Python\Python39\site-packages\torch\serialization.py", line 1382, in load_tensor wrap_storage=restore_location(storage, location), File "C:\Users\MrMe\AppData\Roaming\Python\Python39\site-packages\torch\serialization.py", line 391, in default_restore_location result = fn(storage, location) File "C:\Users\MrMe\AppData\Roaming\Python\Python39\site-packages\torch\serialization.py", line 266, in _cuda_deserialize device = validate_cuda_device(location) File "C:\Users\MrMe\AppData\Roaming\Python\Python39\site-packages\torch\serialization.py", line 250, 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.

Execution failed after 26.18 seconds

Fanchengyan commented 4 months ago

Hi @MohammadMr ,

Please check if you have selected the correct checkpoint : https://geo-sam.readthedocs.io/en/latest/Usage/encoding.html#download-sam-checkpoints

This appears to be a similar issue as problem #21 .