grimoire / amirstan_plugin

Useful tensorrt plugin. For pytorch and mmdetection model conversion.
MIT License
159 stars 38 forks source link

Add Conan recipe #21

Closed sbugallo closed 3 years ago

sbugallo commented 3 years ago

Conan is one of the most used package managers in C++.

I added the recipe so it can be automatically updated and uploaded using a CI pipeline. This should help the user since the compilation is automatic and there is no need export any path.

There are a few things that need to be done on your side:

I uploaded it to my own channel (and you can test it if you want) but I think it would be better to integrate it in the official repository.

grimoire commented 3 years ago

Thanks for the contribution! I will check it. Note that it might take some time since I have no experiment on conan.

sbugallo commented 3 years ago

Sure, take your time! Post any message here if you meet any problem. I just updated the recipe with some options to specify TensorRT dir, whether to compile with DeepStream support or not, etc.

grimoire commented 3 years ago

Hi It is really coooooooool to use conan to manager the package!

And, I do meet some problem, the default value is None when I do the conan install with no options in conanfile. for example:

-DTENSORRT_DIR="None" -DCUB_ROOT_DIR="None"

Guess it is caused by my terrible CMakeLists.txt. Will it be fixed by refactor CMakeLists.txt (for example, using find_package for TensorRT)?

sbugallo commented 3 years ago

Hi! I'm glad that you like conan :)

If I understood correctly, it seems like the recipe is setting some definitions to the string "None" instead of doing nothing. I tried to do the same as you but I cannot reproduce that problem. If I did not mess up, in theory, options set to None should be skipped during the build stage (https://github.com/sbugallo/amirstan_plugin/blob/master/conanfile.py#L42-L49).

Can you provide the conanfile.txt and a simple script with the exact commads you are using?

If you want to remove the TENSORRT_DIR definition, I would do the following:

grimoire commented 3 years ago

I use following script to install plugins:

CONAN_REVISIONS_ENABLED=1 conan install .. -s compiler.libcxx=libstdc++11 --build=missing

The conanfile.txt is the same as what you provided in README:

[requires]
amirstan_plugin/0.4.1

[generators]
cmake

Then I got a lot of errors like(omit some duplicate logs):

CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
TENSORRT_INCLUDE_DIR

....

CMake Error in src/plugin/CMakeLists.txt:
  Found relative path while evaluating include directories of
  "amirstan_plugin":

    "TENSORRT_INCLUDE_DIR-NOTFOUND"

....

CMake Warning:
  Manually-specified variables were not used by the project:

    CMAKE_EXPORT_NO_PACKAGE_REGISTRY
    CMAKE_INSTALL_BINDIR
    CMAKE_INSTALL_DATAROOTDIR
    CMAKE_INSTALL_INCLUDEDIR
    CMAKE_INSTALL_LIBDIR
    CMAKE_INSTALL_LIBEXECDIR
    CMAKE_INSTALL_OLDINCLUDEDIR
    CMAKE_INSTALL_SBINDIR
    CONAN_COMPILER
    CONAN_COMPILER_VERSION
    CONAN_CXX_FLAGS
    CONAN_C_FLAGS
    CONAN_EXPORTED
    CONAN_IN_LOCAL_CACHE
    CONAN_LIBCXX
    CONAN_SHARED_LINKER_FLAGS

CMake Generate step failed.  Build files cannot be regenerated correctly.
amirstan_plugin/0.4.1: 
amirstan_plugin/0.4.1: ERROR: Package 'adbbd260a07cd76dce778726c4d4db78076e5e09' build failed
amirstan_plugin/0.4.1: WARN: Build folder /home/grimoire/.conan/data/amirstan_plugin/0.4.1/_/_/build/adbbd260a07cd76dce778726c4d4db78076e5e09
ERROR: amirstan_plugin/0.4.1: Error in build() method, line 51
    cmake.configure(source_folder=".")
    ConanException: Error 1 while executing cd '/home/grimoire/.conan/data/amirstan_plugin/0.4.1/_/_/build/adbbd260a07cd76dce778726c4d4db78076e5e09' && cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE="Release" -DCONAN_IN_LOCAL_CACHE="ON" -DCONAN_COMPILER="gcc" -DCONAN_COMPILER_VERSION="7" -DCONAN_CXX_FLAGS="-m64" -DCONAN_SHARED_LINKER_FLAGS="-m64" -DCONAN_C_FLAGS="-m64" -DCONAN_LIBCXX="libstdc++11" -DBUILD_SHARED_LIBS="ON" -DCMAKE_INSTALL_PREFIX="/home/grimoire/.conan/data/amirstan_plugin/0.4.1/_/_/package/adbbd260a07cd76dce778726c4d4db78076e5e09" -DCMAKE_INSTALL_BINDIR="bin" -DCMAKE_INSTALL_SBINDIR="bin" -DCMAKE_INSTALL_LIBEXECDIR="bin" -DCMAKE_INSTALL_LIBDIR="lib" -DCMAKE_INSTALL_INCLUDEDIR="include" -DCMAKE_INSTALL_OLDINCLUDEDIR="include" -DCMAKE_INSTALL_DATAROOTDIR="share" -DCMAKE_EXPORT_NO_PACKAGE_REGISTRY="ON" -DCONAN_EXPORTED="1" -DWITH_DEEPSTREAM="False" -DGPU_ARCHS="61;62;70;72;75;80;86" -DTENSORRT_DIR="None" -DCUB_ROOT_DIR="None" -Wno-dev '/home/grimoire/.conan/data/amirstan_plugin/0.4.1/_/_/build/adbbd260a07cd76dce778726c4d4db78076e5e09/.'

If I add following options in conanfile, it will finsh the building.

[options]
amirstan_plugin:tensorrt_dir=<path_to_tensorrt>
amirstan_plugin:cub_root_dir=<path_to_cub>

And, add FindTensorRT.cmake is a great idea. The root CMakeLists.txt looks better. Thank you!

sbugallo commented 3 years ago

It looks like the None value behaves differently than other option types. I just uploaded a minor fix. Please check if those errors still come up.

grimoire commented 3 years ago

Done! I have upload the package to https://grimoire.jfrog.io/artifactory/api/conan/grimoire-conan . Please check it and add it to the readme for me.

sbugallo commented 3 years ago

Conan is requesting me my credentials. I think you forgot to enable anonymous access:

grimoire commented 3 years ago

Oops, sorry, I have enable anonymous access.

sbugallo commented 3 years ago

Nice! I was able to download the recipe without problems. I just updated the README. Once this PR is merged, I think it would be nice to also add a conanfile.txt to https://github.com/grimoire/mmdetection-to-tensorrt/tree/master/demo/cpp. I can create a PR if you want.