Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Trying to install MxNet and GluonCV on Mac M1 #20992

Open
LewsTherin511 opened this issue Apr 7, 2022 · 7 comments
Open

Trying to install MxNet and GluonCV on Mac M1 #20992

LewsTherin511 opened this issue Apr 7, 2022 · 7 comments

Comments

@LewsTherin511
Copy link

LewsTherin511 commented Apr 7, 2022

I've been trying to install MxNet and GluonCV on a M1 Mac, and I'm using Miniconda, which supposedly supports arm-based packages installations.
I tried a couple of approaches so far, without any success

Installation with pip
I created the env by:

conda create --name mc_mxnet_py39 python=3.9

and installed mxnet by:

pip install --upgrade mxnet

I also tried specifying

CONDA_SUBDIR=osx-arm64 pip install --upgrade mxnet

But the result is always the same, when importing mxnet I get the error:

OSError: dlopen(/Users/cdemasi/miniconda3/envs/mc_mxnet_py39/lib/python3.9/site-packages/mxnet/libmxnet.so, 0x0006): tried: '/Users/cdemasi/miniconda3/envs/mc_mxnet_py39/lib/python3.9/site-packages/mxnet/libmxnet.so' (not a mach-o file)

During the installation, I see that it's doing:

Collecting mxnet
Using cached mxnet-1.6.0-py2.py3-none-any.whl (68.7 MB)

So, I assume there's an error in the mxnet-1.6.0-py2.py3-none-any.whl file, which is actually not a Mac-compatible version?

Then, I tried building it from source

  • MxNet 2.0.0
    I followed the instructions on this page, which seemed to work, I built and installed MxNet 2.0.0.
    My problem now is to install GluonCV as well. I tried installing it with pip, and everything seemed to work as well. But then when , when running a simple object detection script, I got the error:

RuntimeError: Legacy mxnet==2.0.0 detected, some modules may not work properly. mxnet>=1.4.0,<2.0.0 is required. You can use pip to upgrade mxnet "pip install -U 'mxnet>=1.4.0,<2.0.0'" or "pip install -U 'mxnet-cu100>=1.4.0,<2.0.0'"

(I also tried building Gluoncv from source as well, but I'm getting the same error, the issue seems to be the MxNet version)

  • MxNet 1.7.0: building fails, when running "cmake --build ." I got this error:

1 error generated. make[2]: *** [3rdparty/mkldnn/src/cpu/CMakeFiles/dnnl_cpu.dir/jit_utils/jitprofiling/jitprofiling.c.o] Error 1 make[1]: *** [3rdparty/mkldnn/src/cpu/CMakeFiles/dnnl_cpu.dir/all] Error 2 make: *** [all] Error 2

so, I modified the config.cmake file (copied from config/darwin.cmake to the root folder), by setting:

set(USE_MKL_IF_AVAILABLE OFF CACHE BOOL "Use Intel MKL if found") set(USE_MKLDNN OFF CACHE BOOL "Build with MKL-DNN support")

but now it seems it got even worse (always after running "cmake --build ."):

fatal error: too many errors emitted, stopping now [-ferror-limit=] 20 errors generated. make[2]: *** [CMakeFiles/mxnet_static.dir/src/api/_api_internal/_api_internal.cc.o] Error 1 make[1]: *** [CMakeFiles/mxnet_static.dir/all] Error 2 make: *** [all] Error 2

  • I'll try building version 1.6.0, and see if it works

Originally posted by @LewsTherin511 in #20650 (comment)

@github-actions
Copy link

github-actions bot commented Apr 7, 2022

Welcome to Apache MXNet (incubating)! We are on a mission to democratize AI, and we are glad that you are contributing to it by opening this issue.
Please make sure to include all the relevant context, and one of the @apache/mxnet-committers will be here shortly.
If you are interested in contributing to our project, let us know! Also, be sure to check out our guide on contributing to MXNet and our development guides wiki.

@joelteply
Copy link

joelteply commented Jun 14, 2022

I was able to get mxnet version 1.6 compiling for m1 macs by basically copying some of their stuff from the 2.0 code: top of cmakelists script that loads the config.cmake file, moved the darwin config.cmake to root, and replaced the scripts the blas and accelerate framework package finders. I could fork it if it's wanted. I had to disable USE_SSE for it to function (config.cmake) and I don't have enough time to research what was wrong there.

Remove .txt extension to this config.cmake.txt here, place it in the root, and then replace the chooseblas and findaccerlerate with the ones from the 2.0 branch.

CMakeLists.txt
config.cmake.txt
.

@iGxnon
Copy link

iGxnon commented Aug 15, 2022

I used some of the same approaches as you and none of them worked, and finally I found a shortcut: use docker images
After clicking this https://hub.docker.com/r/mxnet/python/tags, you can find an image with a tag of 1.9.1_aarch64_cpu_py3, pull it down with docker pull mxnet/python:1.9.1_aarch64_cpu_py3 and use it

Screen Shot 2022-08-15 at 17 03 42

I can use the Docker Interpreter in Pycharm to have a good coding experience.
Screen Shot 2022-08-15 at 17 05 26

But there is still a problem that after using the docker image, it is not very convenient to install a new python package. You need to manually build a new image based on this image with the python packages you need

@Yimin-Yi
Copy link

I was able to get mxnet version 1.6 compiling for m1 macs by basically copying some of their stuff from the 2.0 code: top of cmakelists script that loads the config.cmake file, moved the darwin config.cmake to root, and replaced the scripts the blas and accelerate framework package finders. I could fork it if it's wanted. I had to disable USE_SSE for it to function (config.cmake) and I don't have enough time to research what was wrong there.

Remove .txt extension to this config.cmake.txt here, place it in the root, and then replace the chooseblas and findaccerlerate with the ones from the 2.0 branch.

CMakeLists.txt config.cmake.txt .

Can you please fork it? I also want to install mxnet 1.6. Thanks

@yaosting
Copy link

Did you successfully install by adjusting these two files
I installed according https://mxnet.apache.org/versions/1.9.1/get_started/osx_setup.html#install-mxnet-for-python, and replaced two files after the build, but the following error occurred
image

What should I do?

@fazaza
Copy link

fazaza commented Oct 21, 2022

any news please ?

@udtda
Copy link

udtda commented Nov 17, 2023

I was able to get mxnet version 1.6 compiling for m1 macs by basically copying some of their stuff from the 2.0 code: top of cmakelists script that loads the config.cmake file, moved the darwin config.cmake to root, and replaced the scripts the blas and accelerate framework package finders. I could fork it if it's wanted. I had to disable USE_SSE for it to function (config.cmake) and I don't have enough time to research what was wrong there.

Remove .txt extension to this config.cmake.txt here, place it in the root, and then replace the chooseblas and findaccerlerate with the ones from the 2.0 branch.

CMakeLists.txt config.cmake.txt .

@joelteply
Can you give more details on this? Or maybe share your compiled version? I still have that same issue and I am required to use mxnet 1.6.0.

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

No branches or pull requests

7 participants