import tensorflow from within Slicer python interactor causes crash

Hi All,

I build Slicer from trunk and pip_install(“tensorflow”) from python interactor within Slicer (Ctrl + 3).
Seems to be successful. Then I “import tensorflow”,but this crashes Slicer without detailed error message.

I tried this:
./Slicer --launch …/python-install/bin/python
Then in this python interpreter, I import tensorflow
And things are fine (no crashing)

But within Slicer it crashes.

Could I have any hint on the direction I should look into?

Thank you!

yi

Importing tensorflow in Slicer GUI works fine on Windows (using a recent Slicer Preview Release - Slicer-4.11.0-2019-08-13).

What operating system and which Slicer version do you use? Do you have a stack trace of the crash? Have you pip-installed any other packages?

You may try to downgrade tensorflow or switch between GPU/CPU version.

Hi Andras,

I’m using Linux Mint 19.1 with gcc 7.3 with nightly Slicer (20190816)

I didn’t pip install other packages except those trigger by tensorflow.

I tried both GPU (tensorflow-gpu) and CPU versions and both crashes.

I don’t have crash trace yet. It just says :
./SlicerApp-real] exit abnormally - Report the problem.

How could I get the trace info?

Thanks!
yi

I don’t know how to debug this on linux, hopefully others can help.

Alternatively, you can run your Python script as a CLI module. See example here.

Thank you Andras!

I’ll investigate the CLI python approach and update with you.

Best,
yi

You could also generate a core dump and than open it with ddd (or gdb). While there are no debug info available within Release build, it should still provide some useful information.

See Documentation/Nightly/Developers/Tutorials/Debug Instructions - Slicer Wiki

Thanks Jc,

Will do this and report back soon.

Best,
yi

Hi Andras,

In trying the python CLI, how could i assign the python environment I want Slicer to run my pythonCLI with? (Say my python exe is in /opt/anacondaGPU/bin/python)

Thanks for the advice!

Best,
yi