Vision: Package libjpeg and libpng within torchvision

Created on 5 Jun 2020  路  6Comments  路  Source: pytorch/vision

With the addition of image-reading functions enabled by default in torchvision #1632 #1881 #1909, we will need to properly package libjpeg and libpng (and other libraries will be used soon as well, like ffmpeg) so that users of {Windows, Linux, OSX} x {pip, conda, source} can use those new functionalities in torchvision without issues.

I believe the current recommended way that PyTorch deals with 3rd-party libraries is the following:

  • for conda, we use conda's package manager to handle the dependencies. Both libjpeg and libpng are available in standard channels, although I'm not sure if using the conda-forge channel would bring problems due to conflicts with other libraries we use.
  • for pip, I believe the preferred way is to include the libraries together with the torchvision wheel
  • for source, we would need to handle the common installation locations, or at least provide clear instructions on how to provide the path to the libraries, either via CMake or performing the handling via python like Pillow does (although the logic seems quite intricate).

We will also need to make sure our CI (which is fairly tied to binary builds) is updated.

cc @seemethere @rgommers

high priority binaries build

Most helpful comment

@andfoy I gave you and @rgommers triage permissions to torchvision

All 6 comments

although I'm not sure if using the conda-forge channel would bring problems due to conflicts with other libraries we use.

It may right now I think, we really need to improve that situation. It would also force the users to mix channels. libpng is available in defaults. libjpeg-turbo is in defaults as well, but it looks outdated. Needs a more detailed look at what the best option is here.

for pip, I believe the preferred way is to include the libraries together with the torchvision wheel

@fmassa said that size of the wheels isn't critical, and just bundling in libpng and libjpeg should be fine for now. So using auditwheel (Linux) and delocate (macOS) seems like the way to go. There's no such tool for Windows, so there the right libs need to be copied in by hand.

@fmassa, is it possible to have assignment permissions on this repository?

@andfoy I gave you and @rgommers triage permissions to torchvision

@jjhelmus is it possible to update libjpeg-turbo to the latest version on the default channel in Anaconda? It seems that the current version (1.2.1) is older than the one found on conda-forge.

libjpeg-turbo is provided as a CDT in defaults not a standard package. CDT are packages which stand in for system installed libraries and therefore cannot be updated.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

xuanqing94 picture xuanqing94  路  3Comments

ArashJavan picture ArashJavan  路  3Comments

martinarjovsky picture martinarjovsky  路  4Comments

IssamLaradji picture IssamLaradji  路  3Comments

varagrawal picture varagrawal  路  3Comments