nikolamilosevic86 / local-genAI-search

Local-GenAI-Search is a generative search engine based on Llama 3, langchain and qdrant that answers questions based on your local files
GNU General Public License v3.0
82 stars 30 forks source link

Crash on start of uvicorn_start.py #1

Closed dejankocic closed 5 months ago

dejankocic commented 5 months ago

Hello,

Following the instructions provided and completing the indexing, I run _python uvicornstart.py Running this script produces the following error. Could you please advise?

I am using Python 3.11.7

Thx, Dejan

C:\Users\Dejan\AppData\Roaming\Python\Python311\site-packages\huggingface_hub\file_download.py:1132: FutureWarning: resume_download is deprecated and will be removed in version 1.0.0. Downloads always resume when possible. If you want to force a new download, use force_download=True. warnings.warn( INFO: Started server process [18808] INFO: Waiting for application startup. INFO: Application startup complete. Process SpawnProcess-3: Traceback (most recent call last): File "C:\Users\Dejan\AppData\Roaming\Python\Python311\site-packages\portalocker\portalocker.py", line 42, in lock win32file.LockFileEx(os_fh, mode, 0, -0x10000, __overlapped) pywintypes.error: (33, 'LockFileEx', 'The process cannot access the file because another process has locked a portion of the file.')

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "C:\Users\Dejan\AppData\Roaming\Python\Python311\site-packages\qdrant_client\local\qdrant_local.py", line 114, in _load portalocker.lock( File "C:\Users\Dejan\AppData\Roaming\Python\Python311\site-packages\portalocker\portalocker.py", line 47, in lock raise exceptions.AlreadyLocked( portalocker.exceptions.AlreadyLocked: (1, 'The process cannot access the file because another process has locked a portion of the file.')

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\ProgramData\anaconda3\Lib\multiprocessing\process.py", line 314, in _bootstrap self.run() File "C:\ProgramData\anaconda3\Lib\multiprocessing\process.py", line 108, in run self._target(*self._args, **self._kwargs) File "C:\Users\Dejan\AppData\Roaming\Python\Python311\site-packages\uvicorn_subprocess.py", line 80, in subprocess_started target(sockets=sockets) File "C:\Users\Dejan\AppData\Roaming\Python\Python311\site-packages\uvicorn\supervisors\multiprocess.py", line 63, in target return self.real_target(sockets) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Dejan\AppData\Roaming\Python\Python311\site-packages\uvicorn\server.py", line 65, in run return asyncio.run(self.serve(sockets=sockets)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\ProgramData\anaconda3\Lib\asyncio\runners.py", line 190, in run return runner.run(main) ^^^^^^^^^^^^^^^^ File "C:\ProgramData\anaconda3\Lib\asyncio\runners.py", line 118, in run return self._loop.run_until_complete(task) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\ProgramData\anaconda3\Lib\asyncio\base_events.py", line 653, in run_until_complete return future.result() ^^^^^^^^^^^^^^^ File "C:\Users\Dejan\AppData\Roaming\Python\Python311\site-packages\uvicorn\server.py", line 69, in serve await self._serve(sockets) File "C:\Users\Dejan\AppData\Roaming\Python\Python311\site-packages\uvicorn\server.py", line 76, in _serve config.load() File "C:\Users\Dejan\AppData\Roaming\Python\Python311\site-packages\uvicorn\config.py", line 434, in load self.loaded_app = import_from_string(self.app) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Dejan\AppData\Roaming\Python\Python311\site-packages\uvicorn\importer.py", line 19, in import_from_string module = importlib.import_module(module_str) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\ProgramData\anaconda3\Lib\importlib__init.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "", line 1204, in _gcd_import File "", line 1176, in _find_and_load File "", line 1147, in _find_and_load_unlocked File "", line 690, in _load_unlocked File "", line 940, in exec_module File "", line 241, in _call_with_frames_removed File "C:\Users\Dejan\Documents\Projects\GitHub\local-gen-search\api.py", line 56, in client = QdrantClient(path="qdrant/") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Dejan\AppData\Roaming\Python\Python311\site-packages\qdrant_client\qdrant_client.py", line 117, in init self._client = QdrantLocal( ^^^^^^^^^^^^ File "C:\Users\Dejan\AppData\Roaming\Python\Python311\site-packages\qdrant_client\local\qdrant_local.py", line 60, in init__ self._load() File "C:\Users\Dejan\AppData\Roaming\Python\Python311\site-packages\qdrant_client\local\qdrant_local.py", line 119, in _load raise RuntimeError( RuntimeError: Storage folder qdrant/ is already accessed by another instance of Qdrant client. If you require concurrent access, use Qdrant server instead. Process SpawnProcess-2: Traceback (most recent call last): File "C:\Users\Dejan\AppData\Roaming\Python\Python311\site-packages\portalocker\portalocker.py", line 42, in lock win32file.LockFileEx(os_fh, mode, 0, -0x10000, __overlapped) pywintypes.error: (33, 'LockFileEx', 'The process cannot access the file because another process has locked a portion of the file.')

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "C:\Users\Dejan\AppData\Roaming\Python\Python311\site-packages\qdrant_client\local\qdrant_local.py", line 114, in _load portalocker.lock( File "C:\Users\Dejan\AppData\Roaming\Python\Python311\site-packages\portalocker\portalocker.py", line 47, in lock raise exceptions.AlreadyLocked( portalocker.exceptions.AlreadyLocked: (1, 'The process cannot access the file because another process has locked a portion of the file.')

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\ProgramData\anaconda3\Lib\multiprocessing\process.py", line 314, in _bootstrap self.run() File "C:\ProgramData\anaconda3\Lib\multiprocessing\process.py", line 108, in run self._target(*self._args, **self._kwargs) File "C:\Users\Dejan\AppData\Roaming\Python\Python311\site-packages\uvicorn_subprocess.py", line 80, in subprocess_started target(sockets=sockets) File "C:\Users\Dejan\AppData\Roaming\Python\Python311\site-packages\uvicorn\supervisors\multiprocess.py", line 63, in target return self.real_target(sockets) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Dejan\AppData\Roaming\Python\Python311\site-packages\uvicorn\server.py", line 65, in run return asyncio.run(self.serve(sockets=sockets)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\ProgramData\anaconda3\Lib\asyncio\runners.py", line 190, in run return runner.run(main) ^^^^^^^^^^^^^^^^ File "C:\ProgramData\anaconda3\Lib\asyncio\runners.py", line 118, in run return self._loop.run_until_complete(task) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\ProgramData\anaconda3\Lib\asyncio\base_events.py", line 653, in run_until_complete return future.result() ^^^^^^^^^^^^^^^ File "C:\Users\Dejan\AppData\Roaming\Python\Python311\site-packages\uvicorn\server.py", line 69, in serve await self._serve(sockets) File "C:\Users\Dejan\AppData\Roaming\Python\Python311\site-packages\uvicorn\server.py", line 76, in _serve config.load() File "C:\Users\Dejan\AppData\Roaming\Python\Python311\site-packages\uvicorn\config.py", line 434, in load self.loaded_app = import_from_string(self.app) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Dejan\AppData\Roaming\Python\Python311\site-packages\uvicorn\importer.py", line 19, in import_from_string module = importlib.import_module(module_str) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\ProgramData\anaconda3\Lib\importlib__init.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "", line 1204, in _gcd_import File "", line 1176, in _find_and_load File "", line 1147, in _find_and_load_unlocked File "", line 690, in _load_unlocked File "", line 940, in exec_module File "", line 241, in _call_with_frames_removed File "C:\Users\Dejan\Documents\Projects\GitHub\local-gen-search\api.py", line 56, in client = QdrantClient(path="qdrant/") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Dejan\AppData\Roaming\Python\Python311\site-packages\qdrant_client\qdrant_client.py", line 117, in init self._client = QdrantLocal( ^^^^^^^^^^^^ File "C:\Users\Dejan\AppData\Roaming\Python\Python311\site-packages\qdrant_client\local\qdrant_local.py", line 60, in init__ self._load() File "C:\Users\Dejan\AppData\Roaming\Python\Python311\site-packages\qdrant_client\local\qdrant_local.py", line 119, in _load raise RuntimeError( RuntimeError: Storage folder qdrant/ is already accessed by another instance of Qdrant client. If you require concurrent access, use Qdrant server instead. INFO: Waiting for child process [2448] INFO: Child process [2448] died INFO: Waiting for child process [5476] INFO: Child process [5476] died INFO: Waiting for child process [5476] INFO: Child process [5476] died C:\Users\Dejan\AppData\Roaming\Python\Python311\site-packages\transformers\utils\generic.py:441: UserWarning: torch.utils._pytree._register_pytree_node is deprecated. Please use torch.utils._pytree.register_pytree_node instead. _torch_pytree._register_pytree_node( C:\Users\Dejan\AppData\Roaming\Python\Python311\site-packages\transformers\utils\generic.py:441: UserWarning: torch.utils._pytree._register_pytree_node is deprecated. Please use torch.utils._pytree.register_pytree_node instead. _torch_pytree._register_pytree_node( C:\Users\Dejan\AppData\Roaming\Python\Python311\site-packages\langchain_core_api\deprecation.py:119: LangChainDeprecationWarning: The class HuggingFaceEmbeddings was deprecated in LangChain 0.2.2 and will be removed in 0.3.0. An updated version of the class exists in the langchain-huggingface package and should be used instead. To use it run pip install -U langchain-huggingface and import as from langchain_huggingface import HuggingFaceEmbeddings. warn_deprecated( C:\Users\Dejan\AppData\Roaming\Python\Python311\site-packages\langchain_core_api\deprecation.py:119: LangChainDeprecationWarning: The class HuggingFaceEmbeddings was deprecated in LangChain 0.2.2 and will be removed in 0.3.0. An updated version of the class exists in the langchain-huggingface package and should be used instead. To use it run pip install -U langchain-huggingface and import as from langchain_huggingface import HuggingFaceEmbeddings. warn_deprecated( C:\Users\Dejan\AppData\Roaming\Python\Python311\site-packages\transformers\utils\generic.py:441: UserWarning: torch.utils._pytree._register_pytree_node is deprecated. Please use torch.utils._pytree.register_pytree_node instead. _torch_pytree._register_pytree_node( C:\Users\Dejan\AppData\Roaming\Python\Python311\site-packages\langchain_core_api\deprecation.py:119: LangChainDeprecationWarning: The class HuggingFaceEmbeddings was deprecated in LangChain 0.2.2 and will be removed in 0.3.0. An updated version of the class exists in the langchain-huggingface package and should be used instead. To use it run pip install -U langchain-huggingface and import as from langchain_huggingface import HuggingFaceEmbeddings. warn_deprecated( INFO: Received SIGINT, exiting. INFO: Terminated child process [18808] INFO: Terminated child process [24908] INFO: Terminated child process [24936] INFO: Waiting for child process [18808] forrtl: error (200): program aborting due to control-C event Image PC Routine Line Source libifcoremd.dll 00007FF8F2B5DF54 Unknown Unknown Unknown KERNELBASE.dll 00007FF9740D2D17 Unknown Unknown Unknown KERNEL32.DLL 00007FF9756D257D Unknown Unknown Unknown ntdll.dll 00007FF976BCAA48 Unknown Unknown Unknown forrtl: error (200): program aborting due to control-C event Image PC Routine Line Source libifcoremd.dll 00007FF8F2B5DF54 Unknown Unknown Unknown KERNELBASE.dll 00007FF9740D2D17 Unknown Unknown Unknown KERNEL32.DLL 00007FF9756D257D Unknown Unknown Unknown ntdll.dll 00007FF976BCAA48 Unknown Unforrtl: error (200): program aborting due to control-C event Image PC Routine Line Sourknown Unknown ce libifcoremd.dll 00007FF8F2B5DF54 Unknown Unknown Unknown KERNELBASE.dll 00007FF9740D2D17 Unknown Unknown Unknown KERNEL32.DLL 00007FF9756D257D Unknown Unknown Unknown ntdll.dll 00007FF976BCAA48 Unknown Unknown Unknown forrtl: error (200): program aborting due to control-C event Image PC Routine Line Source libifcoremd.dll 00007FF8F2B5DF54 Unknown Unknown Unknown KERNELBASE.dll 00007FF9740D2D17 Unknown Unknown Unknown KERNEL32.DLL 00007FF9756D257D Unknown Unknown Unknown ntdll.dll 00007FF976BCAA48 Unknown Unknown Unknown INFO: Waiting for child process [24908]

dejankocic commented 5 months ago

Maybe this error message will give some useful info

AppData\Roaming\Python\Python311\site-packages\qdrant_client\qdrant_client.py", line 117, in init self._client = QdrantLocal( ^^^^^^^^^^^^ File "C:\Users\Dejan\AppData\Roaming\Python\Python311\site-packages\qdrant_client\local\qdrant_local.py", line 60, in init self._load() File "C:\Users\Dejan\AppData\Roaming\Python\Python311\site-packages\qdrant_client\local\qdrant_local.py", line 119, in _load raise RuntimeError( RuntimeError: Storage folder qdrant/ is already accessed by another instance of Qdrant client. If you require concurrent access, use Qdrant server instead.

nikolamilosevic86 commented 5 months ago

Did you start uvicorn while index was running? The warning that there is already other instance of Qdrant client in qdrant folder happens, but should not disrupt execution. With Qdrant client only a single code can access the vector database, otherwise, Qdrant server would need to be used.

dejankocic commented 5 months ago

@nikolamilosevic86 I thought the same thing, but the indexing was completed (at least from running command point of view).

dejankocic commented 5 months ago

Not sure how it is intendent to work, but whenever I start python uvicorn_start.py, the .lock file gets created in the qdrant folder, even I deleted it previously.

Hope it helps.

Thx, D.

P.S. Just to repeat, indexing looks completed.

Kira-Pgr commented 5 months ago

Fixed the problem by rebooting, deleting the .lockand use uvicorn api:app --reload to start the script

dejankocic commented 5 months ago

I tried, but the same error appears again.

@Kira-Pgr you mean uviconr_start.py api:app -- reload? BTW, what did yo restart?

Prajwalbr625 commented 5 months ago

@dejankocic Delete the .lock file in qdrant, reboot the system, under uvicorn script change reload=True and host to 127.0.0.1, Run the script, this will resolve (RuntimeError: Storage folder qdrant/ is already accessed by another instance of Qdrant client. If you require concurrent access, use Qdrant server instead.)

dejankocic commented 5 months ago

Thx. It works!