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

Error: "pip install nnabla" on M1(M2)mac #1191

Open
tsukamoto1783 opened this issue Apr 28, 2023 · 4 comments
Open

Error: "pip install nnabla" on M1(M2)mac #1191

tsukamoto1783 opened this issue Apr 28, 2023 · 4 comments
Assignees

Comments

@tsukamoto1783
Copy link

tsukamoto1783 commented Apr 28, 2023

Thanks for creating and managing such a nice package.

I am using M2 mac.
The following commands, which are first instructed in official documents, etc., will result in an execution error.

pip install nnabla

ERROR: Could not find a version that satisfies the requirement nnabla (from versions: none)
ERROR: No matching distribution found for nnabla

The documentation says that "mac" is also supported, but I wonder if "intel" and "apple silicon" are both supported.

Also, I would be very happy if you could provide some possible solutions for the "apple silicon" if it is supported.

The execution environment is described below.
If you need more information, please let us know.

We sincerely look forward to your response.


【PC environment】

Chip:Apple M2
macOS:13.3.1

【tried】
I tried using "pyenv" and multiple python versions, but all gave the same execution error.

pip --version
pip 23.1.2 from /Users/username/.pyenv/versions/3.9.1/lib/python3.9/site-packages/pip (python 3.9)

pip --version
pip 23.1.2 from /Users/username/.pyenv/versions/3.9.10/lib/python3.9/site-packages/pip (python 3.9)

pip --version
pip 23.1.2 from /Users/username/.pyenv/versions/3.10.3/lib/python3.10/site-packages/pip (python 3.10)

【addition】
I tried "pip install nnabla" under "intel mac". on my own intel Mac, it installed without any problem.

pip --version
pip 23.1.2 from /username/Versions/3.9/liv/python3.9/site-packages/pip (python 3.9)

@justinTM
Copy link

justinTM commented May 8, 2023

having the same problem. to give an explanation, it looks like there are linux ARM-specific (aarch64) builds, but no macOS ARM-specific builds: https://pypi.org/project/nnabla/#files

@justinTM
Copy link

justinTM commented May 8, 2023

here's how I built nnabla from source for M2 Mac:

  1. install pre-requisites
# ensure homebrew is installed
echo ""
echo "making sure homebrew is installed..."
which brew || /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# ensure clang is installed
echo ""
echo "making sure clang is installed..."
which clang || brew install llvm

# install cmake CLI (add binary and include paths for cmake to ~/.bash_profile)
echo ""
echo "installing cmake..."
DIRPATH_LOCAL_BIN="${HOME}/.local/bin"
DIRPATH_LOCAL_INCLUDE="${HOME}/.local/include"
echo "" >> ~/.bash_profile
echo "# cmake binary and include paths" >> ~/.bash_profile
echo "export C_INCLUDE_PATH=\"${DIRPATH_LOCAL_INCLUDE}\"" >> ~/.bash_profile
echo "export CPLUS_INCLUDE_PATH=\"${DIRPATH_LOCAL_INCLUDE}\"" >> ~/.bash_profile
echo "" >> ~/.bash_profile
echo "export PATH=\"${PATH}:${DIRPATH_LOCAL_BIN}\"" >> ~/.bash_profile
source ~/.bash_profile
brew install cmake

# download and copy protoc
echo ""
echo "installing protoc..."
URL_PROTOC="https://github.com/protocolbuffers/protobuf/releases/download/v23.0-rc3/protoc-23.0-rc-3-osx-aarch_64.zip"
cd "${HOME}/Downloads"
mkdir -p ./protoc/
curl -L "$URL_PROTOC" -o "$(basename $URL_PROTOC)" && unzip "$(basename $URL_PROTOC)" -d ./protoc/
cp protoc/bin/protoc "${DIRPATH_LOCAL_BIN}"
cp -R protoc/include/google "${DIRPATH_LOCAL_INCLUDE}"
rm -rf protoc/ "$(basename $URL_PROTOC)"
which protoc || echo "ERROR: failed to install protoc!"
  1. build nnabla and replace any installation with self-built python wheel
    see here: https://github.com/sony/nnabla/blob/master/doc/build/build.md#build-and-installation

@justinTM
Copy link

justinTM commented May 8, 2023

@YukioOobuchi I'm not sure how nnabla assets are getting uploaded to pypi, but I'd love to contribute python wheels for 3.8, 3.9, and 3.10 on macOS 13 (Ventura):

nnabla-mac13-arm64-python-whls.zip

@justinTM
Copy link

justinTM commented May 8, 2023

might have to swap builder.py from latest protobuf: https://stackoverflow.com/a/72494013

to fix this error upon import nnabla in python:

mes-MacBook-Pro:nnabla me$ python
Python 3.10.11 (main, May  7 2023, 19:48:21) [Clang 14.0.3 (clang-1403.0.22.14.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import nnabla
2023-05-07 20:10:54,252 [nnabla][INFO]: Initializing CPU extension...
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/me/.pyenv/versions/3.10.11/lib/python3.10/site-packages/nnabla/__init__.py", line 34, in <module>
    from .parameter import (
  File "/Users/me/.pyenv/versions/3.10.11/lib/python3.10/site-packages/nnabla/parameter.py", line 29, in <module>
    import nnabla.utils.nnabla_pb2 as nnabla_pb2
  File "/Users/me/.pyenv/versions/3.10.11/lib/python3.10/site-packages/nnabla/utils/nnabla_pb2.py", line 8, in <module>
    from google.protobuf.internal import builder as _builder
ImportError: cannot import name 'builder' from 'google.protobuf.internal' (/Users/me/.pyenv/versions/3.10.11/lib/python3.10/site-packages/google/protobuf/internal/__init__.py)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants