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

conda package for newer m1/m2 mac #354

Open
taDachs opened this issue Nov 17, 2024 · 2 comments
Open

conda package for newer m1/m2 mac #354

taDachs opened this issue Nov 17, 2024 · 2 comments

Comments

@taDachs
Copy link

taDachs commented Nov 17, 2024

Hello there,
we are using biorbd (+ bioviz + bioptim) in a course and one student is using an M1 or M2 macbook. Conda doesn't seem to contain packages for that architecture, only for x86. is this assumption correct?

I am currently trying to work around it by building the libraries in a docker container from source, but it complicates the setup immensely.

Are there plans for releasing a ARM version? I would be willing to help with that

@pariterre
Copy link
Member

Hello!
I am happily surprise to learn that biorbd is used in a lecture!

We tried really hard to push for newer Mac, but I could not find a way... conda-force did not seem to have the resources at the time to compile to full chain (including casadi, rbdl, eigen, etc), so biorbd could finally be compiled... I could a look again soon, maybe now it is possible. I unfortunately cannot garanty that it is going to work as I failed twice already

In any cases, if you need/want, we can setup a zoom call so I can help you compiling everything needed

@taDachs
Copy link
Author

taDachs commented Nov 18, 2024

I have a working Dockerfile for compiling it on arm (using multiplatform builds with docker buildx and qemu):

FROM ubuntu:jammy
ARG USERNAME=hcr
ARG USER_UID=1000
ARG USER_GID=$USER_UID

ENV DEBIAN_FRONTEND=NONINTERACTIVE

# fix build of libc for arm (https://stackoverflow.com/questions/78105004/docker-build-fails-because-unable-to-install-libc-bin)
RUN rm /var/lib/dpkg/info/libc-bin.* && \
   apt-get clean && \
   apt-get update && \
   apt-get install libc-bin && \
   rm -rf /var/lib/apt/lists/*

# Create the user
RUN groupadd --gid $USER_GID $USERNAME \
   && useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
   #
   # [Optional] Add sudo support. Omit if you don't need to install software after connecting.
   && apt-get update \
   && apt-get install -y sudo \
   && echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
   && chmod 0440 /etc/sudoers.d/$USERNAME \
   && rm -rf /var/lib/apt/lists/*

RUN apt-get update \
   && apt-get upgrade -y \
   && DEBIAN_FRONTEND=noninteractive apt-get install -y python3-pip ripgrep git git-lfs tldr curl libgl1-mesa-dev python3-venv cmake wget libstdc++-11-dev python3-tk \
   && rm -rf /var/lib/apt/lists/*


USER $USERNAME
WORKDIR /home/$USERNAME

# install micromamba
RUN wget -qO- https://micromamba.snakepit.net/api/micromamba/linux-aarch64/latest | tar -xvj bin/micromamba \
   && ./bin/micromamba shell init -s bash

RUN echo 'eval "$($HOME/bin/micromamba shell hook -s posix)"' >> /home/$USERNAME/.bashrc


# install conda deps
RUN ./bin/micromamba install -n base -y -c conda-forge python-graphviz vtk rbdl tinyxml ipopt scipy swig pyomeca ezc3d matplotlib pandas numpy casadi

# build biorbb
RUN git clone https://github.com/pyomeca/biorbd.git && \
   export CONDA_PREFIX=/home/$USERNAME/.local/share/mamba && \
   cd biorbd && \
   mkdir -p build && \
   cd build && \
   cmake -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX  -DMATH_LIBRARY_BACKEND="Casadi" -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=OFF -DMODULE_ACTUATORS=ON -DMODULE_KALMAN=ON -DMODULE_MUSCLES=ON -DBUILD_EXAMPLE=OFF -DBINDER_PYTHON3=ON .. && \
   make install -j8


# set shell to bash
ENV SHELL=/bin/bash
SHELL ["/bin/bash", "-c"]
CMD ["/bin/bash"]


# install bioviz
RUN git clone https://github.com/pyomeca/bioviz.git && \
   cd bioviz && \
   ~/bin/micromamba run python3 setup.py install

# install bioptim
RUN git clone https://github.com/pyomeca/bioptim.git && \
   cd bioptim && \
   ~/bin/micromamba run python3 setup.py install

RUN echo 'micromamba activate' >> /home/$USERNAME/.bashrc

So far biorbd is the only package that really has to be compiled for arm, bioviz and bioptim are pure python packages so they shouldn't really be a problem.

I can try opening a PR for running a build in the CI for arm based macs.

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

2 participants