Skip to content

Glmnet Compatibility with M1 MacBooks (Solved) #59

@skbwu

Description

@skbwu

Hi everybody,

I had some trouble getting glmnet_python to work with my M1 MacBook Pro (Late 2020). Some error messages I received included "OSError: dlopen(/opt/homebrew/Caskroom/miniforge/base/envs/tensorflow/lib/python3.9/site-packages/glmnet_py/GLMnet.so, 0x0006): tried: '/opt/homebrew/Caskroom/miniforge/base/envs/tensorflow/lib/python3.9/site-packages/glmnet_py/GLMnet.so' (not a mach-o file), '/usr/local/lib/GLMnet.so' (no such file), '/usr/lib/GLMnet.so' (no such file)"

I just wanted to share my solution that finally got it to work:

  1. Create a virtual conda environment, but force it to only install and use legacy x86-64 packages. The specific instructions for this step can be found here.
  2. Install glmnet_py using pip in this specific environment as usual.
  3. Replace the GLMnet.so file from the pip installation with the GLMnet.so file from here.
  4. Replace "scipy.floor(nobs/nfolds)" in line 260/261 of cvglmnet.py with "int(scipy.floor(nobs/nfolds))". The source of this fix can be found here.

Hope this helps!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions