Message Boards Message Boards

2
|
4376 Views
|
4 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Installing ARM Mathematica Version with GUI on Android Devices using Termux-x11

This is a guide for installing Mathematica ARM Version (Raspberry Pi) on Android devices with a full GUI. The guide assumes that one has Termux-x11 and proot-distro working in order to have a GUI. You are required to have a Mathematica key for Linux to activate.

Termux and Termux-x11 are a terminal and x11-forwarding implementation for Android devices. There is no root requirement, thus the security of your device will not be compromised. Please refer to these guides in order to install and get them working.

Proot-distro is a quick way to get a linux distro to work on Android devices. It is not a virtual machine because all installed distros are the ARM64 version to work with most phones/tablets' processors. Rather, proot-distro is a container environment manager, handling/hijacking system IO and storage to emulate chroot and mount for non-rooted devices, thus if your device is rooted, you do not need to install proot-distro. Because it is not a virtual machine, you have almost full processing speed except for the IO hijacking, giving a minor hit to the performance. However, as long as the calculation in Mathematica does not involve a lot of IOs, performance is very decent. Please follow the guide and install the debian (for rooted device, install debian using whatever you want).

Here, we need debian because the ARM version of Mathematica is built for Raspbian originally, which is debian-based, thus using debian via proot-distro helps to handle some system dependents that native Termux does not have. It is my goal in the future to have Mathematica working natively on Termux to get native performance. Inputs/helps are needed and welcome!

How to Install Wolfram Kernel (back end):

  • Start proot-distro debian by

    proot-distro login debian
    
  • Allow a multi-architecture (64+32-bit) and install 32-bit libraries because Mathematica uses some of these (the latter is optional, but it might help in case you see some error related to 32-bit instruction)

    dpkg --add-architecture armhf
    apt install libatomic1:armhf libgl1:armhf
    
  • Download the Raspberry Pi installation script from Wolfram and put it in the root folder of debian. You should have access to your usual Android "Download" folder through

    cd //sdcard/Download/
    
  • Execute the official installation script (Current version is 13.3.1, but this might change when they release new version)

    bash ./install-wolfram-engine-13.3.1.sh
    
  • At this point, everything should be set. You can activate Mathematica by starting its Kernel and follow the instruction (I activate sucessfully using a Linux Mathematica Key provided by my institution)

    wolfram
    
  • After activation, you should have been forwarded to the Wolfram CLI Kernel, where we have full access to the Kernel (back end). To quit, execute

    Quit[]
    

How to run Mathematica GUI (front end):

  • Start the Termux-x11 app on your Android device and a termux terminal. Then, start an x11 instance by executing in Termux terminal

    termux-x11 :1 &
    

    If Termux and Termux-x11 have been installed correctly, you should see the x11 app window black and the mouse cursor is an x.

  • Start debian with x-11 forwarding

    proot-distro login debian --shared-tmp
    
  • Set display to the previously started (1 in this case)

    export DISPLAY=:1
    
  • Optional step: Install xfce4 desktop environment to have full multi-window desktop experience (otherwise you cannot control fullscreen window in x11 window)

    apt install xfce4
    

    To start the desktop environment (you should see the x11 app with full desktop interface now)

    xfce4-session &
    
  • Start Mathematica from command line

    mathematica &
    

    and you should see the Raspberry Pi Mathematica window pop-up!

Tested device: Samsung Tab S9 with Snapdragon 8 gen 2 runnning Android 14 + One UI 6.

POSTED BY: Quan Le Thien
4 Replies
Posted 9 months ago

Awesome! But where can I download the Mathematica GUI (front end) for ARM?

POSTED BY: Yumin Tian

The install script for Pi's wolfram engine also install the mathematica front end, you just need termux-x11 + a desktop environment as set up here to access it

POSTED BY: Quan Le Thien

No noticeable difference from users' POV. All commands and interfaces are exactly the same!

ARM refers to the CPU architecture that most mobile devices and apple are using. The so-called regular version is built only for x86 CPUs (AMD and Intel PC CPUs), thus it cannot run natively on mobile devices CPUs. You can install Virtual Machine on android to emulate, but the speed will be really slow.

This method uses the less well-known built of Mathematica intended originally for the Raspberry Pi which uses ARM architecture CPU. Hence, you can enjoy the usual native speed as on a normal PC.

Having said that, one potential issue is that most ARM mobile CPUs uses hybrid big + little cores, thus if you use multi-threaded commands such as ParallelTable, you will sometimes see that some how running things in parallel can be significantly slower than the usual single-threaded Table. This is because Mathematica does not know how to divide the work appropriately between big and little cores. The little cores will receive the same amount of work as the big core, but because they are much weaker, they take longer to acomplish the task, thus when the big cores finish their work, the little cores are still evaluating. I also encounter this issue with the latest Intel CPUs. One way to circumvent this problem is to use thread affinity that tie Mathematica Kernel to only the big cores or just stick with the single-threaded commands.

POSTED BY: Quan Le Thien
Posted 9 months ago

Will you provide links to the guide of installing and configuring termux and termux-x11?

POSTED BY: Updating Name
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract