Skip to content

request: Pillow-simd w/ libjpeg-turbo conda/pip package #44

@stas00

Description

@stas00

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 called pillow-simd-jpeg-turbo which will be a binary build of Pillow-SIMD, built with libjpeg-turbo's libjpeg.so at a unique location under PIL/, rather than environment's libs, 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:

try:
    import PIL_SIMD
    PIL = PIL_SIMD # alias to PIL
    ...etc...
except:
    import PIL

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions