Julia on iOS and Android

Check out my guide here. I found ti searching for Android in this forum

2 Likes

Thank even I found the same guide but I want to connect it a jupyter app and run from browser

Up to now julia can be built for iSH but unfortunately freezes on executing code. One reason could be unimplemented syscalls related to memory management and tracing (e.g. gdb doesnā€™t work as iSH doesnā€™t support ptrace syscalls). Anyway, performance wouldnt bee too nice due to emulation.

As a heads up to users of Termux, it looks like Android has had some changes to their security model in Android 10 which may affect (and possible eliminate) Julia functionality:

https://github.com/termux/termux-packages/wiki/Termux-and-Android-10

2 Likes

Iā€™ve linked a pretty huge github issue below, but the tl;dr is this: Native code which is not packaged in an .apk may not be executed by the user or non-system applications.

The solution they are currently employing is to repackage everything as .apks, which will be downloaded and installed by the pkg utility in termux. Many applications will still work, including interpreted languages like Python or Ruby. The same cannot be said for compiled languages.

One proposal is to compile code as an apk and installed by the user, but for a language like Julia with as much metaprogramming as it contains may not be compatible with that model.

https://github.com/termux/termux-app/issues/1072#issuecomment-474385386

1 Like

It may be possible that Julia can still run under proot, albeit with performance penalties.

Have you checked this? I ran Julia some time ago on my Pixel 3, and Iā€™m pretty sure I was running Android 10 at the time?

I havenā€™t checked it, but at present (and in the near future) it should continue working. Google is enforcing this based on the targetSdk, so even if your device is API 29+ but the app uses API 28 it continues to function, and should do so for at least a few years.

There are two sides to this issue, both of which are relevant to ways in which Google is removing the method on which Termux relies in Android API 29.

  1. Enforcement: Google Play stops accepting app updates which do not target API 29. Currently apps must target API 28 to be accepted on Google Play, and API 28 is what Termux targets. While this will become a problem, it can easily be bypassed by simply installing the Termux apk from elsewhere. This is expected to happen toward the end of 2020.

  2. Technical: This will be the case if a future Android release enforces this security rule for all apps, no matter which API level they target, breaking backwards compatibility (including for Termux). This would affect all apps on a device, including those installed via sources outside of Google Play.

    Googleā€™s handling of security rules for target API 28 in conjunction with Google Play update policy indicates that such a technical change is indeed coming, but likely not for a few years.

2 Likes

That means Android 9. This is easy to misunderstand. I fell into the trap of thinking that non-old Android versions are no longer supported, reading Googleā€™s docs, but actually targetSdk must be set at some level for the app, while minSdkVersion can be much lower.

E.g. Firefox supports very old (discontinued by Google) ā€œAndroid Jelly Bean or laterā€ by setting minSdkVersion appropriately, I believe.

As Google canā€™t change already release Android versions (only Google Play policy on apps allowed; or allowed for updates), are you saying, old versions can use Termux forever (and even get updates), but on recent Android versions you get a new API, which, for you is worse?

1 Like

Since Julia doesnā€™t seem to work yet in iSH, I tried compiling Scimark with GCC 9.2, and performance does seem to be bad, with a composite score of 17 on an iPhone SE (the new one). This is about two orders of magnitude lower than one might expect for real numerical work, though GCC seemed to compile everything reasonably fast so maybe itā€™s ok for some workloads.

2 Likes

Can Julia work in iPad or Android devices now ? Are there any future plan since iPad are becoming more and more powerful with m-chips ?

Running Julia on Android is not hard. I have not heard about success on iOS.

If I needed to use the Julia programming language on iOS, I would probably try this first:

Of course, I donā€™t know if it would work.

1 Like

termux is probably your best bet to get Julia running on Android at this point

1 Like

The fundamental issue remains: Julia depends on JIT, and apple is a bunch of dystopian control-freaks who only pretend to transfer ownership of iphones and ipads to ā€œbuyersā€.

Unless political change is enacted on that, it will probably remain impossible to run things like julia without joining the apple developer program, which is paid in money, PII and dignity (e.g. follow above links to end up at jitterbug, which is a pretty cool hack!).

That makes the target audience for an iphone-julia pretty small.

(for those who are less in the know: On ios, the kernel checks signatures when marking a page executable. You donā€™t control the kernel on ā€œyourā€ device, apple does. Farewell, von Neumann architecture. Apple has chosen a side in the war on general computation, and it sure ainā€™t ours)

4 Likes

There is also iSH app that simulates a lightweight linux kernel. I have not tried it on M series iPads but few years ago couldnā€™t get Julia to work on some iPad mini. Donā€™t know if it works now.

1 Like

I tried running the current Julia x86-32 binary under iSH recently on an iPad Pro (2018 10.5", not an M-series chip), and ran into the same old issue of it failing to load. Bigger picture: I would really love to be able to run something like Pluto natively on the device, but I donā€™t see how it would be possible. Iā€™ve been playing around with JuliaHubā€™s Pluto service recently but havenā€™t tried using it from iPadOS/Safari yet. The included 20 hours/month free usage is pretty generous, so if it works well that would probably be a pretty reasonable 80% solution.

Shouldnā€™t it be possible to set up Pluto on a remote server with specific port to be accessible through safari etc. ?

1 Like

EDIT: Actually in this case, for iSH, I see you want a i386 build, but I do see two potential problems:

It used JIT so i386 should work on Arm (just not Apples Rosetta implementation of emulation), but while Julia supports 32-bit, itā€™s not i386, i.e. not quite that old. Julia targets about 10 year old 32-bit chips, but maybe can be compiled for older 32-bit.

Another thing is I see Alpine mentioned, and if you need that type of Linux userland, then it needs musl, and the Julia musl build is only for 64-bit.

What I wrote before that didnā€™t take iSH into account:
Iā€™m not sure the iPad ever had Rosetta [2], i.e. emulation, since it doesnā€™t have any history of non-Arm chips used there.

So you should use an Arm build of Julia on the iPad, and it might work?

I believe this is possible on a LAN but havenā€™t tried it yet. If Iā€™m at home Iā€™ve got a desktop and laptop available, so no big desire to try running it from the iPad Pro. I take it with me on-the-go for note-taking where Iā€™d need to have a personal VPN setup to remote into.

1 Like