maweigert / spimagine

GPU accelerated volume rendering / processing in Python
BSD 3-Clause "New" or "Revised" License
117 stars 17 forks source link

Window close immediately #28

Closed alessandro-zomparelli closed 6 years ago

alessandro-zomparelli commented 6 years ago

Hi @maweigert , thank you for your great work, this visualizer is really amazing. Unfortunately when I try to execute it, the window immediately close without any kind of messages in the console...

If I try to run spimagine, it work perfectly, but I'm not really able to run your examples... Do you have clues?

Thanks!

maweigert commented 6 years ago

Hi, I'm confused as to when this error appears, so i would need more information to pin that down:

alessandro-zomparelli commented 6 years ago

Sorry, I wasn't really specific: Ubuntu 16.04, Python 3, Nvidia GTX960M. This is my test code:

from spimagine import volshow import numpy as np

data = np.linspace(0,1,100*3).reshape((100,)3)

w = volshow(data)

w.transform.setRotation(.1,1,0,1) w.set_colormap("hot")

w.saveFrame("/media/DATI/PythonCode/scene.png")

The generated image is that: scene

The problem occurs on both Jupyter and simple command line. Trying a simpler code, same problem:

import numpy as np from spimagine import volshow

data = np.einsum("ij,k",np.ones((100,)*2), np.linspace(0,1,100)) w = volshow(data)

If I type dmesg | tail I get this:

[ 33.233310] nvidia-modeset: Allocated GPU:0 (GPU-daa1fc2f-e793-5d4f-fd9a-08262cc7c7e7) @ PCI:0000:02:00.0 [ 33.233501] nvidia-modeset: Freed GPU:0 (GPU-daa1fc2f-e793-5d4f-fd9a-08262cc7c7e7) @ PCI:0000:02:00.0 [ 34.407216] nvidia-modeset: Allocated GPU:0 (GPU-daa1fc2f-e793-5d4f-fd9a-08262cc7c7e7) @ PCI:0000:02:00.0 [ 34.407353] nvidia-modeset: Freed GPU:0 (GPU-daa1fc2f-e793-5d4f-fd9a-08262cc7c7e7) @ PCI:0000:02:00.0 [ 38.743852] nvidia-modeset: Allocated GPU:0 (GPU-daa1fc2f-e793-5d4f-fd9a-08262cc7c7e7) @ PCI:0000:02:00.0 [ 38.744090] nvidia-modeset: Freed GPU:0 (GPU-daa1fc2f-e793-5d4f-fd9a-08262cc7c7e7) @ PCI:0000:02:00.0 [ 39.215370] nvidia-modeset: Allocated GPU:0 (GPU-daa1fc2f-e793-5d4f-fd9a-08262cc7c7e7) @ PCI:0000:02:00.0 [ 39.215514] nvidia-modeset: Freed GPU:0 (GPU-daa1fc2f-e793-5d4f-fd9a-08262cc7c7e7) @ PCI:0000:02:00.0 [ 77.630615] nvidia-modeset: Allocated GPU:0 (GPU-daa1fc2f-e793-5d4f-fd9a-08262cc7c7e7) @ PCI:0000:02:00.0 [ 77.630976] nvidia-modeset: Freed GPU:0 (GPU-daa1fc2f-e793-5d4f-fd9a-08262cc7c7e7) @ PCI:0000:02:00.0

Can be something related to my system, maybe with the incoming version 18.04 LTS everything will work fine...

maweigert commented 6 years ago

Hi,

The output is the same as for me and this is expected behaviour (its the cube rendered with the maximal intensity side front). Likewise your png seemes to be saved just fine.

So does it crash inbetween? Can you rotate the cube when you're grabbing it with the mouse?

Did you start ipython with ipython3 --gui qt5

or in jupyter included %gui qt5 at the beginning?

alessandro-zomparelli commented 6 years ago

Hi @maweigert , many thanks, now in Jupyter it works. But i'm still not able to run it with from the command line. Ipython is the only way to execute it from the command line?

alessandro-zomparelli commented 6 years ago

Solved! I was missing the blocking=True argument for volshow: w = volshow(data, blocking=True)

Thanks again! Alessandro

maweigert commented 6 years ago

Cool :)

Strange still, as ipython3 --gui qt5 should give you the default non-blocking behaviour (which is what one normally wants). Was there an actual error message, when you run it from within ipython (without blocking=True)?

alessandro-zomparelli commented 6 years ago

Well, I know nothing about ipython, but because I'm running it under python 2.7 (maybe this is the reason?), I typed: ipython --gui qt5 /media/DATI/PythonCode/spimagine_test_02.py

And without using blocking=True, it doesn't work. Why should I use ipython instead of just python?

maweigert commented 6 years ago

Ahhh, now I see :)

Yes, there are several ways to use it:

1) interactively in ipython, where one first starts the ipython shell with ipython --gui qt5 and then just types in the commands line by line as in the example. This is the way I mostly use it, whenever I have some arrays that is alread loaded or processed in ipython, i just do

import spimagine
volshow(my_array)

This is my preferred way to interact with 3d data (works in Jupyter the same way).

2) as skript to output the rendered scenes: This is like you did it, when you run a script with ipython my_script.py the intepreter will directly return after the window is created. This is normally what I want, as it enables to run lots of scripts that produce some output, without user interruption (e.g. to close the window).

3) What I typically do:

Finally, I would always use ipython over the standard python shell. It has tab completion, syntax highlighting, and lots of cool stuff (e.g. you can run normal shell commands from within).

alessandro-zomparelli commented 6 years ago

Ah ok, now it's more clear. In my case I'm interested at the moment in running real-time simulations and see the outputs with volshow. It works perfectly!

But I will probably used it for generating catalogs of images, and for that I will probably use your way :)

Many thanks, and great job again!