sparse icon indicating copy to clipboard operation
sparse copied to clipboard

"Segmentation fault (core dumped)" after installing the required sparse library in a Qiskit env (conda virtual env)

Open seafolk-cn opened this issue 2 years ago • 14 comments

Hi,

We encountered a serious issue when running jupyter notebook code with the support of sparse library. Can someone help?

Thanks!

Describe the bug In a Qiskit 0.30 conda virtual env, after installing the required sparse library using pip, the ipython run will error out with "Segmentation fault (core dumped)" message. issue_with_sparse.log

To Reproduce

  1. Activate conda virtual env and run the "01_neural_networks.ipynb" sample code with below commands:

conda activate qiskit0.30_test ipython -c "%run 01_neural_networks.ipynb" This will prompt you to install the sparse library.

  1. Install sparse library by executing "pip install 'qiskit-machine-learning[sparse]'" inside the conda virtual env
  2. Rerun the "01_neural_networks.ipynb" sample code will produce the "Segmenttation fault" error.

Expected behavior expect no prompt for install sparse library and no errors popped up for the ipython run

System

  • OS and version: RHEL 8.4 (s390x)
  • Conda: 4.10.1
  • Sparse: version: 0.13.0
  • NumPy version: 1.20.3
  • Numba version: 0.54.1

Additional context Add any other context about the problem here.

seafolk-cn avatar Oct 19 '21 06:10 seafolk-cn

I cannot tell from your issue where the notebook is, could you give a link to it or upload it? Also could you show where you got the conda environment to run the notebook?

hameerabbasi avatar Oct 19 '21 07:10 hameerabbasi

Also can you run with the environment variable NUMBA_DISABLE_JIT=1 and post the stack trace?

hameerabbasi avatar Oct 19 '21 10:10 hameerabbasi

I cannot tell from your issue where the notebook is, could you give a link to it or upload it? Also could you show where you got the conda environment to run the notebook?

We got the sample notebook from below official repo, it's inside the docs/tutorials/ folder. https://github.com/Qiskit/qiskit-machine-learning 01_neural_networks.ipynb.zip

Download link for anaconda for IBM z https://www.anaconda.com/products/individual#Downloads https://repo.anaconda.com/archive/Anaconda3-2021.05-Linux-s390x.sh

I installed anaconda for z on RHEL 8.4 (s390x) and created virtual env using below commands:

conda create -n qiskit0.30 python=3.8 conda activate qiskit0.30 pip install qiskit==0.30 pip install qiskit-machine-learning ........ then i can run the notebook inside this virtual env.

seafolk-cn avatar Oct 20 '21 03:10 seafolk-cn

Unfortunately I don't have access to an s390x machine, but I can try to reproduce it on x86_64 over the weekend.

hameerabbasi avatar Oct 20 '21 03:10 hameerabbasi

(qiskit0.30_test) [root@rhel84 qiskit-machine-learning]# jupyter nbconvert --to script 01_neural_networks.ipynb [NbConvertApp] Converting notebook 01_neural_networks.ipynb to script [NbConvertApp] Writing 9419 bytes to 01_neural_networks.py (qiskit0.30_test) [root@rhel84 qiskit-machine-learning]# (qiskit0.30_test) [root@rhel84 qiskit-machine-learning]# (qiskit0.30_test) [root@rhel84 qiskit-machine-learning]# (qiskit0.30_test) [root@rhel84 qiskit-machine-learning]# python 01_neural_networks.py Segmentation fault (core dumped) (qiskit0.30_test) [root@rhel84 qiskit-machine-learning]# export NUMBA_DISABLE_JIT=1 (qiskit0.30_test) [root@rhel84 qiskit-machine-learning]# python 01_neural_networks.py Segmentation fault (core dumped) (qiskit0.30_test) [root@rhel84 qiskit-machine-learning]# python -q -X faulthandler 01_neural_networks.py Fatal Python error: Segmentation fault

Current thread 0x000003ffb7278240 (most recent call first): File "/opt/anaconda/envs/qiskit0.30_test/lib/python3.8/ctypes/init.py", line 373 in init File "/opt/anaconda/envs/qiskit0.30_test/lib/python3.8/site-packages/llvmlite/binding/ffi.py", line 185 in File "", line 219 in _call_with_frames_removed File "", line 843 in exec_module File "", line 671 in _load_unlocked File "", line 975 in _find_and_load_unlocked File "", line 991 in _find_and_load File "", line 219 in _call_with_frames_removed File "", line 1042 in _handle_fromlist File "/opt/anaconda/envs/qiskit0.30_test/lib/python3.8/site-packages/llvmlite/binding/dylib.py", line 3 in File "", line 219 in _call_with_frames_removed File "", line 843 in exec_module File "", line 671 in _load_unlocked File "", line 975 in _find_and_load_unlocked File "", line 991 in _find_and_load File "/opt/anaconda/envs/qiskit0.30_test/lib/python3.8/site-packages/llvmlite/binding/init.py", line 4 in File "", line 219 in _call_with_frames_removed File "", line 843 in exec_module File "", line 671 in _load_unlocked File "", line 975 in _find_and_load_unlocked File "", line 991 in _find_and_load File "/opt/anaconda/envs/qiskit0.30_test/lib/python3.8/site-packages/numba/core/config.py", line 16 in File "", line 219 in _call_with_frames_removed File "", line 843 in exec_module File "", line 671 in _load_unlocked File "", line 975 in _find_and_load_unlocked File "", line 991 in _find_and_load File "", line 219 in _call_with_frames_removed File "", line 1042 in _handle_fromlist File "/opt/anaconda/envs/qiskit0.30_test/lib/python3.8/site-packages/numba/init.py", line 19 in File "", line 219 in _call_with_frames_removed File "", line 843 in exec_module File "", line 671 in _load_unlocked File "", line 975 in _find_and_load_unlocked File "", line 991 in _find_and_load File "/opt/anaconda/envs/qiskit0.30_test/lib/python3.8/site-packages/sparse/_coo/core.py", line 9 in File "", line 219 in _call_with_frames_removed File "", line 843 in exec_module File "", line 671 in _load_unlocked File "", line 975 in _find_and_load_unlocked File "", line 991 in _find_and_load File "/opt/anaconda/envs/qiskit0.30_test/lib/python3.8/site-packages/sparse/_coo/init.py", line 1 in File "", line 219 in _call_with_frames_removed File "", line 843 in exec_module File "", line 671 in _load_unlocked File "", line 975 in _find_and_load_unlocked File "", line 991 in _find_and_load File "/opt/anaconda/envs/qiskit0.30_test/lib/python3.8/site-packages/sparse/init.py", line 1 in File "", line 219 in _call_with_frames_removed File "", line 843 in exec_module File "", line 671 in _load_unlocked File "", line 975 in _find_and_load_unlocked File "", line 991 in _find_and_load File "/opt/anaconda/envs/qiskit0.30_test/lib/python3.8/site-packages/qiskit_machine_learning/neural_networks/circuit_qnn.py", line 21 in File "", line 219 in _call_with_frames_removed File "", line 843 in exec_module File "", line 671 in _load_unlocked File "", line 975 in _find_and_load_unlocked File "", line 991 in _find_and_load File "/opt/anaconda/envs/qiskit0.30_test/lib/python3.8/site-packages/qiskit_machine_learning/neural_networks/init.py", line 52 in File "", line 219 in _call_with_frames_removed File "", line 843 in exec_module File "", line 671 in _load_unlocked File "", line 975 in _find_and_load_unlocked File "", line 991 in _find_and_load File "01_neural_networks.py", line 66 in Segmentation fault (core dumped) (qiskit0.30_test) [root@rhel84 qiskit-machine-learning]#

seafolk-cn avatar Oct 20 '21 03:10 seafolk-cn

Unfortunately I don't have access to an s390x machine, but I can try to reproduce it on x86_64 over the weekend.

Let me check if i can share this env to you. :)

seafolk-cn avatar Oct 20 '21 03:10 seafolk-cn

It seems to be a problem importing Numba on S390x, IIUC. Can you try that on your system to see if it is indeed the issue?

If it is, can you install as many packages from conda as possible, and the conda compilers package as well, so things are built in an ABI compatible way?

hameerabbasi avatar Oct 20 '21 03:10 hameerabbasi

Is below your mailbox?

[email protected]

seafolk-cn avatar Oct 20 '21 04:10 seafolk-cn

hameer, mailed you just now, thanks!

seafolk-cn avatar Oct 20 '21 05:10 seafolk-cn

Hameer, sorry, just found the mentioned env not on this machine, i need create one to reproduce the issue, wait a moment.

seafolk-cn avatar Oct 20 '21 05:10 seafolk-cn

I'm doing it already following your instructions! 😆

hameerabbasi avatar Oct 20 '21 05:10 hameerabbasi

OK! Great!

But that will take some time to complete! You can create a new env with below clone command: conda create -n qiskit0.30_test --clone qiskit0.30_py3.8

the qiskit 0.30 already installed in it, then you can install extension like machine learning (pip install qiskit-machine-learning) etc.

the sample code are located in below folder. /root/tutorials/application-tutorials/qiskit-machine-learning

seafolk-cn avatar Oct 20 '21 05:10 seafolk-cn

I see that you reported numba/llvmlite#780. This is the root cause here. I will mark this as upstream.

hameerabbasi avatar Oct 20 '21 10:10 hameerabbasi

I see that you reported numba/llvmlite#780. This is the root cause here. I will mark this as upstream.

Yes, i originally considered these were different issues. But i now feel it maybe the same by comparing the stack trace.

Thanks!

seafolk-cn avatar Oct 21 '21 02:10 seafolk-cn