kach / memo

A domain-specific probabilistic programming language for reasoning about reasoning
https://pypi.org/project/memo-lang/
MIT License
37 stars 2 forks source link

jax import error #55

Closed tobiasgerstenberg closed 3 months ago

tobiasgerstenberg commented 3 months ago

hi,

i got this error on an M1 mac with a fresh install of python 3.12.4 via conda and then running pip install jax jaxlib

Python 3.12.4 | packaged by Anaconda, Inc. | (main, Jun 18 2024, 10:14:12) [Clang 14.0.6 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.

>>> import jax
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/tobiasg/opt/miniconda3/envs/py312/lib/python3.12/site-packages/jax/__init__.py", line 25, in <module>
    from jax._src.cloud_tpu_init import cloud_tpu_init as _cloud_tpu_init
  File "/Users/tobiasg/opt/miniconda3/envs/py312/lib/python3.12/site-packages/jax/_src/cloud_tpu_init.py", line 17, in <module>
    from jax._src import config
  File "/Users/tobiasg/opt/miniconda3/envs/py312/lib/python3.12/site-packages/jax/_src/config.py", line 27, in <module>
    from jax._src import lib
  File "/Users/tobiasg/opt/miniconda3/envs/py312/lib/python3.12/site-packages/jax/_src/lib/__init__.py", line 84, in <module>
    cpu_feature_guard.check_cpu_features()
RuntimeError: This version of jaxlib was built using AVX instructions, which your CPU and/or operating system do not support. This error is frequently encountered on macOS when running an x86 Python installation on ARM hardware. In this case, try installing an ARM build of Python. Otherwise, you may be able work around this issue by building jaxlib from source.

any clue how to fix this?

kach commented 3 months ago

Hi Tobi - I suspect what is going on is that you are using an ARM Mac, but somehow have an x86 Python installed.

To test this hypothesis, first try running file $(which python). Does it say something like Mach-O 64-bit executable arm64, or does it say something about x86?

If the latter (x86), then I suspect you need to reinstall Python, making sure to install the ARM version, for example using CONDA_SUBDIR=osx-arm64.

If the former (arm), then more investigation needed…

tobiasgerstenberg commented 3 months ago

great -- thanks for your help!

running this command and then following the readme worked for me.

CONDA_SUBDIR=osx-arm64 conda create -n py312 python=3.12