-
Notifications
You must be signed in to change notification settings - Fork 363
Fix missing unistd.h on Windows #152
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
Conversation
Note that with this change I am able to successfully build TRTorch for Windows. Built version shown here: |
@xsacha Thanks for the contribution! We will try to verify the patch and get it merged in as soon as possible, though for the foreseeable future windows support is going to remain unofficial / mostly community driven due to developer resource constraints. We are more than happy to merge / review PRs and help where we can but it will not be a high priority for us. Also in order to merge we need you to sign your commit in accordance with the Developer Certificate of Origin (https://github.com/NVIDIA/TRTorch/blob/master/CONTRIBUTING.md#commits-and-prs). To amend your commits follow these instructions: https://github.com/NVIDIA/TRTorch/pull/152/checks?check_run_id=888297024 |
As part of Windows compatibility Signed-off-by: Sacha Refshauge <[email protected]>
Signed-off-by: Sacha Refshauge <[email protected]>
@xsacha Were there associated build system changes you made to get the library to compile? |
I needed to change the bazel files to point to Windows dlls but I am not familiar with the proper way to do this so I didn't commit these. I had just changed the default to Windows. |
Ideally we could use bazel platforms like we do for aarch64-linux (e.g. https://github.com/NVIDIA/TRTorch/blob/fe06d0993d1ebf9083eada67a42e4fd46c4bee92/third_party/tensorrt/local/BUILD#L3, documentation: https://docs.bazel.build/versions/master/platforms-intro.html) if you want to take a stab at it or you could commit the changes you made and we can advise on next steps. |
Do you want the Bazel changes in this PR as well? |
Note: you will need to use local instead of archive for cuda/cudnn/tensorrt. Also: I was not able to get git working in Bazel but it is meant to work. If it doesn't just comment that out and load the pip repository manually. Signed-off-by: Sacha Refshauge <[email protected]>
Yeah having them in this PR is fine |
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.
I have a few queries and requests
Signed-off-by: Sacha Refshauge <[email protected]>
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.
LGTM
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.
Noticed a couple syntax issues and also when I tried compiling I ran into some errors, seems like the have to do with the logging macros. Did you run into these?
core/conversion/conversion.cpp(60): error C2679: binary '<<': no operator found which takes a right-hand operand of type 'trtorch::core::util::logging::TRTorchLogger' (or there is no acceptable conversion)
Also just curious when you do development on Windows do you typically install libraries like cudnn or tensorrt to the system somewhere and reuse them or do you keep them in a workspace that is project specific. Seems like we could extend these changes to the archive based dependencies too pretty easily. Doesn't have to be in this PR but just wondering if it would be useful.
@@ -19,6 +26,7 @@ cc_import( | |||
name = "cudnn_lib", | |||
shared_library = select({ | |||
":aarch64_linux": "lib/aarch64-linux-gnu/libcudnn.so", | |||
":windows": glob(["bin/cudnn64_*.dll"])[0], |
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.
This is kind of odd, is there a reason you chose glob here?
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.
Just to note, the glob failed, I ended up just putting the 7 in the path and removing the glob
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.
How do we support cudnn8?
I was trying to make sure it supports v8 and the glob worked for me to pick 7 or 8.
I'm not good with bazel and couldn't figure out how to do a wildcard without a glob. Then a glob returns a list so I needed to get the first value.
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.
Also just curious when you do development on Windows do you typically install libraries like cudnn or tensorrt to the system somewhere and reuse them or do you keep them in a workspace that is project specific. Seems like we could extend these changes to the archive based dependencies too pretty easily. Doesn't have to be in this PR but just wondering if it would be useful.
I installed cudnn and tensorrt to a folder and specified it in WORKSPACE. I'm more of a Linux developer but need this working on Windows if we are to use it at all.
Not sure what's going on with the stream operator there. From the error, it looks like it doesn't like:
#define TRTORCH_LOG(l, sev, msg) \
do { \
std::stringstream ss{}; \
ss << msg; \
l.log(sev, ss.str()); \
} while (0)
Maybe a MSVC issue (if that's the compiler you are using).
If you remove the line:
ss << msg;
does it compile?
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.
I can look into if there is another way to get the wildcard working. Hmm, I can look into the logging issue more, you didn't hit it right? What version of MSVC did you use? Did you add any additional flags or anything (like I noticed MSVC doesnt handle default flags we have like --std=c++14
)?
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.
@narendasan Any update with this?
It seems to work fine here. Is it the version of Bazel I am using?
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.
Seems like something about the particular use of a specialized logger in conversion.cpp that is causing the issue, If I switch to the generic logger I can compile the library and successfully start programs using the core library such as trtorchc
(I don't notice the issue mentioned in #153 if i understood the issue correctly either, the compiler starts up correctly but I think we don't handle windows paths well so i haven't yet tested further). I dont think it is due to the bazel version as it just calls the underlying C++ compiler similar to how make or CMake does. I think its a compiler issue, I am not sure which compiler version you used, I used the latest MSVC 2019 build tools. If there is anymore information you could give me about your build environment and build process that would be helpful. I think other than that issue this PR is good to merge though.
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.
I mean for the globbing issue. Is this related to the bazel version?
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.
No I think it may have been a path error on my part i think. It works now.
Signed-off-by: Sacha Refshauge <[email protected]>
Solved the issue with the macros in #ifdef _MSC_VER
#define EXPAND( x ) x
#define LOG_GRAPH(...) EXPAND(GET_MACRO(__VA_ARGS__, LOG_GRAPH_OWN, LOG_GRAPH_GLOBAL)(__VA_ARGS__))
#define LOG_DEBUG(...) EXPAND(GET_MACRO(__VA_ARGS__, LOG_DEBUG_OWN, LOG_DEBUG_GLOBAL)(__VA_ARGS__))
#define LOG_INFO(...) EXPAND(GET_MACRO(__VA_ARGS__, LOG_INFO_OWN, LOG_INFO_GLOBAL)(__VA_ARGS__))
#define LOG_WARNING(...) EXPAND(GET_MACRO(__VA_ARGS__, LOG_WARNING_OWN, LOG_WARNING_GLOBAL)(__VA_ARGS__))
#define LOG_ERROR(...) EXPAND(GET_MACRO(__VA_ARGS__, LOG_ERROR_OWN, LOG_ERROR_GLOBAL)(__VA_ARGS__))
#define LOG_INTERNAL_ERROR(...) EXPAND(GET_MACRO(__VA_ARGS__, LOG_INTERNAL_ERROR_OWN, LOG_INTERNAL_ERROR_GLOBAL)(__VA_ARGS__))
#else
#define LOG_GRAPH(...) GET_MACRO(__VA_ARGS__, LOG_GRAPH_OWN, LOG_GRAPH_GLOBAL)(__VA_ARGS__)
#define LOG_DEBUG(...) GET_MACRO(__VA_ARGS__, LOG_DEBUG_OWN, LOG_DEBUG_GLOBAL)(__VA_ARGS__)
#define LOG_INFO(...) GET_MACRO(__VA_ARGS__, LOG_INFO_OWN, LOG_INFO_GLOBAL)(__VA_ARGS__)
#define LOG_WARNING(...) GET_MACRO(__VA_ARGS__, LOG_WARNING_OWN, LOG_WARNING_GLOBAL)(__VA_ARGS__)
#define LOG_ERROR(...) GET_MACRO(__VA_ARGS__, LOG_ERROR_OWN, LOG_ERROR_GLOBAL)(__VA_ARGS__)
#define LOG_INTERNAL_ERROR(...) GET_MACRO(__VA_ARGS__, LOG_INTERNAL_ERROR_OWN, LOG_INTERNAL_ERROR_GLOBAL)(__VA_ARGS__)
#endif |
Signed-off-by: Sacha Refshauge <[email protected]>
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.
Awesome looks like everything is compiling, Should be good to merge! Thanks for sticking with it.
Description
As part of Windows compatibility, a simple replacement for the two unistd functions is provided.
Also add in a missing export that is necessary on Windows.
Type of change
Checklist:
make html
in docsrc)