Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Haystack not running on Mac M1 #1310

Closed
nisrj10 opened this issue Jul 28, 2021 · 22 comments
Closed

Haystack not running on Mac M1 #1310

nisrj10 opened this issue Jul 28, 2021 · 22 comments
Assignees
Labels
topic:installation type:bug Something isn't working

Comments

@nisrj10
Copy link

nisrj10 commented Jul 28, 2021

Description:
I had the library working fine about 2 months ago. Suddenly it is giving me this error. I tried installing again in new conda env, but scipy installation is stopping installation, as an alternative looked at using miniforge3 but there faiss-cpu won't install. So, I am back to start trying to figure out how to fix this.

error:

ValueError Traceback (most recent call last)
in
----> 1 from haystack.connector import Crawler

~/Documents/Ai_projects/haystack/haystack/init.py in
3 import pandas as pd
4 from haystack.schema import Document, Label, MultiLabel, BaseComponent
----> 5 from haystack.finder import Finder
6 from haystack.pipeline import Pipeline
7 from haystack._version import version

~/Documents/Ai_projects/haystack/haystack/finder.py in
6 from collections import defaultdict
7
----> 8 from haystack.reader.base import BaseReader
9 from haystack.retriever.base import BaseRetriever
10 from haystack import MultiLabel

~/Documents/Ai_projects/haystack/haystack/reader/init.py in
----> 1 from haystack.reader.farm import FARMReader
2 from haystack.reader.transformers import TransformersReader

~/Documents/Ai_projects/haystack/haystack/reader/farm.py in
6 from time import perf_counter
7
----> 8 from farm.data_handler.data_silo import DataSilo
9 from farm.data_handler.processor import SquadProcessor
10 from farm.data_handler.dataloader import NamedDataLoader

~/opt/anaconda3/envs/LiveAi/lib/python3.8/site-packages/farm/data_handler/data_silo.py in
18
19 from farm.data_handler.dataloader import NamedDataLoader
---> 20 from farm.data_handler.processor import Processor, BertStyleLMProcessor
21 from farm.data_handler.utils import grouper
22 from farm.modeling.tokenization import EmbeddingTokenizer

~/opt/anaconda3/envs/LiveAi/lib/python3.8/site-packages/farm/data_handler/processor.py in
15 from tokenizers import Encoding
16 from tokenizers.pre_tokenizers import WhitespaceSplit
---> 17 from transformers import AutoConfig
18
19 from farm.data_handler.dataset import convert_features_to_dataset

~/opt/anaconda3/envs/LiveAi/lib/python3.8/site-packages/transformers/init.py in
41
42 # Check the dependencies satisfy the minimal versions required.
---> 43 from . import dependency_versions_check
44 from .file_utils import (
45 _LazyModule,

~/opt/anaconda3/envs/LiveAi/lib/python3.8/site-packages/transformers/dependency_versions_check.py in
39 continue # not required, check version only if installed
40
---> 41 require_version_core(deps[pkg])
42 else:
43 raise ValueError(f"can't find {pkg} in {deps.keys()}, check dependency_versions_table.py")

~/opt/anaconda3/envs/LiveAi/lib/python3.8/site-packages/transformers/utils/versions.py in require_version_core(requirement)
118 """require_version wrapper which emits a core-specific hint on failure"""
119 hint = "Try: pip install transformers -U or pip install -e '.[dev]' if you're working with git master"
--> 120 return require_version(requirement, hint)

~/opt/anaconda3/envs/LiveAi/lib/python3.8/site-packages/transformers/utils/versions.py in require_version(requirement, hint)
112 if want_ver is not None:
113 for op, want_ver in wanted.items():
--> 114 _compare_versions(op, got_ver, want_ver, requirement, pkg, hint)
115
116

~/opt/anaconda3/envs/LiveAi/lib/python3.8/site-packages/transformers/utils/versions.py in _compare_versions(op, got_ver, want_ver, requirement, pkg, hint)
43 def _compare_versions(op, got_ver, want_ver, requirement, pkg, hint):
44 if got_ver is None:
---> 45 raise ValueError("got_ver is None")
46 if want_ver is None:
47 raise ValueError("want_ver is None")

ValueError: got_ver is None

@brandenchan
Copy link
Contributor

brandenchan commented Jul 29, 2021

Hi @nisrj10 , sorry that it's not running for you at the moment. My first instinct is to say this could be a versioning problem. Am I right in saying that you are installing the latest master by cloning the repo? (I'm making this guess because I see this line which is quite a recent addition 7 from haystack._version import version)

If so, could you try installing an official release version of haystack via pip? (i.e. pip install haystack==0.9)

@brandenchan brandenchan self-assigned this Jul 29, 2021
@nisrj10
Copy link
Author

nisrj10 commented Aug 1, 2021

@brandenchan I had it installed with pip . And I am getting different error due to scipy and other dependencies not installing through requirements.txt when pip install for farm-haystack is done.

@brandenchan
Copy link
Contributor

Are you able to install scipy and these other dependencies by themself? i.e. pip install scipy?

@tholor
Copy link
Member

tholor commented Aug 12, 2021

@julian-risch can you replicate this problem on your Mac?

@tholor tholor added topic:installation type:bug Something isn't working labels Aug 12, 2021
@julian-risch
Copy link
Member

I am currently executing FARM and haystack in an Intel python version and not Apple M1 ARM python version. Without breaking my current setup it's hard to replicate the problem, sorry. 😕 However, I am sure that the problems reported here are not about haystack itself but its requirements. Miniforge is the way to go, in my opinion, e.g., have a look here. faiss-cpu will be a challenge. As I understand it, you will need to compile it yourself. It's unfortunate that there is no support of Apple M1 ARM for many of the libraries. Most people are using workarounds to still have Intel and Apple M1 ARM compatibility.

@nisrj10
Copy link
Author

nisrj10 commented Aug 14, 2021

Are you able to install scipy and these other dependencies by themself? i.e. pip install scipy?

@brandenchan no not anymore.

@nisrj10
Copy link
Author

nisrj10 commented Aug 14, 2021

I am currently executing FARM and haystack in an Intel python version and not Apple M1 ARM python version. Without breaking my current setup it's hard to replicate the problem, sorry. 😕 However, I am sure that the problems reported here are not about haystack itself but its requirements. Miniforge is the way to go, in my opinion, e.g., have a look here. faiss-cpu will be a challenge. As I understand it, you will need to compile it yourself. It's unfortunate that there is no support of Apple M1 ARM for many of the libraries. Most people are using workarounds to still have Intel and Apple M1 ARM compatibility.

@julian-risch I will try compiling faiss-cpu and check if that fixes it.

@julian-risch
Copy link
Member

Hi @nisrj10 I had a look today and managed to install most of haystack's dependencies but not all. Currently, I am still working on installing the following:

  • ray==1.5.0
  • sparqlwrapper
  • more_itertools
  • sqlalchemy_utils
  • faiss-cpu[version='>=1.6.3']
  • weaviate-client==2.5.0

It seems that all of them would need to be compiled if you want to use them. Most of them are optional, which means that large parts of haystack can be used without them. The good news is that FARM can be installed for Apple M1 without any bigger problems.

@nisrj10
Copy link
Author

nisrj10 commented Aug 16, 2021

Hi @nisrj10 I had a look today and managed to install most of haystack's dependencies but not all. Currently, I am still working on installing the following:

  • ray==1.5.0
  • sparqlwrapper
  • more_itertools
  • sqlalchemy_utils
  • faiss-cpu[version='>=1.6.3']
  • weaviate-client==2.5.0

It seems that all of them would need to be compiled if you want to use them. Most of them are optional, which means that large parts of haystack can be used without them. The good news is that FARM can be installed for Apple M1 without any bigger problems.

Screenshot 2021-08-16 at 20 29 14

Got Same issue trying to run farm.
Then tried to install farm in the miniforge3 env where I have pytorch and got this error
Screenshot 2021-08-16 at 20 32 14

@julian-risch
Copy link
Member

I installed sentencepiece via conda install -c conda-forge sentencepiece

@julian-risch
Copy link
Member

julian-risch commented Aug 17, 2021

Hi @nisrj10 let me list the steps that I followed to get haystack running on Mac M1 aka Apple Silicon in more detail:

  1. Install brew and miniforge simple steps are described in this tutorial
  2. Create a virtual environment. I decided to go with python3.9: conda create --name py39 python=3.9 and activate it afterward: conda activate py39
  3. Clone FARM repository and install FARM and its dependencies. (FARM itself is a dependency of haystack.)
    • git clone https://github.com/deepset-ai/FARM.git
    • cd FARM
    • conda install pytorch scikit-learn
    • conda install -c conda-forge sentencepiece
    • pip install -r requirements.txt
    • pip install -e .
  4. Optionally, you can try to run python examples/doc_classification.py now or any other example. If it shows some nice ASCII art, you're all good.
  5. Clone haystack repository and install some haystack dependencies:
    • cd ..
    • git clone https://github.com/deepset-ai/haystack.git
    • cd haystack
    • conda install -c conda-forge psycopg2-binary
    • conda install -c conda-forge uvloop
  6. Edit requirements.txt to remove (comment out) dependencies that I could not get installed (so far) or that are already installed:
    • #farm==0.8.0
    • #--find-links=https://download.pytorch.org/whl/torch_stable.html
    • #psycopg2-binary; sys_platform != 'win32' and sys_platform != 'cygwin'
    • #faiss-cpu>=1.6.3
    • #uvloop==0.14; sys_platform != 'win32' and sys_platform != 'cygwin'
    • #ray==1.5.0
  7. Now that everything is prepared you should be able to run the following two commands without getting any errors:
    • pip install -r requirements.txt
    • pip install -e .
  8. Test the setup, e.g., by running python tutorials/Tutorial1_Basic_QA_Pipeline.py

Note that we did not install all dependencies, such as faiss-cpu. As a consequence, there are some limits to the features that we can use in haystack on Apple M1 at the moment. An alternative is to use rosetta and the Intel version of haystack and its dependencies.

Please let me know if that works for you so that we can close the issue. I would recommend to start with a fresh virtual environment.

@nisrj10
Copy link
Author

nisrj10 commented Aug 17, 2021

Hi @nisrj10 let me list the steps that I followed to get haystack running on Mac M1 aka Apple Silicon in more detail:

  1. Install brew and miniforge simple steps are described in this tutorial

  2. Create a virtual environment. I decided to go with python3.9: conda create --name py39 python=3.9 and activate it afterward: conda activate py39

  3. Clone FARM repository and install FARM and its dependencies. (FARM itself is a dependency of haystack.)

    • git clone https://github.com/deepset-ai/FARM.git

    • cd FARM

    • conda install pytorch scikit-learn

    • conda install -c conda-forge sentencepiece

    • `pip install -r requirements.txt``

    • pip install -e .

  4. Optionally, you can try to run python examples/doc_classification.py now or any other example. If it shows some nice ASCII art, you're all good.

  5. Clone haystack repository and install some haystack dependencies:

    • cd ..

    • git clone https://github.com/deepset-ai/haystack.git

    • cd haystack

    • conda install -c conda-forge psycopg2-binary

    • conda install -c conda-forge uvloop

  6. Edit requirements.txt to remove (comment out) dependencies that I could not get installed (so far) or that are already installed:

  7. Now that everything is prepared you should be able to run the following two commands without getting any errors:

    • pip install -r requirements.txt

    • pip install -e .

  8. Test the setup, e.g., by running python tutorials/Tutorial1_Basic_QA_Pipeline.py

Note that we did not install all dependencies, such as faiss-cpu. As a consequence, there are some limits to the features that we can use in haystack on Apple M1 at the moment. An alternative is to use rosetta and the Intel version of haystack and its dependencies.

Please let me know if that works for you so that we can close the issue. I would recommend to start with a fresh virtual environment.

Thanks @julian-risch I will try this out. Appreciate the help.

@nisrj10
Copy link
Author

nisrj10 commented Aug 18, 2021

@julian-risch Farm installation worked fine. Haystack installation didn't work as grpcio installation caused issues.

@julian-risch
Copy link
Member

julian-risch commented Aug 18, 2021

I don't think I had to install grpcio. Maybe I am wrong and I am mixing it up with grpcio-tools. Can you tell which of the dependencies tried to install grpcio? Did you uncomment faiss-cpu and ray from the requirements.txt?

@julian-risch
Copy link
Member

Anyway, conda install -c conda-forge grpcio works for me. If it works for you too, I will add it to the list above. @nisrj10

What does not work is to install grpcio-tools but it should not be needed if you uncomment faiss-cpu and ray from the requirements.txt.

@julian-risch
Copy link
Member

Hi @nisrj10 did you manage to get it running on your machine by following the instructions listed above?

@julian-risch
Copy link
Member

Hi @nisrj10 if you're still having problems maybe this issue is also interesting to you: #1443

@bogdankostic
Copy link
Contributor

Thanks @julian-risch for the step by step instructions. I needed to install grpcio with the following command: conda install -c conda-forge grpcio==1.37.1. Otherwise, everything worked without a problem.

@julian-risch
Copy link
Member

Great news! I will close this issue then. @nisrj10 Feel free to reopen if you are still facing problems with setting up haystack on Apple Mac M1.

@dmigo
Copy link
Member

dmigo commented Dec 17, 2021

I had simillar problems with haystack on M1 with python version 3.9.9

  1. ray==1.5.0 wasn't available
    1. fix: Unpinned version of ray(PR) and installed from the branch
  2. grpcio package failed to install
    1. fix: Used GRPC_PYTHON_BUILD_SYSTEM_ZLIB=true variable to make grpcio happy. (source)
  3. sentencepiece failed to install
    1. fix: installed cmake (source)
  4. psycopg2-binary failed to install
    1. fix: installed postgresql

So in the end my command was:

brew install postgresql
brew install cmake
GRPC_PYTHON_BUILD_SYSTEM_ZLIB=true pip install git+https://github.com/deepset-ai/haystack.git

@mathislucka
Copy link
Member

I also had to install rust because tokenizers needed a rust compiler. So my full installation routine was:

brew install postgresql
brew install cmake
GRPC_PYTHON_BUILD_SYSTEM_ZLIB=true pip install git+https://github.com/deepset-ai/haystack.git
brew install rust

@ChristoRad
Copy link

ChristoRad commented Apr 13, 2023

For the Poetry users, this worked for me:

brew install postgresql
brew install cmake
brew install rust
arch -arm64 brew install llvm@11
LLVM_CONFIG="/opt/homebrew/Cellar/llvm@11/11.1.0_4/bin/llvm-config" arch -arm64 poetry add llvmlite
GRPC_PYTHON_BUILD_SYSTEM_ZLIB=true poetry add git+https://github.com/deepset-ai/haystack.git

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic:installation type:bug Something isn't working
Projects
None yet
Development

No branches or pull requests

8 participants