Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Napari crashes when taking an OCLArray as input #1

Closed
haesleinhuepf opened this issue May 14, 2020 · 2 comments
Closed

Napari crashes when taking an OCLArray as input #1

haesleinhuepf opened this issue May 14, 2020 · 2 comments

Comments

@haesleinhuepf
Copy link
Member

Hey Folks,

I'm adding this issue here because I'm not sure if this is an issue on pyopencl side, on our side or a napari issue.

When replacing fly in this line with background_subtracted_fly, the te_oki.py script crashes. Napari cannot show OCLArrays even though the OCLArray should be accessible as a numpy array. I think we need to introduce a cle.pull method but couldn't figure out how to convert an OCLArray into a numpy array.

If someone has an idea how to fix this, feel freel to push to master :-)

Thanks!

Cheers,
Robert

P.S.: The error message reads like this:

>python te_oki.py
no scikit-tensor detected, so separable functions wont work
This is a python3 issue and can be resolved by:

git clone https://github.com/mnick/scikit-tensor.git
pip3 install scikit-tensor
(121, 1024, 512)
C:\Users\rober\Anaconda3\envs\te_oki\lib\site-packages\pyopencl\cffi_cl.py:1502: CompilerWarning: Non-empty compiler output encountered. Set the environment variable PYOPENCL_COMPILER_OU
TPUT=1 to see more.
  "to see more.", CompilerWarning)
Traceback (most recent call last):
  File "te_oki.py", line 21, in <module>
    viewer.add_image(background_subtracted_fly);
  File "C:\Users\rober\Anaconda3\envs\te_oki\lib\site-packages\napari\components\add_layers_mixin.py", line 228, in add_image
    return self.add_layer(layers.Image(data, **kwargs))
  File "C:\Users\rober\Anaconda3\envs\te_oki\lib\site-packages\napari\layers\image\image.py", line 232, in __init__
    self.contrast_limits_range = self._calc_data_range()
  File "C:\Users\rober\Anaconda3\envs\te_oki\lib\site-packages\napari\layers\image\image.py", line 257, in _calc_data_range
    return calc_data_range(input_data)
  File "C:\Users\rober\Anaconda3\envs\te_oki\lib\site-packages\napari\layers\utils\layer_utils.py", line 35, in calc_data_range
    [np.max(data[idx]) for idx in idxs],
  File "C:\Users\rober\Anaconda3\envs\te_oki\lib\site-packages\napari\layers\utils\layer_utils.py", line 35, in <listcomp>
    [np.max(data[idx]) for idx in idxs],
  File "<__array_function__ internals>", line 6, in amax
  File "C:\Users\rober\Anaconda3\envs\te_oki\lib\site-packages\numpy\core\fromnumeric.py", line 2668, in amax
    keepdims=keepdims, initial=initial, where=where)
  File "C:\Users\rober\Anaconda3\envs\te_oki\lib\site-packages\numpy\core\fromnumeric.py", line 88, in _wrapreduction
    return reduction(axis=axis, out=out, **passkwargs)
  File "C:\Users\rober\Anaconda3\envs\te_oki\lib\site-packages\gputools\core\ocltypes.py", line 123, in func
    return getattr(mod, f)(self, *args, **kwargs)
TypeError: f() got an unexpected keyword argument 'axis'
@jni
Copy link
Contributor

jni commented May 14, 2020

@haesleinhuepf you would need this for it to be automatic:

inducer/pyopencl#301

You can actually monkey patch it by running the line in my IPython session shown in that PR:

from pyopencl.array import Array
Array.__array__ = Array.get

And if you don't need it to be automatic, just call oclarray.get(). =)

I also want to note that long term, it would be super awesome if the arrays could just stay on the GPU, since we are then turning them into an OpenGL array. 😂 But, that will take quite a bit of coordination still, so the above remains your best bet.

@haesleinhuepf
Copy link
Member Author

Hey @jni ,

that solved it, thanks! So easy :-)

I also want to note that long term, it would be super awesome if the arrays could just stay on the GPU, since we are then turning them into an OpenGL array.

Let's see who is faster: You implementing that or us streaming OpenCL-Buffers directly into Tensorflow. It's always good to keep a long-term goal for later - long term ;-)

Thanks again!

Cheers,
Robert

haesleinhuepf pushed a commit that referenced this issue Jan 12, 2021
set destination parameters to None per default
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants