Closed ospaarmann closed 2 years ago
So I got it to run. I'm not sure if this is ideal but I'm sharing my solution to maybe help anyone running into the same issue. I installed tensorflow 2.6.0
in a virtual environment using conda / mambaforge. I opted for 2.6.0
because 2.5.2
is not available for M1 and 2.5.0
wasn't working. You can read about installing Mamaforge here. After that, I installed Tensorflow with
conda install tensorflow==2.6.0
I also set the pandas version to pandas>1.2.3
in the requirements.txt
of my own project (same as in ethnicolr). This resolved to pandas 1.3.3
.
Next, I had to solve the dependency issue with ethnicolr, since ethnicolr requires tensorflow 2.5.2
. I did that by forking the ethnicolr repo and creating a branch where I pin the tensorflow version to 2.6.0
in the requirements.txt
and setup.py
. You find this branch over here. To use this github branch, I changed the line in my requirements.txt
to:
git+https://github.com/ospaarmann/ethnicolr.git@apple_m1_support_tensorflow_2_6_0#egg=ethnicolr
Now I had an issue with a dependency mismatch with numpy. It is described in this StackOverflow thread. What happened was that importing pandas or ethnicolr would throw this error:
>>> from ethnicolr import census_ln, pred_census_ln, pred_wiki_name
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/olespaarmann/mambaforge/envs/diversity_scraper/lib/python3.8/site-packages/ethnicolr/__init__.py", line 2, in <module>
from ethnicolr.census_ln import census_ln
File "/Users/olespaarmann/mambaforge/envs/diversity_scraper/lib/python3.8/site-packages/ethnicolr/census_ln.py", line 6, in <module>
import pandas as pd
File "/Users/olespaarmann/mambaforge/envs/diversity_scraper/lib/python3.8/site-packages/pandas/__init__.py", line 22, in <module>
from pandas.compat import (
File "/Users/olespaarmann/mambaforge/envs/diversity_scraper/lib/python3.8/site-packages/pandas/compat/__init__.py", line 15, in <module>
from pandas.compat.numpy import (
File "/Users/olespaarmann/mambaforge/envs/diversity_scraper/lib/python3.8/site-packages/pandas/compat/numpy/__init__.py", line 7, in <module>
from pandas.util.version import Version
File "/Users/olespaarmann/mambaforge/envs/diversity_scraper/lib/python3.8/site-packages/pandas/util/__init__.py", line 1, in <module>
from pandas.util._decorators import ( # noqa
File "/Users/olespaarmann/mambaforge/envs/diversity_scraper/lib/python3.8/site-packages/pandas/util/_decorators.py", line 14, in <module>
from pandas._libs.properties import cache_readonly # noqa
File "/Users/olespaarmann/mambaforge/envs/diversity_scraper/lib/python3.8/site-packages/pandas/_libs/__init__.py", line 13, in <module>
from pandas._libs.interval import Interval
File "pandas/_libs/interval.pyx", line 1, in init pandas._libs.interval
ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 88 from C header, got 80 from PyObject
The solution here is to just ignore the dependency issues and manually install a newer version of numpy. It doesn't work when I set the numpy version in my requirements.txt
because this throws a dependency error:
ERROR: Cannot install numpy>=1.20.0 and tensorflow==2.6.0 because these package versions have conflicting dependencies.
The conflict is caused by:
The user requested numpy>=1.20.0
tensorflow 2.6.0 depends on numpy~=1.19.2
So I just installed it with python -m pip install numpy==1.20.0
. And now everything seems to work.
Hey, I recently moved a project to a new MacBook with a M1 chip and I now have issues getting everything to run. I'm using Mambaforge because it is recommended for Apple Silicon (previously I used Miniconda).
When I try to install ethnicolr 0.8.1 I get the error
ERROR: Could not find a version that satisfies the requirement tensorflow==2.5.2 (from ethnicolr) (from versions: none)
. The available versions of tensorflow that I can install in my setup are2.4.0, 2.4.1, 2.4.3, 2.6.0
and2.6.2
. I read in this issue that tensorflow 2.6 is not an option so I tried to install Tensorflow2.5
.I tried to clone an existing conda environment with Tensorflow
2.5.0
following this description. Using this environment I was able to install the followingrequirements.txt
, but only withpip install --no-deps
.First it looked like everything was working but when running
pred_wiki_name
I get the following error:How do I run ethnicolr on an M1 chip? Has anyone successfully done so? Thanks