Skip to content
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

🐛 [Bug] Windows build broken after 1.2.0 - experimental:filesystem in TRTEngine #1563

Closed
bharrisau opened this issue Dec 21, 2022 · 5 comments
Assignees
Labels
bug Something isn't working channel: windows bugs, questions, & RFEs around Windows

Comments

@bharrisau
Copy link
Contributor

Bug Description

At some point after v1.2.0 the TensorRT\core\runtime\TRTEngine.h file was added and it brought the #include <experimental/filesystem> with it. I had some issues trying to build due to this. A #define is needed to build, the path cannot implicitly be converted to a std::string, an extra #include is needed to use std::stringbuilder and there is no stdc++fs to link against.

Environment

  • Torch-TensorRT Version: master f43be5b
  • PyTorch Version: libtorch 1.13.1+cu117
  • CPU Architecture: amd64
  • OS: Windows 11
  • Python version: Python 3.10.9
  • CUDA version: 11.8
  • cmake version: cmake version 3.21.21080301-MSVC_2
  • cl version: Microsoft (R) C/C++ Optimizing Compiler Version 19.30.30706 for x64
  • MSVC toolchain version: 14.30.30705

Rough fix

The below changes were needed to get a compile. They probably would break the build on other systems - so maybe need to be based on some platform detection.

Additional CMAKE flag

{
  "name": "CMAKE_CXX_FLAGS",
  "value": "-D_SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING",
  "type": "STRING"
}

Code changes

diff --git a/core/runtime/CMakeLists.txt b/core/runtime/CMakeLists.txt
index d21c661a..b3632e8f 100644
--- a/core/runtime/CMakeLists.txt
+++ b/core/runtime/CMakeLists.txt
@@ -33,7 +33,6 @@ target_link_libraries(${lib_name}
         TensorRT::nvinfer
         torch
         core_util
-        stdc++fs
 )

 # Install
diff --git a/core/runtime/TRTEngine.h b/core/runtime/TRTEngine.h
index 5615a824..1a2df1f2 100644
--- a/core/runtime/TRTEngine.h
+++ b/core/runtime/TRTEngine.h
@@ -25,7 +25,7 @@ struct TRTEngine : torch::CustomClassHolder {
   std::string name;
   RTDevice device_info;

-  std::string profile_path_prefix = std::experimental::filesystem::temp_directory_path();
+  std::string profile_path_prefix = std::experimental::filesystem::temp_directory_path().string();

   std::unordered_map<uint64_t, uint64_t> in_binding_map = {}; // TRT IDX -> PYT IDX
   std::unordered_map<uint64_t, uint64_t> out_binding_map = {}; // TRT IDX -> PYT IDX
diff --git a/core/runtime/TRTEngineProfiler.cpp b/core/runtime/TRTEngineProfiler.cpp
index a1159516..7857a467 100644
--- a/core/runtime/TRTEngineProfiler.cpp
+++ b/core/runtime/TRTEngineProfiler.cpp
@@ -1,5 +1,6 @@
 #include <algorithm>
 #include <fstream>
+#include <sstream>
 #include <iomanip>

 #include "core/runtime/TRTEngineProfiler.h"
@bharrisau bharrisau added the bug Something isn't working label Dec 21, 2022
@narendasan narendasan self-assigned this Jan 12, 2023
@narendasan
Copy link
Collaborator

@bharrisau can you open a PR for this?

@bharrisau
Copy link
Contributor Author

I'm 99% sure my changes will break all the other builds though. Did you want me to just take a best guess at hiding the WIN changes behind define/etc?

@narendasan
Copy link
Collaborator

Yeah that will at least give us a starting point and we can work to make sure it doesn't effect linux

@narendasan narendasan added the channel: windows bugs, questions, & RFEs around Windows label Jan 22, 2023
@Christina-Young-NVIDIA
Copy link
Collaborator

Awaiting PR.

@bharrisau bharrisau mentioned this issue Mar 3, 2023
10 tasks
@bharrisau
Copy link
Contributor Author

Done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working channel: windows bugs, questions, & RFEs around Windows
Projects
None yet
Development

No branches or pull requests

3 participants