BlueBrain / morphoclass

Neuronal morphology preparation and classification using Machine Learning.
https://morphoclass.readthedocs.io
Apache License 2.0
8 stars 4 forks source link

"Segmentation fault: 11" error when using pretrained dataset #79

Open YannRoussel opened 2 years ago

YannRoussel commented 2 years ago

Hello,

I am trying to use pre-trained models downloaded following this guide but I get the "Segmentation fault: 11" error even if I use a dummy dataset (i.e. a numpy array of the right shape filled with 0)

I use this script:

d = torch.load("morphoclass/dvc/training/checkpoints-alt-neurites/pc-L6-all-image-tmd-proj-xgb-stratified-k-fold/checkpoint.chk")
model = d["all"]["model"]

dummy = np.zeros((100, 10000))
model.predict(dummy)

I also tried with another model (pc-L5-all-image-tmd-rd-xgb-stratified-k-fold) and with an actual dataset of persistence images but get the same error.

Thank you for your help,

Yann Roussel.

FrancescoCasalegno commented 2 years ago

Hi @YannRoussel ,

I tried to reproduce your snippet but it works fine for me:

>>> model.predict(dummy)

array([2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
       2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
       2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
       2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
       2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2])

Could you please check your environment?

If the two points above don't solve it try also pip install -r requirements.txt to make sure you have the exact same versions for the Python packages as we used to train the models.

YannRoussel commented 2 years ago

Hi @FrancescoCasalegno ,

Thank you for the help! my python version is Python 3.8.13 and I have xgboost==1.4.2.

I have pip install -r requirements.txt and got:

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
sphinx-bluebrain-theme 0.2.11 requires Jinja2~=3.0.0, but you have jinja2 2.11.3 which is incompatible.
dvc 2.16.0 requires tqdm<5,>=4.63.1, but you have tqdm 4.53.0 which is incompatible.
dvc-objects 0.1.6 requires tqdm<5,>=4.63.1, but you have tqdm 4.53.0 which is incompatible.

Successfully installed Cython-0.29.32 Flask-1.1.2 argparse-1.4.0 captum-0.3.1 cleanlab-1.0 click-8.1.2 dash-1.19.0 dash-bootstrap-components-0.12.0 dash-core-components-1.15.0 dash-html-components-1.1.2 dash-table-4.11.2 dash_renderer-1.9.0 deepwalk-1.0.3 dill-0.3.3 futures-3.0.5 gensim-4.1.0 imbalanced-learn-0.8.0 jinja2-2.11.3 matplotlib-3.5.1 morphology-workflows-0.3.0 networkx-2.5 neurom-3.1.0 numpy-1.21.0 pandas-1.3.4 plotly-5.4.0 scikit-learn-1.0.1 scipy-1.7.3 seaborn-0.11.0 shap-0.39.0 torch-1.7.1 tqdm-4.53.0 umap-learn-0.5.1 wheel-0.37.1

I also re-run my dummy script and got:

OSError: dlopen(/Users/yroussel/PycharmProjects/pythonProject/scala_morpho_classification/morphoclass/myvenv/lib/python3.8/site-packages/torch_sparse/_version_cpu.so, 0x0006): Symbol not found: __ZN3c106detail12infer_schema20make_function_schemaENS_8ArrayRefINS1_11ArgumentDefEEES4_
  Referenced from: /Users/yroussel/PycharmProjects/pythonProject/scala_morpho_classification/morphoclass/myvenv/lib/python3.8/site-packages/torch_sparse/_version_cpu.so
  Expected in: /Users/yroussel/PycharmProjects/pythonProject/scala_morpho_classification/morphoclass/myvenv/lib/python3.8/site-packages/torch/lib/libtorch_cpu.dylib

Could this be related to the Jinja2 from the requirements.txt? Should I try to pip install Jinja2==3.0.0 manually?