Skip to content

Problem when compiling on ARM #615

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

Closed
jbjuin opened this issue Sep 13, 2022 · 4 comments · Fixed by #616
Closed

Problem when compiling on ARM #615

jbjuin opened this issue Sep 13, 2022 · 4 comments · Fixed by #616

Comments

@jbjuin
Copy link

jbjuin commented Sep 13, 2022

Summary:

Compilation on ARM do not work properly: the version option is not enough to download the correct cmdstan release file.

Description:

In our deployment process we install facebook "prophet" (1.1) which depends on cmdstanpy 1.0.7.
The deployment is done on an ARM architecture.

The process stops with the error:

--- Translating Stan model to C++ code ---
        bin/stanc  --o=examples/bernoulli/bernoulli.hpp examples/bernoulli/bernoulli.stan
        bash: line 1: bin/stanc: cannot execute binary file: Exec format error

which indicate an architecture problem.

After some investigation it seems that the url to download the cmdstan release is not correct for ARM, here:

url = (
        'https://github.com/stan-dev/cmdstan/releases/download/'
        'v{0}/cmdstan-{0}.tar.gz'.format(version)
    )

This url construct do not take into account the architecture of the target which is:

https://github.com/stan-dev/cmdstan/releases/download/v2.26.1/cmdstan-2.26.1-linux-arm64.tar.gz

The Ruby wrapper for cmdstan (https://github.com/ankane/cmdstan-ruby) fixed this problem in that commit: ankane/cmdstan-ruby@7a6a384

Would it be possible to use the same fix with cmdstanpy ?
Thanks !

Additional Information:

Everything works fine when installing on amd64 architecture.

Current Version:

  • cmdstanpy version: 1.0.7
  • cmdstan version: 2.26.1
@WardBrian
Copy link
Member

Good catch! We should support all the following linux architectures:

cmdstan-2.30.1-linux-arm64.tar.gz
cmdstan-2.30.1-linux-armel.tar.gz
cmdstan-2.30.1-linux-armhf.tar.gz
cmdstan-2.30.1-linux-mips64el.tar.gz
cmdstan-2.30.1-linux-ppc64el.tar.gz
cmdstan-2.30.1-linux-s390x.tar.gz

It seems like platform.machine() should contain the information we need, but I'm not sure how to test this on the various platforms.

@ahartikainen
Copy link
Contributor

Maybe first add possibility to select it manually and then add automatic logic?

@jbjuin
Copy link
Author

jbjuin commented Sep 14, 2022

Wow that's a quick answer ! Thanks a lot.

For now I got around this issue by installing prophet from source (https://github.com/facebook/prophet/tree/v1.1.1#installation-in-python---development-version) instructing it not to install cmdstan:

export PROPHET_REPACKAGE_CMDSTAN=False; python setup.py develop

and pointing to a manually installed cmdstan (basically a download, extract and symbolic link operation) using the CMDSTAN environment variable.

@WardBrian on my intel dev laptop this gets me: x86_64, which would be the default one (no specific arch string) ?

@ahartikainen I think too that a manual control is quite enough to start with, it may bring more code changes though to allow the argument passing down the calls.

Any idea about the schedule for this to land in a release ?
Again thanks a lot for looking at this so quickly !

@WardBrian
Copy link
Member

I'm currently thinking we should:

  1. Do our best-effort to determine the architecture automatically. Using the docker instances we use to create these versions I've recorded what platform.machine() outputs for each
  2. Use an environment variable (CMDSTAN_ARCH?) to allow the user to override this. I think this has a few advantages over a straight-up argument, mainly for things like prophet. For a new argument --arch, anyone downstream would need to update to support it. Also, this is a more "advanced" feature that I imagine won't be needed often.

The other thing I considered is updating the version argument such that it would be able to properly handle version strings like "2.30.1-linux-arm64". I don't love this option, since they're not really "versions"

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

Successfully merging a pull request may close this issue.

3 participants