-
Notifications
You must be signed in to change notification settings - Fork 86
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
request: Pillow-simd w/ libjpeg-turbo conda/pip package #44
Comments
This will happen after the release 5.4 of Pillow. No additional action is required.
Pillow-SIMD is not a binary package, it could build with both libjpeg and libjpeg-turbo depending on which is installed in your system. Installing Pillow-SIMD is the same thing as installing Pillow from sources. Pillow-SIMD doesn't aim to change Pillow's build system. If you have problems when building Pillow from sources, you'd better fix it in Pillow, not in Pillow-SIMD.
This is exactly what happens now.
Pillow and Pillow-SIMD don't control pip and conda. If you want conda/pip to behave in some particular way, you probably need to ask them about it.
Pillow doesn't work this way right now: It has many "from PIL" import in codebase. So before using alternative namespace, you need to fix Pillow. |
libjpeg-turbo detects CPU features and choose different branches of code at runtime. Pillow-SIMD doesn't have such feature. |
Thank you for answering my questions, @homm. Here are proposed solutions for building Pillow-SIMD from scratch by users and not getting Pillow-SIMD wiped out on conda/pip install/update for 1. Solution for pipThat's an easy one: Apply this patch:
Now build
Now we get a true drop-in replacement and not half-baked. Observe:
Since we need a user to build this from scratch this works If a user is not using the conda environment, this problem is now solved for her. 2. Solution for CondaWhile pip will respect conda's installs (i.e. won't try to reinstall a package with the same version installed by conda), conda doesn't respect pip's packages - it'll not look at whether the package has already been installed. So anybody using the conda environment will have a constant problem of losing their custom-build Since you say we can't have a binary release and users need to rebuild from scratch, we need to provide them a way to build a conda package on their machine from scratch. First, unzip the conda recipe folder attached to this comment. So:
Now the user has their own I'm getting intermittent problems with the overriding, it works with:
but need to do more testing. So, we will just need you to include the patch in solution #1 and the conda recipe. Someone could please repeat my solutions and see that I haven't made any mistakes. I have made many in the process of writing this comment. |
Could Pillow-SIMD to do the same or will that have a negative impact on the performance? Also the README of this project isn't going into details why Pillow-SIMD needs to be built from scratch. |
Any chance you could follow up on the last comment, @homm? I'm not asking you to commit to build any binary packages. Just needing to know whether it's enough to build 2 versions for optimal performance on linux-64 (a. SSE4 b. AVX2) to cover all bases. I don't have the expertise in this domain, and I was hoping that you could share your insights. Thank you. |
The solution at https://docs.fast.ai/performance.html#conda-packages does work, but is (as the description says) very fragile. Conda immediately starts to display warnings like:
and will indeed wipe out
This sounds correct to me, SSE4 and AVX2 versions do seem to be enough.
This is possible without significant performance impact. NumPy, OpenCV and other packages do the same. The long-term solution for this packaging problem seems to be to add runtime selection, and then upstream everything into Pillow. But of course that may be a lot of work .... Thanks for the work on this packaging issue @stas00. And of course thanks @homm for making Pillow faster - it does make a noticeable difference to me in some deep learning pipelines. |
Thank you for your comments, @rgommers. I'm with you that ideally this would be part of upstream. Thomas Brandon, has expanded on my initial work, and created |
I second this request. I've been trying to install |
Since you have been making this amazing effort to port more and more things into SIMD, I was wondering if perhaps you have a modified conda recipe that builds Pillow-simd w/ built-in libjpeg-turbo library.
Currently, Pillow-simd is already a problem with conda, since any update of any package relying on Pillow will wipe out Pillow-simd. And if one wants to build either Pillow or Pillow-SIMD with libjpeg-turbo to include SIMD compression/decompression it becomes even more complicated package management-wise. Plus there is a potential conflict of libjpeg-turbo and jpeg should they both have the same
libjpeg.so.x.y
- that would be the worst!I spent the last few days trying to sort it out, resulting in this documentation https://docs.fast.ai/performance.html#faster-image-processing and python-pillow#3493 kindly contributed by @radarhere, which I hope you will sync into your branch soon. The main effort was made to detect the SIMD versions of Pillow and libjpeg because they are so volatile in the pypi/conda environments.
We really need a reliable binary package that has all the SIMD goodness and which won't get swapped out and replaced by the default-limited versions of the same. And so that other packages (fastai in our case) could depend on it in their pypi/conda dependencies.
I propose a new version of
pillow-simd
calledpillow-simd-jpeg-turbo
which will be a binary build of Pillow-SIMD, built with libjpeg-turbo'slibjpeg.so
at a unique location underPIL/
, rather than environment'slibs
, so that one doesn't need to install the turbo package (and no need for any other files from the libjpeg-turbo package). And once installed it'll reliable work, no matter what other packages get installed or updated.And for our use, linux-only build would be a great start.
Thoughts?
edit: re-reading again your README file, I now see that pre-compiling won't work. What about making a source pip package then that will be compiled by each user, but once compiled it'll be left alone and not swapped out by conda/pip updates of other packages.
and moreover my idea won't work unless it'll replace PIL with PIL-foo, so it's no longer a drop-in replacement, but a different namespace altogether. Which perhaps could be aliased back to PIL, and it'd go something like:
What a mess.
Finally, libjpeg-turbo is distributed as a binary, and it says AVX2 is supported. Sorry, I am new to SIMD, you say Pillow-SIMD has to be built from source, but libjpeg-turbo doesn't? Please kindly explain.
The text was updated successfully, but these errors were encountered: