I finally wanted to test the QuPath SAM extension, but I fail to get the SAM API to run.
I'm sorry if I'm making a dumb mistake, but when I run ...
The application attempts to load the necessary models, but I receive warnings about overwriting model registrations. Eventually, the application fails with a PytorchStreamReader error, forcing the inference to run on CPU despite CUDA being detected. Below is the full error trace:
[path_to_env]\mobile_sam\modeling\tiny_vit_sam.py:656: UserWarning: Overwriting tiny_vit_5m_224 in registry with mobile_sam.modeling.tiny_vit_sam.tiny_vit_5m_224. This is because the name being registered conflicts with an existing name. Please check if this is not expected.
return register_model(fn_wrapper)
[path_to_env]\mobile_sam\modeling\tiny_vit_sam.py:656: UserWarning: Overwriting tiny_vit_11m_224 in registry with mobile_sam.modeling.tiny_vit_sam.tiny_vit_11m_224. This is because the name being registered conflicts with an existing name. Please check if this is not expected.
return register_model(fn_wrapper)
[path_to_env]\mobile_sam\modeling\tiny_vit_sam.py:656: UserWarning: Overwriting tiny_vit_21m_224 in registry with mobile_sam.modeling.tiny_vit_sam.tiny_vit_21m_224. This is because the name being registered conflicts with an existing name. Please check if this is not expected.
return register_model(fn_wrapper)
[path_to_env]\mobile_sam\modeling\tiny_vit_sam.py:656: UserWarning: Overwriting tiny_vit_21m_384 in registry with mobile_sam.modeling.tiny_vit_sam.tiny_vit_21m_384. This is because the name being registered conflicts with an existing name. Please check if this is not expected.
return register_model(fn_wrapper)
[path_to_env]\mobile_sam\modeling\tiny_vit_sam.py:656: UserWarning: Overwriting tiny_vit_21m_512 in registry with mobile_sam.modeling.tiny_vit_sam.tiny_vit_21m_512. This is because the name being registered conflicts with an existing name. Please check if this is not expected.
return register_model(fn_wrapper)
[path_to_env]\samapi\main.py:238: UserWarning: cuda device found but got the error PytorchStreamReader failed reading zip archive: failed finding central directory - using CPU for inference
warnings.warn(
Traceback (most recent call last):
File "[path_to_env]\runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "[path_to_env]\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "[path_to_env]\uvicorn.exe\__main__.py", line 7, in <module>
sys.exit(main())
File "[path_to_env]\click\core.py", line 1157, in __call__
return self.main(*args, **kwargs)
File "[path_to_env]\click\core.py", line 1078, in main
rv = self.invoke(ctx)
File "[path_to_env]\click\core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "[path_to_env]\click\core.py", line 783, in invoke
return __callback(*args, **kwargs)
File "[path_to_env]\uvicorn\main.py", line 412, in main
run(
File "[path_to_env]\uvicorn\main.py", line 579, in run
server.run()
File "[path_to_env]\uvicorn\server.py", line 65, in run
return asyncio.run(self.serve(sockets=sockets))
File "[path_to_env]\asyncio\runners.py", line 44, in run
return loop.run_until_complete(main)
File "[path_to_env]\asyncio\base_events.py", line 649, in run_until_complete
return future.result()
File "[path_to_env]\uvicorn\server.py", line 69, in serve
await self._serve(sockets)
File "[path_to_env]\uvicorn\server.py", line 76, in _serve
config.load()
File "[path_to_env]\uvicorn\config.py", line 434, in load
self.loaded_app = import_from_string(self.app)
File "[path_to_env]\uvicorn\importer.py", line 19, in import_from_string
module = importlib.import_module(module_str)
File "[path_to_env]\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "[path_to_env]\samapi\main.py", line 291, in <module>
_register_default_weights()
File "[path_to_env]\samapi\main.py", line 287, in _register_default_weights
register_state_dict_from_url(model_type, checkpoint_url, f"default")
File "[path_to_env]\samapi\main.py", line 272, in register_state_dict_from_url
raise e
File "[path_to_env]\samapi\main.py", line 261, in register_state_dict_from_url
_, filepath = load_state_dict_from_url(
File "[path_to_env]\samapi\hub_extension.py", line 244, in load_state_dict_from_url
return torch.load(cached_file, map_location=map_location), cached_file
File "[path_to_env]\torch\serialization.py", line 1004, in load
with _open_zipfile_reader(opened_file) as opened_zipfile:
File "[path_to_env]\torch\serialization.py", line 456, in __init__
super().__init__(torch._C.PyTorchFileReader(name_or_buffer))
RuntimeError: PytorchStreamReader failed reading zip archive: failed finding central directory
Any assistance or guidance on how to resolve this issue would be greatly appreciated!
P.S. A similar error returns when I set --workers 2 ...
I finally wanted to test the QuPath SAM extension, but I fail to get the SAM API to run.
I'm sorry if I'm making a dumb mistake, but when I run ...
The application attempts to load the necessary models, but I receive warnings about overwriting model registrations. Eventually, the application fails with a
PytorchStreamReadererror, forcing the inference to run on CPU despite CUDA being detected. Below is the full error trace:Full Traceback:
Any assistance or guidance on how to resolve this issue would be greatly appreciated!
Thank you so much and keep up the great work @ksugar !!!
P.S. A similar error returns when I set --workers 2 ...