giotto-ai/giotto-tda

Installing on Apple Silicon

anmolguppta opened this issue · 7 comments

Hi @aranos-tda ! The issue here I believe is that the PyPI package only supports macOS 10.15 or above. So PyPI is falling back to a tarball installation that is doomed to fail, see #308.

For now, I would recommend installing the library from sources, i.e. to perform a developer installation as described in https://giotto-ai.github.io/gtda-docs/0.5.1/installation.html#developer-installation.

I am facing the similar issue in MacOS Monterey 12.1 (M1 Macbook Air) . While trying to install using the developer options it says the following for giotto-ph:

Obtaining file:///Users/anmolgupta/PycharmProjects/pythonProject/giotto-tda/giotto-tda/giotto-tda/giotto-tda
Preparing metadata (setup.py) ... done
Requirement already satisfied: numpy>=1.19.1 in /Users/anmolgupta/PycharmProjects/pythonProject/venv/lib/python3.10/site-packages (from giotto-tda==0.5.1) (1.22.1)
Requirement already satisfied: scipy>=1.5.0 in /Users/anmolgupta/PycharmProjects/pythonProject/venv/lib/python3.10/site-packages (from giotto-tda==0.5.1) (1.7.3)
Requirement already satisfied: joblib>=0.16.0 in /Users/anmolgupta/PycharmProjects/pythonProject/venv/lib/python3.10/site-packages (from giotto-tda==0.5.1) (1.1.0)
Requirement already satisfied: scikit-learn>=0.23.1 in /Users/anmolgupta/PycharmProjects/pythonProject/venv/lib/python3.10/site-packages (from giotto-tda==0.5.1) (1.0.2)
ERROR: Could not find a version that satisfies the requirement giotto-ph>=0.2.1 (from giotto-tda[dev]) (from versions: none)
ERROR: No matching distribution found for giotto-ph>=0.2.1

What should I do? for giotto-ph?

I'm an undergraduate college student and just started trying to pursue research in TDA as interest. I'm very new to python and thus maybe missing something. Any help would be really appreciated.

I have installed though the gcc boost and it is upto date but I'm not able to figure out what is the issue

Originally posted by @anmolguppta in #612 (comment)

Upon entering gcc --version, I get the following details: (If it in case it helps in any way)
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/usr/include/c++/4.2.1
Apple clang version 13.0.0 (clang-1300.0.27.3)
Target: arm64-apple-darwin21.2.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

ulupo commented

Hi! I've changed the title as your issue is due to the fact that we don't yet have PyPI wheels for Apple Silicon in giotto-tda or even giotto-ph. Your developer installation of giotto-tda fails because it is trying to install giotto-ph from PyPI but this cannot yet be done for the M1 processors. The solution is to first install both giotto-ph and pyflagser in developer mode and then to install giotto-tda in developer mode.

I received my own M1 yesterday and installed pyflagser, giotto-ph and giotto-tda using the developer installation instructions, without even having to install GCC (the projects compiled successfully with the native Clang instead). You'll still need CMake for all the projects, and Boost for giotto-tda. Not sure whether using Clang will be recommended for Apple Silicon users moving forward. Here I'd ask for the expert opinion of @MonkeyBreaker.

Not sure whether using Clang will be recommended for Apple Silicon users moving forward. Here I'd ask for the expert opinion of @MonkeyBreaker.

When the new CI will be merged, the MacOS job will be build on Clang.
About if Clang will be the recommended compiler for Apple Silicon, no clue.

I think that we should speed-up on having ASAP wheels for Apple new Silicon and Python 3.10 !

Sorry for the inconvenience @anmolguppta ...

**Heyy, thankyou so much for replying back! I tried installing through the method you mentioned by installing first giotto-ph, pyflagser and then installing giotto-tda.

However on doing pytest, from the main directory and doing the pytest of a for a particular directory from inside it, the pytest results are different. I just wanted to confirm once if I've been able to install the setup completely or not.

The results on running the pytest from home (main directory) is as follows :**

(venv) (base) anmolgupta@Anmols-MacBook-Air pyflagser % cd
(venv) (base) anmolgupta@Anmols-MacBook-Air ~ % pytest giotto-tda
=========================== test session starts ===========================
platform darwin -- Python 3.10.2, pytest-6.2.5, py-1.11.0, pluggy-1.0.0
benchmark: 3.4.1 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000)
rootdir: /Users/anmolgupta/giotto-tda, configfile: setup.cfg
plugins: azurepipelines-0.8.0, benchmark-3.4.1, timeout-2.1.0, hypothesis-6.36.0, cov-3.0.0
collected 0 items / 1 error
##vso[results.publish type=JUnit;runTitle='Pytest results';]/Users/anmolgupta/test-output.xml
##vso[task.logissue type=error;]1 test(s) failed, 0 test(s) collected.
##vso[task.logissue type=warning;]Coverage XML was not created, skipping upload.
=========================================ERRORS=============================================
___________________________________ ERROR collecting test session ________________________________________
/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/importlib/init.py:126: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
:1050: in _gcd_import
???
:1027: in _find_and_load
???
:1006: in _find_and_load_unlocked
???
:688: in _load_unlocked
???
PycharmProjects/pythonProject/venv/lib/python3.10/site-packages/_pytest/assertion/rewrite.py:170: in exec_module
exec(co, module.dict)
giotto-tda/gtda/externals/pybind11/tests/conftest.py:19: in
import pybind11_tests # noqa: F401
E ModuleNotFoundError: No module named 'pybind11_tests'
----- generated xml file: /Users/anmolgupta/test-output.xml ------------------------------------------------------------
===================================== short test summary info ==========================
ERROR giotto-tda - ModuleNotFoundError: No module named 'pybind11_tests'
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
====================================== 1 error in 0.68s =======================================

**- Note: It repeatedly says that pybind11_tests is missing. I'm not sure if this module will affect me while using the package.

Now if I run the test from within the directory. the short test summary is as follows :**

(venv) (base) anmolgupta@Anmols-MacBook-Air ~ % cd giotto-tda
(venv) (base) anmolgupta@Anmols-MacBook-Air giotto-tda % pytest
======================================= short test summary info ===========================
SKIPPED [1] gtda/tests/test_common.py:79: Skipped
XFAIL gtda/tests/test_common.py::test_sklearn_api[Binarizer()-check_transformer_general]
known failure
XFAIL gtda/tests/test_common.py::test_sklearn_api[Binarizer()-check_transformer_general(readonly_memmap=True)]
known failure
XFAIL gtda/tests/test_common.py::test_sklearn_api[Inverter()-check_transformer_data_not_an_array]
known failure
XFAIL gtda/tests/test_common.py::test_sklearn_api[Inverter()-check_transformer_general]
known failure
XFAIL gtda/tests/test_common.py::test_sklearn_api[Inverter()-check_transformer_general(readonly_memmap=True)]
known failure
XPASS gtda/tests/test_common.py::test_sklearn_api[Binarizer()-check_transformer_data_not_an_array] known failure
FAILED gtda/mapper/tests/test_cluster.py::test_firstsimplegap - hypothesis.errors.Flaky: Hypothesis test_firstsimplegap(inp=(2, 2, 1, array([[0.],
============ 1 failed, 1300 passed, 1 skipped, 5 xfailed, 1 xpassed, 392 warnings in 86.94s (0:01:26) ==============

ulupo commented

pytest should be run from within the root directory of the repo as you did in the second example. I think this is what we state in documentation (and we say to run pytest gtda).

In your case, all tests pass apart from a single flaky test (sometimes this happens with the more CPU-intensive tests), so your installation worked! Closing the issue but feel free to ask more questions.

Hi!
I think it would be very useful to mention this in the README.md or anywhere people go to find installation instructions.
I actually spent the whole day trying to find out why the installation process for giotto-tda was failing. But the error messages never pointed in the direction the Apple chip being the problem.
Going once again to the Issues page, I only now noticed that there was a pinned issue (did not know that was a thing actually).

The instructions here worked for me, thank you.
Any idea of when the pip install will be available?

ulupo commented

Fixed by the release of giotto-tda 0.6.0!