-
Notifications
You must be signed in to change notification settings - Fork 359
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
Add CMake support to build the libraries #1058
Conversation
a6fb363
to
c9fa4bf
Compare
@gcuendet Can you sign your commits? |
I think adding a
cc: @andi4191, I think we could just try to build it and just report if succeeds or not
Windows CI is part of our testing plan down the road as support matures. |
Hi @gcuendet! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks! |
I thought I did. If you look at my commit messages, they are all signed. What is it that is missing? Is there anything else to do than just |
This has come as kind of a surprise. In the CONTRIBUTING.md, there is no mention of a Meta CLA. I had the CLA included there reviewed by the legal department of my company before considering to contribute, but of course, now that the CLA has changed, I'll need a new round of reviewing. This might take time 😞 |
@gcuendet Yeah sorry about that, it recently changed (like late last week) as we are now working with Meta on co-developing this project so the requirements to upstream code now includes the Meta CLA instead of DCO (https://pytorch.org/blog/a-contributor-license-agreement-for-pytorch/). Hopefully we can still make progress on review while you get approval on your side |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably want to export the internal APIs to register custom converters as well (see
auto actelu = torch_tensorrt::core::conversion::converters::RegisterNodeConversionPatterns().pattern( |
What do you mean exactly with that? |
I mean export the symbols. I don't think we have any plans to change this. We want to keep it separate from the user level API most people use, however it is really just this file that people would use https://github.com/pytorch/TensorRT/blob/master/core/conversion/converters/converters.h |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Running into issues with linux.
145c133
to
43365df
Compare
b544cf5
to
61bfec8
Compare
65cdcc6
to
f8527d7
Compare
@narendasan how is the internal testing going? Is there anything I can help with? |
I'm facing errors while running this
The exact command I'm using
Errors:
@gcuendet anything I'm missing here ? |
TL;DR
In more details: You are getting the following error:
As the message says, CMake cannot find a target, specifically one of TensorRT targets ( I hope this helps. Let me know if something is unclear. |
Thanks @gcuendet. It works now.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Following things need to be documented in the CMake section of installation.rst so that the expectation is clear and these can be addressed in the future update
Looks like the python api cannot be built using cmake now (as naren mentioned --use-cmake)
CMake support for tests is missing.
Generate a Config.cmake as well, to be able to consume these libraries with cmake targets. Add CMake for windows - Add /wd4067 to silence a warning from pytorch include/c10/macros/Macros.h l.142 - Add /permissive- flag that specifies standards conformance mode to the compiler and allow to use `and` alternative operator for && in core/conversion/converteres/impl/activation.cpp Signed-off-by: Gabriel Cuendet <gabriel.cuendet@gmail.com> Signed-off-by: Gabriel Cuendet <gabriel.cuendet@cognex.com>
Signed-off-by: Gabriel Cuendet <gabriel.cuendet@gmail.com> Signed-off-by: Gabriel Cuendet <gabriel.cuendet@cognex.com>
Signed-off-by: Gabriel Cuendet <gabriel.cuendet@gmail.com> Signed-off-by: Gabriel Cuendet <gabriel.cuendet@cognex.com>
Signed-off-by: Gabriel Cuendet <gabriel.cuendet@gmail.com> Signed-off-by: Gabriel Cuendet <gabriel.cuendet@cognex.com>
Signed-off-by: Gabriel Cuendet <gabriel.cuendet@gmail.com> Signed-off-by: Gabriel Cuendet <gabriel.cuendet@cognex.com>
Signed-off-by: Gabriel Cuendet <gabriel.cuendet@gmail.com> Signed-off-by: Gabriel Cuendet <gabriel.cuendet@cognex.com>
Signed-off-by: Gabriel Cuendet <gabriel.cuendet@gmail.com> Signed-off-by: Gabriel Cuendet <gabriel.cuendet@cognex.com>
Signed-off-by: Gabriel Cuendet <gabriel.cuendet@gmail.com> Signed-off-by: Gabriel Cuendet <gabriel.cuendet@cognex.com>
The examples are considered as completely separated cmake project, in order to demonstrate how torchtrt would typically be consumed in a different CMake project and test the torchtrtConfig.cmake. Signed-off-by: Gabriel Cuendet <gabriel.cuendet@gmail.com> Signed-off-by: Gabriel Cuendet <gabriel.cuendet@cognex.com>
Signed-off-by: Gabriel Cuendet <gabriel.cuendet@gmail.com> Signed-off-by: Gabriel Cuendet <gabriel.cuendet@cognex.com>
f8527d7
to
bde1525
Compare
I added one more line in the CMake section of the Note that, as offered when I initially opened this PR, I can work on the python api compilation with CMake or the unit test support, but I will not do that as part of this PR. I first would like to see this one merged. Also, if you think there is a need for these additional things and would welcome my contributions for these (as opposed to doing them internally), I would like to be able to better communicate with you (typically by having access to your slack org). |
@gcuendet We are on the PyTorch slack which you can join through this form https://docs.google.com/forms/d/e/1FAIpQLSeADnUNW36fjKjYzyHDOzEB_abKQE9b6gqqW9NXse6O0MWh0A/viewform |
Description
This PR adds the CMake support to build the libraries and the torchtrtc executable. It also generates a
torchtrtConfig.cmake
, in order to be able to consume these libraries with cmake targets.The major advantage of the CMake support as introduced in this PR is the added ability to compile for windows as well, fixing the export of symbols, and generating both the
*.dll
and the*.lib
libraries. To export the symbols, I reused the existingTORCHTRT_API
macro, redefining it for windows, using CMake. The consumption of the dynamic libraries (both on linux and windows) is demonstrated by building the executable torchtrtc[.exe]. This has been tested locally with MSVC 2019 (19.29.30143.0), libtorch 1.11 (1.11.0+cu113), CUDA 11.6, cuDNN 8.2.1, and TensorRT 8.2.4.2.A secondary advantage is the handling of dependencies. These can be installed anywhere (not necessarily globally on the system) and by any mean and compiling the lib does not require editing config file anymore, instead, a few CMake variables are enough to have the dependencies correctly found and used. (for cuDNN and TensorRT, most of the magic happens in the CMake finders in
cmake/Modules
).This PR only adds partial CMake support to Torch-TensorRT (only for the libs and the executable torchtrtc). I started working on the unit tests as well and could consider working on adding the python support as well, if there is a clear interest. I still think that being able to compile the libraries (also on windows) has value in itself, and that's the reason for this PR.
I didn't add any documentation about how to compile using CMake, but that should probably be done. A bit of guidance on where and how this should be best done would be appreciated.
With this PR, I also would like to trigger the discussion around CMake and/or windows support (which, technically, are obviously totally independent). The kind of questions I have are:
Thanks for reviewing and looking forward to answer questions 😃
Type of change
Checklist:
Signed-off-by: Gabriel Cuendet gabriel.cuendet@gmail.com