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

PyOpenCl #367

Open
DjoleStepa opened this issue Aug 24, 2020 · 9 comments
Open

PyOpenCl #367

DjoleStepa opened this issue Aug 24, 2020 · 9 comments
Labels

Comments

@DjoleStepa
Copy link

Hi, I try to install PyOpenCl in Andriod Studio, but I have this error.

File "C:\Users\sdjordje\AppData\Local\Temp\easy_install-pu9wdfp0\numpy-1.19.1\tools\cythonize.py", line 59, in process_pyx
from Cython.Compiler.Version import version as cython_version
ModuleNotFoundError: No module named 'Cython'.

Install cython and try to install numpy-1.19.1, but same problem. Can you help me?

@mhsmith
Copy link
Member

mhsmith commented Aug 24, 2020

Thanks for the request. PyOpenCL isn't currently a priority, but if anyone else wants it too, please click the thumbs up button above, and subscribe to this issue for updates.

As for NumPy, I'm not sure why you're trying to install version 1.19.1, as the current version of PyOpenCL has no version number requirement. Chaquopy currently provides NumPy version 1.17.4: if you need a newer version than that, please explain why.

@DjoleStepa
Copy link
Author

If I understand, PyOpenCl not available now?

I want NumPy because in error, version of NumPy was 1.19.1. But, if PyOpenCl does not work, Numpy 1.17.4 is ok.

Thanks for answer.

@mhsmith
Copy link
Member

mhsmith commented Aug 24, 2020

If I understand, PyOpenCl not available now?

Unfortunately not.

@mpottinger
Copy link

I would love to have this. I am currently using compute shaders on Android, but PyOpenCL would be an amazing option to have. How difficult is it to get this to work? Is it something I could work on myself?

@mhsmith
Copy link
Member

mhsmith commented Dec 13, 2020

It might be tricky because OpenCL isn't one of the standard Android libraries. But TensorFlow recently announced that they were using it anyway by "check[ing] the availability of OpenCL at runtime".

Since recent versions of Android don't allow apps to access non-standard system libraries, I'm not sure how they've done this. The post says that "major Android vendors include OpenCL as part of their system library", so maybe that means it's built into libc or one of the other standard libraries.

If you'd like to try building PyOpenCL yourself, then you can license our package build tool, which was used to build everything in our native package repository. For more details, see #175 (comment). We would provide support for any general Android build issues, but we have no expertise in OpenCL specifically.

@mpottinger
Copy link

mpottinger commented Dec 14, 2020

I was able to load the OpenCL library in Chaquopy using ctypes, initial attempts crashed but I may have been initializing the library incorrectly. It did load libOpenCL.so though and attempt to access the gpu, i could see it loaded mali drivers in logcat.

Currently OpenGL Compute shaders are working well for me, but if I find myself really badly needing a feature of OpenCL that OpenGL lacks then I will definitely take up that offer. That or any other native packages I come across.

@mhsmith
Copy link
Member

mhsmith commented Dec 14, 2020

I was able to load the OpenCL library in Chaquopy using ctypes, initial attempts crashed but I may have been initializing the library incorrectly. It did load libOpenCL.so though

Interesting, thanks. How exactly did you load it: was it as simple as ctypes.CDLL("libOpenCL.so")?

@mpottinger
Copy link

mpottinger commented Dec 14, 2020

Interesting, thanks. How exactly did you load it: was it as simple as ctypes.CDLL("libOpenCL.so")?

On my Huawei P30 Pro yes it was as simple as that. Hopefully Tensorflow and/or Pytorch get better OpenCL support. So far the tensorflow-gpu package did not seem to actually use the GPU in Chaquopy when I tried it.

Is your tensorflow-gpu package built from this? The SYSCL port of Tensorflow: https://github.com/codeplaysoftware/tensorflow

If not, I would definitely be interested in that. Having a true GPU accelerated full Tensorflow, not the standard Android/Java tflite would be very interesting.

@mhsmith
Copy link
Member

mhsmith commented Dec 14, 2020

So far the tensorflow-gpu package did not seem to actually use the GPU

That's correct: since TensorFlow 2.0, the tensorflow and tensorflow-gpu packages are actually the same. They only support GPU acceleration via CUDA, which won't work on Android.

As well as OpenCL, the Java TensorFlow Lite library also supports acceleration on Android via OpenGL and NNAPI, but none of these are supported by its Python API yet. Hopefully this will improve in the future, as there also have been some requests for OpenGL acceleration on the Raspberry Pi.

Is your tensorflow-gpu package built from this? The SYSCL port of Tensorflow

No, we have our own patches against the main TensorFlow repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants