pytorch / pytorch/vision

[RFC] Use CMake to compile torchvision in setup.py

Open
#2,349 10 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

needs discussion topic: build
Dominant language
Python
Stars
17.9k
Forks
7.3k
Avg merge
1d 15h
Merged PRs (30d)
13

Description

TorchVision uses setuptools to compile its C++ / CUDA dependencies, which has been working ok for now.

But with the addition of FFmpeg and libpng / libjpeg-turbo as dependencies, and in the interest to simplify the path from using torchvision ops in C++, it might be worth considering unifying the compilation steps in torchvision to aways go through CMake.
This could potentially simplify / make more robust to locate external libraries (like FFmpeg and libjpeg-turbo

This has been first discussed in https://github.com/pytorch/vision/pull/2253#issuecomment-648219377, and has been brought already in the past by @soumith

Non-exhaustive list of what is left to do:

  • Optional PNG and JPEG libs (they are required in cmake)
  • Verify that FindPNG / FindJPEG work with our setup on CI
  • Logic to compile independent libs for image and video
  • torchvision_EXPORTS macro definition unconditionally for windows (shouldn't matter too much)
  • rocm/hipify logic
  • option to build tests for C++ models (can be postponed)

cc @bmanga @andfoy for discussion.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at setup.py and the CMake configuration, then review the listed FindPNG/FindJPEG, CI, independent image/video library, Windows, ROCm/hipify, and C++ model test concerns. Done means the compilation path is unified through CMake and the required checklist items are resolved or explicitly deferred.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, cpp, python
Domain
build-system, computer-vision
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.