FLAMEGPU / FLAMEGPU2-tutorial-python

MIT License
4 stars 0 forks source link

Jitify compilation errors are not visible in notebooks #10

Open ptheywood opened 3 years ago

ptheywood commented 3 years ago

When running pyflamegpu from a notebook, jitify compile errors are not shown to the user

I.e. all that is seen is:

FLAMEGPURuntimeException: (InvalidAgentFunc) /__w/FLAMEGPU2/FLAMEGPU2/src/flamegpu/util/detail/JitifyCache.cu(342): Error compiling runtime agent function (or function condition) ('grass_growth'): function had compilation errors (see std::cout), in JitifyCache::buildProgram().

This is not the case for running python outside of a notebook

This appears to be resolved by running a more recent version of ipython/jupyter, but a workaround is still required for collab where we cannot update this.

Todo

Notes

Locally, jupyter lab and jupyter notebook both show stdout on Ubuntu 21.04, python 3.9 with the following jupyter packages:


ipykernel           6.3.1
ipython             7.27.0
ipython-genutils    0.2.0

nbclassic           0.3.1
nbclient            0.5.4
nbconvert           6.1.0

jupyter-client      7.0.2
jupyter-core        4.7.1
jupyter-server      1.10.2
jupyterlab          3.1.10
jupyterlab-pygments 0.1.2
jupyterlab-server   2.8.0

And from About juptyer notebook:

The version of the notebook server is: 6.4.3-86f11a1

Python 3.9.5 (default, May 11 2021, 08:20:37) 
[GCC 10.3.0]

Python 3.9.5 (default, May 11 2021, 08:20:37) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.27.0 -- An enhanced Interactive Python. Type '?' for help.

The Innstance hub jupyter notebook is running:

ipykernel                     5.5.5
ipython                       7.16.1
ipython-genutils              0.2.0
ipywidgets                    7.6.3

nbclient                      0.5.3
nbconvert                     6.0.7
nbformat                      5.1.3

jupyter                       1.0.0
jupyter-client                6.1.12
jupyter-console               6.4.0
jupyter-core                  4.7.1
jupyterlab-pygments           0.1.2
jupyterlab-widgets            1.0.0
The version of the notebook server is: 6.4.0
The server is running on this version of Python:
Python 3.6.9 (default, Jan 26 2021, 15:33:00) 
[GCC 8.4.0]

Current Kernel Information:
Python 3.6.9 (default, Jan 26 2021, 15:33:00) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.16.1 -- An enhanced Interactive Python. Type '?' for help.

Installing the exact versions as found on the intancehub hosted copy, the stdout being consumed can be reproduced:

python3 -m pip install ipykernel==5.5.5 ipython==7.16.1 ipython-genutils==0.2.0 ipywidgets==7.6.3 nbclient==0.5.3 nbconvert==6.0.7 nbformat==5.1.3 jupyter==1.0.0 jupyter-client==6.1.12 jupyter-console==6.4.0 jupyter-core==4.7.1 jupyterlab-pygments==0.1.2 jupyterlab-widgets==1.0.0 

Colab is running the following:

ipython                       5.5.0
ipython-genutils              0.2.0
ipython-sql                   0.3.9
jupyter                       1.0.0
jupyter-client                5.3.5
jupyter-console               5.2.0
jupyter-core                  4.7.1
jupyterlab-pygments           0.1.2
jupyterlab-widgets            1.0.0
nbclient                      0.5.4
nbconvert                     5.6.1
nbformat                      5.1.3

Installing differnt versions of ipykernel has identified 6.0.0a5 (Released: Apr 26, 2021) as the first pypi release version which fixes this issue / introduces the change. This may help find a workaround.

The closed issues for milestone 6.0 for the ipykernel project may provide some insight.

The diff between 6.0.0a4 and 6.0.0a5 can also be found: https://github.com/ipython/ipykernel/compare/6.0.0a4...6.0.0a5

https://github.com/ipython/ipykernel/pull/630 is the relevant PR.

ptheywood commented 3 years ago

Older ipython versions will also consume any stdout output from flamegpu, i.e. --timing or --verbose output.

ptheywood commented 3 years ago

Updating ipykernel on colab does work, but requires a kernel restart. Pip also complains due to package incompatibility but it does work. This seems like a very sketchy solution though.

!python -m pip install ipykernel==6.0.0

Runtime > Restart Runtime (or ctrl + M .), then Yes. Variables are then lost, so most cells wil need re-running.

Screenshot_20210908_152641

ptheywood commented 3 years ago

Decisions:

ptheywood commented 1 year ago

This issues is still present, with google collab still running ipykernel 5.3.4

import ipykernel
print(ipykernel.__version__)
5.3.4

I opened an issue about this / requesting an update with googlecollab at the time: https://github.com/googlecolab/colabtools/issues/2230

ptheywood commented 1 year ago

Logs can be viewed by Runtime -> view runtime logs (https://github.com/FLAMEGPU/FLAMEGPU2/discussions/1020#discussioncomment-4410748). We should probably add this to the text.

We could potentially ammend the error message in python land if running in jupyter too, if detection and ipython version detection is possible?