devika icon indicating copy to clipboard operation
devika copied to clipboard

[Bug] Numpy not available following install instructions

Open yuma-dev opened this issue 1 year ago • 6 comments

Describe the bug

after following the install instructions 1 to 1 i get this error:

Expected behavior

devika runs

Screenshots and logs

(devika) PS C:\Users\Fabia\Documents\devika> py devika.py
24.06.18 02:15:35: root: INFO   : Initializing Devika...
24.06.18 02:15:35: root: INFO   : checking configurations...
24.06.18 02:15:35: root: INFO   : Initializing Prerequisites Jobs...

A module that was compiled using NumPy 1.x cannot be run in
NumPy 2.0.0 as it may crash. To support both 1.x and 2.x
versions of NumPy, modules must be compiled with NumPy 2.0.
Some module may need to rebuild instead e.g. with 'pybind11>=2.12'.

If you are a user of the module, the easiest solution will be to
downgrade to 'numpy<2' or try to upgrade the affected module.
We expect that some modules will need time to support NumPy 2.

Traceback (most recent call last):  File "C:\Users\Fabia\Documents\devika\devika.py", line 8, in <module>
    init_devika()
  File "C:\Users\Fabia\Documents\devika\src\init.py", line 27, in init_devika
    from src.bert.sentence import SentenceBert
  File "C:\Users\Fabia\Documents\devika\src\bert\sentence.py", line 1, in <module>
    from keybert import KeyBERT
  File "C:\Users\Fabia\Documents\devika\.venv\Lib\site-packages\keybert\__init__.py", line 3, in <module>
    from keybert._llm import KeyLLM
  File "C:\Users\Fabia\Documents\devika\.venv\Lib\site-packages\keybert\_llm.py", line 4, in <module>
    from sentence_transformers import util
  File "C:\Users\Fabia\Documents\devika\.venv\Lib\site-packages\sentence_transformers\__init__.py", line 15, in <module>
    from sentence_transformers.trainer import SentenceTransformerTrainer
  File "C:\Users\Fabia\Documents\devika\.venv\Lib\site-packages\sentence_transformers\trainer.py", line 10, in <module>
    from transformers import EvalPrediction, PreTrainedTokenizerBase, Trainer, TrainerCallback
  File "C:\Users\Fabia\Documents\devika\.venv\Lib\site-packages\transformers\utils\import_utils.py", line 1525, in __getattr__
    module = self._get_module(self._class_to_module[name])
  File "C:\Users\Fabia\Documents\devika\.venv\Lib\site-packages\transformers\utils\import_utils.py", line 1535, in _get_module
    return importlib.import_module("." + module_name, self.__name__)
  File "C:\Python312\Lib\importlib\__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "C:\Users\Fabia\Documents\devika\.venv\Lib\site-packages\transformers\trainer.py", line 71, in <module>
    from .optimization import Adafactor, get_scheduler
  File "C:\Users\Fabia\Documents\devika\.venv\Lib\site-packages\transformers\optimization.py", line 27, in <module>
    from .trainer_pt_utils import LayerWiseDummyOptimizer, LayerWiseDummyScheduler
  File "C:\Users\Fabia\Documents\devika\.venv\Lib\site-packages\transformers\trainer_pt_utils.py", line 235, in <module>
    device: Optional[torch.device] = torch.device("cuda"),
C:\Users\Fabia\Documents\devika\.venv\Lib\site-packages\transformers\trainer_pt_utils.py:235: UserWarning: Failed to initialize NumPy: _ARRAY_API not found (Triggered internally at ..\torch\csrc\utils\tensor_numpy.cpp:84.)
  device: Optional[torch.device] = torch.device("cuda"),
24.06.18 02:15:40: root: INFO   : Loading sentence-transformer BERT models...
Traceback (most recent call last):
  File "C:\Users\Fabia\Documents\devika\devika.py", line 8, in <module>
    init_devika()
  File "C:\Users\Fabia\Documents\devika\src\init.py", line 31, in init_devika
    SentenceBert(prompt).extract_keywords()
  File "C:\Users\Fabia\Documents\devika\src\bert\sentence.py", line 9, in extract_keywords
    keywords = self.kw_model.extract_keywords(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Fabia\Documents\devika\.venv\Lib\site-packages\keybert\_model.py", line 195, in extract_keywords
    doc_embeddings = self.model.embed(docs)
                     ^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Fabia\Documents\devika\.venv\Lib\site-packages\keybert\backend\_sentencetransformers.py", line 67, in embed
    embeddings = self.embedding_model.encode(documents, **self.encode_kwargs)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Fabia\Documents\devika\.venv\Lib\site-packages\sentence_transformers\SentenceTransformer.py", line 568, in encode
    all_embeddings = np.asarray([emb.numpy() for emb in all_embeddings])
                                 ^^^^^^^^^^^
RuntimeError: Numpy is not available

Configuration

- OS: Windows
- Python version: Python 3.12.2
- Node version: 10.2.4
- bun version: 1.1.13
- search engine: x
- Model: x

yuma-dev avatar Jun 18 '24 00:06 yuma-dev

Arrived here from Google search, have exact same issue with ComfyUI fresh install. If same error occurs in two different repos, can it be package related?

upd: fixed the issue by deleteing current numpy 2.0.0 and installing correct version 1.25.2

AVcorp avatar Jun 18 '24 16:06 AVcorp

have a look on my comment here if might help and confirm

https://github.com/stitionai/devika/pull/603#issuecomment-2177320283

Arrived here from Google search, have exact same issue with ComfyUI fresh install. If same error occurs in two different repos, can it be package related?

upd: fixed the issue by deleteing current numpy 2.0.0 and installing correct version 1.25.2

MahmoudZaki1 avatar Jun 19 '24 01:06 MahmoudZaki1

Arrived here from Google search, have exact same issue with ComfyUI fresh install. If same error occurs in two different repos, can it be package related?

upd: fixed the issue by deleteing current numpy 2.0.0 and installing correct version 1.25.2

Had the same bug and this solution worked for me with a uv pip install --force-reinstall -v "numpy==1.25.2"

colpiche avatar Jun 19 '24 08:06 colpiche

Arrived here from Google search, have exact same issue with ComfyUI fresh install. If same error occurs in two different repos, can it be package related? upd: fixed the issue by deleteing current numpy 2.0.0 and installing correct version 1.25.2

Had the same bug and this solution worked for me with a uv pip install --force-reinstall -v "numpy==1.25.2"

Thank you , thats fixed it !!!

edition08 avatar Jul 04 '24 14:07 edition08

On trying this I got the following issue

error: Failed to prepare distributions
  Caused by: Failed to fetch wheel: numpy==1.25.2
  Caused by: Failed to build: `numpy==1.25.2`
  Caused by: Build backend failed to determine extra requires with `build_wheel()` with exit status: 1
--- stdout:

--- stderr:
Traceback (most recent call last):
  File "<string>", line 8, in <module>
  File "/Users/zayed/Library/Caches/uv/environments-v0/.tmpor9HWi/lib/python3.12/site-packages/setuptools/__init__.py", line 10, in <module>
    import distutils.core
ModuleNotFoundError: No module named 'distutils'
---

engmsaleh avatar Jul 30 '24 23:07 engmsaleh

It was an issue with python version, I have downgraded to 3.11 and it worked

engmsaleh avatar Jul 31 '24 00:07 engmsaleh