cjerzak / causalimages-software

causalimages: An R package for performing causal inference with image and image sequence data
https://arxiv.org/pdf/2310.00233
MIT License
16 stars 3 forks source link

Complications with Building Backend with Apple Silicon Powered Devices #14

Open WarrenZhu050413 opened 3 months ago

WarrenZhu050413 commented 3 months ago

I am not entirely certain, but it seems like Macbook doesn't work with the current default install (at least when I do it manually) since it installs x86-64 versions of the packages when Mac needs ARM64. I am not sure whether it is a general problem, but seems good to flag.

Error Message Error: /Users/wz/opt/anaconda3/envs/CausalImagesEnv/lib/libpython3.11.dylib - dlopen(/Users/wz/opt/anaconda3/envs/CausalImagesEnv/lib/libpython3.11.dylib, 0x000A): tried: '/Users/wz/opt/anaconda3/envs/CausalImagesEnv/lib/libpython3.11.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/Users/wz/opt/anaconda3/envs/CausalImagesEnv/lib/libpython3.11.dylib' (no such file), '/Users/wz/opt/anaconda3/envs/CausalImagesEnv/lib/libpython3.11.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64'))

Solution

curl -L https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-MacOSX-arm64.sh -o Miniforge3-MacOSX-arm64.sh

sh Miniforge3-MacOSX-arm64.sh

Conda init zsh

CONDA_SUBDIR=osx-arm64 conda create -n my_arm64_env python=3.11

conda create -n my_arm64_env python=3.11

conda activate my_arm64_env

conda config --env --set subdir osx-arm64

# Check whether python is running on the right platform
python -c "import platform; print(platform.machine())"
cjerzak commented 3 months ago

Very true; in general most of these packages will require different versions for arm64 vs. x86_64 (as well as for METAL vs. Nvidia vs. AMD GPU). Often, this is handled automatically, but not always.