zsh: illegal hardware instruction python (mac m1 silicon)
JiaqiHu2021 opened this issue · 6 comments
I run the following code in the terminal, I get the error "zsh: illegal hardware instruction python"
Python 3.9.7 (default, Sep 16 2021, 08:50:36)
[Clang 10.0.0 ] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from abess.linear import abessLogistic
>>> from sklearn.datasets import load_breast_cancer
>>> from sklearn.pipeline import Pipeline
>>> from sklearn.metrics import make_scorer, roc_auc_score
>>> from sklearn.preprocessing import PolynomialFeatures
>>> from sklearn.model_selection import GridSearchCV
>>> pipe = Pipeline([('poly', PolynomialFeatures(include_bias=False)), ('alogistic', abessLogistic())])
>>> param_grid = {'poly__interaction_only': [True, False],'poly__degree': [1, 2, 3]}
>>> scorer = make_scorer(roc_auc_score, greater_is_better=True)
>>> grid_search = GridSearchCV(pipe, param_grid, scoring=scorer, cv=5)
>>> X, y = load_breast_cancer(return_X_y=True)
>>> grid_search.fit(X, y)
Can you give me more details about your system info?
You can get them by running:
import platform
print("Platform Version: {0}, {1}".format(platform.platform(), platform.architecture()[0]))
print("Python Version:", platform.python_version())
import abess
print("Package Version:", abess.__version__)
Platform Version: macOS-10.16-x86_64-i386-64bit, 64bit
Python Version: 3.9.7
Package Version: 0.3.6
Thanks.
It is a tough issue. We have to pay some time to fix it. If you are urgent to use abess
on Mac with M1 chip, you can refer to: tensorflow/tensorflow#45404, tensorflow/tensorflow#46044, or https://www.tensorflow.org/install/source#bazel_build_options, https://stackoverflow.com/questions/65770132/python3-install-of-tensorflow-on-apple-silicon-m1. Another option is using it in Windows or Linux.
The following is a step-by-step procedure for solving this issue.
-
Download
miniforge
from github: https://github.com/conda-forge/miniforge
-
Install it in terminal by commands:
mv Miniforge3-MacOSX-arm64.sh ~/
Chmod +x Miniforge3-MacOSX-arm64.sh
./Miniforge3-MacOSX-arm64.sh
- Activate and start a new environment named
abess
in terminal via:
conda create --name abess python=3.8
conda activate abess
- Follow the instruction to install the latest version of
abess
Python package.
After executing these steps, I believe the illegal hardware instruction python
would be resolved.
If you meet any questions, feel free to contact us.
Hi @JiaqiHu2021 ,we have updated a new version in Pypi. We believe the newest version can successfully executed the following code:
>>> from abess.linear import abessLogistic
>>> from sklearn.datasets import load_breast_cancer
>>> from sklearn.pipeline import Pipeline
>>> from sklearn.metrics import make_scorer, roc_auc_score
>>> from sklearn.preprocessing import PolynomialFeatures
>>> from sklearn.model_selection import GridSearchCV
>>> pipe = Pipeline([('poly', PolynomialFeatures(include_bias=False)), ('alogistic', abessLogistic())])
>>> param_grid = {'poly__interaction_only': [True, False],'poly__degree': [1, 2, 3]}
>>> scorer = make_scorer(roc_auc_score, greater_is_better=True)
>>> grid_search = GridSearchCV(pipe, param_grid, scoring=scorer, cv=5)
>>> X, y = load_breast_cancer(return_X_y=True)
>>> grid_search.fit(X, y)
You can run
pip uninstall abess
pip install --no-cache-dir abess==0.4.2
to reinstall the latest abess
library.
If you still meet any problem, feel free to contact us.
After upgrading to the latest version, I successfully ran the above code.
Thank you very much for your help!