Illegal instruction

Hello Streamlit community,

Iā€™ve been using streamlit for almost 1 year. However - we recently went through a period of working on other applications in our project which were part of the same virtual environment.
This meant for me needing to upgrade my python version to 3.7.9. I use deadsnake for this on Ubunutu 18.04

Now here comes the nasty part. I now see an error message coming from Streamlit which simply outputs: ā€œIllegal instructionā€. Has anyone seen this before. It even happens on the simple ā€˜helloā€™ application. e.g.

(streamlit_3.8) nherriot@kieran:~/virtualenv/streamlit_3.8/project/streamlit$ python --version
Python 3.8.6
(streamlit_3.8) nherriot@kieran:~/virtualenv/streamlit_3.8/project/streamlit$ python
Python 3.8.6 (default, Oct  6 2020, 03:22:36) 
[GCC 7.5.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
(streamlit_3.8) nherriot@kieran:~/virtualenv/streamlit_3.8/project/streamlit$ 
(streamlit_3.8) nherriot@kieran:~/virtualenv/streamlit_3.8/project/streamlit$ 
(streamlit_3.8) nherriot@kieran:~/virtualenv/streamlit_3.8/project/streamlit$ 
(streamlit_3.8) nherriot@kieran:~/virtualenv/streamlit_3.8/project/streamlit$ streamlit hello
Illegal instruction

Iā€™m guessing that itā€™s calling up some binary which is trying to execute something for the wrong architecture (machine architecture). The machine is an AMD Phenomā„¢ II X6 1090T Processor Ɨ 5

Any help on how to get more debug on this would be great! :slight_smile:

Kind regards, Nicholas.

HI again,

more information on this error:
If I move streamlit back to version 0.52.0 it goes away.
So this has been introduced with the new releases. Also what is interesting is that it does not happen on my Intel laptop running Linux mint.

(streamlit) nherriot@kieran:~/virtualenv/streamlit/project/streamlit$ streamlit --version
Streamlit, version 0.52.0
(streamlit) nherriot@kieran:~/virtualenv/streamlit/project/streamlit$ streamlit hello

  You can now view your Streamlit app in your browser.

  Local URL: http://localhost:8501
  Network URL: http://192.168.8.201:8501


I have now raised an issue for this in github with details on how to reproduce:

Hi @nherriot -

Can you confirm that youā€™re using a 64-bit version of Python?

Having the breakpoint at <0.63 is an interesting place, as 0.63 is where we released the custom components framework. With that, we added Apache Arrow as a dependency. So Iā€™m wondering if there is an issue with that somehow.

1 Like

Think itā€™s 64, I get this from my virtualenvironment:


>>> import struct
>>> print(struct.calcsize("P") * 8)
64

Hi @nherriot, weā€™re having a pretty detailed discussion internally about what this might be and what to do, so thanks for your patience!

Hi @nherriot!

First of all, thank you very much for bringing this up both on GitHub and here, and sorry we didnā€™t get back sooner! I hope that we figure out a solution here. We have been unable to repro on our systems (both macOS and Ubuntu), so this will be a little tricky to identify the solution.

ā€œIllegal Instructionā€ errors occur when you try to run a program that was compiled with some processor-specific optimizations, and is then running on a processor that fails to meet those requirements. This leads me to think that something we introduced either wasnā€™t compiled correctly for your processor or something strange happened on your system when combined with our changes caused issues.

Here are a few ideas to try:

  1. (From a colleague) The AMD Phenom processor is not a unique processor, just an AMD64-compatible CPU, so it should be using the same Python binaries as all AMD and Intel CPUs from the past 15 or so years.That said, it may be worth a try having them build their own Python by using pyenv , since it looks like theyā€™re installing theirs from a PPA (which I donā€™t trust 100%ā€¦). Also the PPA is for Ubuntu and their system is Elementary ā€”which is based on Ubuntu, but may have some different libraries, which could be causing issues.
# Install pyenv
$ curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash# Install Python 3.7
$ ~/.pyenv/bin/pyenv install 3.7.0# Then point to the newly installed Python when creating the virtual env
$ mkvirtualenv streamlit --python=~/.pyenv/versions/3.7.0/bin/python

From then on, all pip packages are actually compiled on the usersā€™ machine so they should all work fine.

  1. As @randyzwitch pointed out, the marked change between 0.62 and 0.63 is the introduction of a new package called pyarrow. Itā€™s possible (but perhaps a little shocking) that it caused the problem. We donā€™t import arrow when you run streamlit --version, so that shouldnā€™t crash. But in any case, you can try to install pyarrow from Conda and see if that fixes it. Itā€™s a long shot, but worth a try.

  2. With regard to (2) I see this: https://issues.apache.org/jira/browse/ARROW-4272 for pyarrow, and it might be related to a tensorflow installation. It might be worthwhile to test TensorFlow similarly. Hereā€™s an article that shares more on how tensorflow can be a problem and call the Illegal Instruction https://tech.amikelive.com/node-887/how-to-resolve-error-illegal-instruction-core-dumped-when-running-import-tensorflow-in-a-python-program/

All these ideas are educated guesses that I hope either yield fruitful results or at least more information to solve the problem. Let us know what you end up figuring out.

Note: Iā€™m going to post this comment on the GitHub issue, and will continue responding on there. Given itā€™s public and perhaps more ā€œGoogleableā€ I think it will be useful for more users who hit similar issues there.

2 Likes

Stealing the suggestion from the arrow/tensorflow issue, could you try using our conda build (conda install -c conda-forge streamlit)? It seems the conda build worked for them.

OK - Iā€™ll try some of this out sometime next week since we are pushed on a deadline.
For the minute we have frozen everything on 0.62.

Conda scares me. Iā€™d like to remain on good old fashion ā€˜virtualenvā€™! I know what it does, where it puts things and how it works! :-/

Thank you all for your responses and help! Great community! :slight_smile: