[ARM] Problem on M1 Mac through a Docker Ubunt image

712 views
Skip to first unread message

Gonçalo Almeida

unread,
Feb 15, 2021, 12:24:49 PM2/15/21
to sage-devel
I've tried everything and since there ins't a proper version for M1 Macs natively (at least public yet), I got a Docker image for an Ubuntu terminal and tried to install Sage there, but it failed to build.

OS: macOS BigSur 11.2 (ARM)

These are the steps I took:

$ docker run -td --name=sage-arm ubuntu
$ docker exec -it sage-arm bash

$ apt-get upgrade && apt-get update
$ apt-get install -y git
$ apt-get install build-essential m4 gfortran
$ apt install python3 python3-setuptools python3-pip
$ git clone https://github.com/sagemath/sage.git
$ cd /sage
$ ./configure --enable-build-as-root

$ apt-get install texlive-latex-extra texlive-xetex latexmk dvipng default-jdk ffmpeg libavdevice-dev libflint-arb-dev libboost-dev libboost-dev libbrial-dev libbrial-groebner-dev libbz2-dev bzip2 coinor-cbc coinor-libcbc-dev libcdd-dev libcdd-tools cliquer libcliquer-dev cmake curl libcurl4-openssl-dev libec-dev eclib-tools gmp-ecm libecm-dev fflas-ffpack libflint-dev flintqs libfreetype6-dev libgc-dev libgf2x-dev gfan libgiac-dev xcas libgivaro-dev glpk-utils libglpk-dev libgmp-dev pari-gp2c libgsl-dev libigraph-dev libiml-dev libisl-dev lcalc liblfunction-dev libatomic-ops-dev libbraiding-dev libffi-dev libgd-dev libhomfly-dev libnauty-dev libxml2-dev liblrcalc-dev libm4rie-dev libmpc-dev libmpfi-dev libmpfr-dev nauty libncurses5-dev ninja-build libntl-dev libopenblas-dev openssl libssl-dev palp pandoc pari-gp2c libpari-dev pari-doc pari-elldata pari-galdata pari-galpol pari-seadata libpcre3-dev libxml-libxslt-perl libxml-writer-perl libxml2-dev libperl-dev libfile-slurp-perl libjson-perl libsvg-perl libterm-readkey-perl libterm-readline-gnu-perl libmongodb-perl libterm-readline-gnu-perl pkg-config libplanarity-dev planarity libppl-dev ppl-dev python3 libpython3-dev python3-distutils r-base-dev r-cran-lattice libreadline-dev librw-dev libsqlite3-dev sqlite3 libsuitesparse-dev libsymmetrica2-dev sympow tachyon tox xz-utils liblzma-dev libzmq3-dev libzn-poly-dev

$ ./config.status --recheck && ./config.status
$ make
$ ./sage


Getting:
---------------------------------------------------------------------------------------------------------------------------
************************************************************************
It seems that you are attempting to run Sage from an unpacked source
tarball, but you have not compiled it yet (or maybe the build has not
finished). You should run `make` in the Sage root directory first.
If you did not intend to build Sage from source, you should download
a binary tarball instead. Read README.txt for more information.
************************************************************************
---------------------------------------------------------------------------------------------------------------------------



The end of the install.log says the following:
---------------------------------------------------------------------------------------------------------------------------
make[4]: *** [Makefile:2098: python3-no-deps] Error 1
make[3]: *** [Makefile:2098: /sage/local/var/lib/sage/installed/python3-3.9.1] Error 2
make[2]: *** [Makefile:1792: all-start] Error 2
make[2]: Leaving directory '/sage/build/make'

real  1m28.196s
user 1m19.299s
sys   0m8.615s
***************************************************************
Error building Sage.

The following package(s) may have failed to build (not necessarily
during this run of 'make all-start'):

* package:         python3-3.9.1
  last build time: Feb 15 15:56
  log file:        /sage/logs/pkgs/python3-3.9.1.log
  build directory: /sage/local/var/tmp/sage/build/python3-3.9.1

It is safe to delete any log files and build directories, but they
contain information that is helpful for debugging build problems.
WARNING: If you now run 'make' again, the build directory of the
same version of the package will, by default, be deleted. Set the
environment variable SAGE_KEEP_BUILT_SPKGS=yes to prevent this.
---------------------------------------------------------------------------------------------------------------------------

And checking that log file for python3-3.9.1 I got redirected here.
Config.log and python3-3.9.1.log are attached to this message.

Looking to figure if I did anything wrong, and if you have some beta solution for the M1 Macs based on ARM.


Sincerely,
Gonçalo Almeida
python3-3.9.1.log
config.log

Matthias Koeppe

unread,
Feb 15, 2021, 12:43:40 PM2/15/21
to sage-devel
It looks like your apt-get install did not go through. For example, liblzma-dev is not installed, causing python3 to be installed from source. Were there any errors?

Samuel Lelievre

unread,
Feb 15, 2021, 12:50:36 PM2/15/21
to sage-devel
Maybe use a SageMath Docker image which
comes with Ubuntu and an already-built Sage?

William Stein

unread,
Feb 15, 2021, 2:34:27 PM2/15/21
to sage-devel
On Mon, Feb 15, 2021 at 9:24 AM Gonçalo Almeida <goncalo...@gmail.com> wrote:
I've tried everything and since there ins't a proper version for M1 Macs natively (at least public yet), I got a Docker image for an Ubuntu terminal and tried to install Sage there, but it failed to build.

I tried exactly this approach about a month ago with my M1 Mac and it does work and is by far the easiest/most efficient way to get Sage running on M1.   One critical surprise was that I had to be careful to increase the amount of RAM that the Docker hypervisor has **significantly above the default** (at least 4GB of RAM, maybe more).  Make sure to do that.  Otherwise, various aspects of the build will fail in confusing ways due to running out of memory.   

For what it's worth, here's a paste of some notes I kept for myself:

Goal -- SageMath on M1

I think the best hope for efficient Sage on M1 Mac is via Docker but without QEMU.  I.e., use ARM64 Linux via Docker, which runs via a hypervisor, so will be very fast/performant.

https://news.ycombinator.com/item?id=25447153

docker run -td --name=sage-arm  -v ~/sage-arm:/sage-arm ubuntu

According to

root@79ac2b56798b:/# uname -a
Linux 79ac2b56798b 4.19.104-linuxkit #1 SMP PREEMPT Sat Feb 15 00:49:47 UTC 2020 aarch64 aarch64 aarch64 GNU/Linux

this is ARM linux, so should be fast.

apt update
apt install tmux dpkg-dev git python m4
git clone https://github.com/sagemath/sage.git
cd sage
make configure
./configure --enable-build-as-root

apt-get install  texlive-latex-extra texlive-xetex latexmk pandoc dvipng default-jdk ffmpeg libavdevice-dev libflint-arb-dev libboost-dev libboost-dev libbrial-dev libbrial-groebner-dev libbz2-dev bzip2 coinor-cbc coinor-libcbc-dev libcdd-dev libcdd-tools cliquer libcliquer-dev cmake curl libcurl4-openssl-dev libec-dev eclib-tools gmp-ecm libecm-dev fflas-ffpack libflint-dev flintqs libfreetype6-dev libgc-dev libgf2x-dev gfan gfortran libgiac-dev xcas libgivaro-dev glpk-utils libglpk-dev libgmp-dev pari-gp2c libgsl-dev libigraph-dev libiml-dev libisl-dev lcalc liblfunction-dev libatomic-ops-dev libbraiding-dev libffi-dev libgd-dev libhomfly-dev libnauty-dev libxml2-dev liblrcalc-dev libm4rie-dev libmpc-dev libmpfi-dev libmpfr-dev nauty libncurses5-dev ninja-build libntl-dev libopenblas-dev openssl libssl-dev palp pandoc pari-gp2c libpari-dev pari-doc pari-elldata pari-galdata pari-galpol pari-seadata libpcre3-dev libxml-libxslt-perl libxml-writer-perl libxml2-dev libperl-dev libfile-slurp-perl libjson-perl libsvg-perl libterm-readkey-perl libterm-readline-gnu-perl libmongodb-perl libterm-readline-gnu-perl pkg-config libplanarity-dev planarity libppl-dev ppl-dev python3 libpython3-dev python3-distutils r-base-dev r-cran-lattice libreadline-dev librw-dev libsqlite3-dev sqlite3 libsuitesparse-dev libsymmetrica2-dev sympow tachyon tox xz-utils liblzma-dev libzmq3-dev libz-dev libzn-poly-dev

./config.status --recheck && ./config.status
export MAKE="make -j8"
make

First try -- I think it failed building sagelib due to not enough RAM, so trying again with 8 cpu and 4GB RAM.  It can be very resource intensive.  This worked for me.


 -- William

Isuru Fernando

unread,
Feb 16, 2021, 11:55:45 AM2/16/21
to sage-devel
Hi,

You can use conda packages on aarch64 to provide all the dependencies for a sage development build. (Or sage itself if you are not developing on that machine)

Isuru

--
You received this message because you are subscribed to the Google Groups "sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/CACLE5GBaL6%3DTr1MWfja%3Dz8aVGRpp89jtMVB7D3ea-o2or4kqZw%40mail.gmail.com.

Gonçalo Almeida

unread,
Feb 19, 2021, 5:26:32 AM2/19/21
to sage-...@googlegroups.com
Thanks for the replies.

About William's tips, I did read it previously so I allocated 4GB to Docker and allowed also more cpus to help run the tasks but in the end I didn't like it (even it worked) because I ended up with a 15GB image when I wanted something much smaller (so that in the future the final users can use it taking much less space)

So I decided to abandon the Ubuntu bash with Sage and went after the sagemath/sagemath-jupyter Docker image (taking only 4GB of space). My supervisor had me clarified about what he really wanted to test, and perhaps this is the best solution for the product we are developing.

Once again, thanks everyone!


GA

You received this message because you are subscribed to a topic in the Google Groups "sage-devel" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sage-devel/TeqSx0xMXhs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sage-devel+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/CA%2B01voMrMMgx-WYg3YC7wbXuXgVFnv5bd1G53q_y28NJKAO48A%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages