Get windows build working by bharrisau · Pull Request #1711 · pytorch/TensorRT (original) (raw)
Description
Initial PR for #1563. Fixes Windows CMAKE build.
Finally had time to come back to this - build on a fresh Windows11 machine, all steps to setup/reproduce included.
The change to core/plugins/CMakeLists.txt seems like it should be unrelated to this. I was unable to build because 'cudnn.h' was required, but the include path was not being passed to the compiler as the cuDNN module wasn't specified. This might not be a problem in other targets because commonly the cudnn files are just installed in to the cuda include/lib/bin dirs.
Also note - windows is generally case insensitive. The normal output dir is build/ but that doesn't work on Windows as there is a BUILD file. So I'm using out/ as the output. But that isn't in the .gitignore, and I haven't included a change for that in this PR.
Type of change
- Bug fix (incomplete and probably breaks other build targets)
- This change requires a documentation update
Notes to reproduce with Visual Studio Code (I didn't want to pull down the whole Visual Studio)
- Install Visual Studio Code
- Install Build Tools for Visual Studio 2022
- Select "Desktop Development with C++"
* Currently, this installs MSVC v143 - 2022. There are also options to install previous 2019/2017/2015 editions of MSVC - License term "1b Build Tools additional use right" allows using Build Tools to compile Open Source Dependencies
- Also allows using Build Tools to develop and test Open Source Dependencies, to the minor extend of ensuring compatibility with Build Tools
- Select "Desktop Development with C++"
- Install CUDA 11.7.1
- Install CuDNN 8.5.0.96
- Set
cuDNN_ROOT_DIR
- Set
- Install TensorRT 8.5.1.7
- Set
TensorRT_ROOT - Add
TensorRT_ROOT\libto PATH
- Set
- Install "libtorch-win-shared-with-deps-latest.zip"
- Select the CUDA 11.7 version
- Set
Torch_DIR - Add
Torch_DIR\libto PATH
- Clone TensorRT repo
- Install C++ and CMake Tools extensions from MS
- Change build to RelWithDebInfo
- Update
.vscode\settings.json - Clean, configure, build
/.vscode/settings.json
{ "cmake.generator": "Ninja", "cmake.configureSettings": { "CMAKE_MODULE_PATH": { "type": "FILEPATH", "value": "$PWD\cmake\Modules" }, "CMAKE_CXX_FLAGS": { "type": "STRING", "value": "-D_SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING" }, "Torch_DIR": { "type": "FILEPATH", "value": "X:\libtorch\share\cmake\Torch" }, "TensorRT_ROOT": { "type": "FILEPATH", "value": "X:\path\to\tensorrt" }, "cuDNN_ROOT_DIR": { "type": "FILEPATH", "value": "X:\path\to\cudnn" }, "CMAKE_CUDA_FLAGS": "-allow-unsupported-compiler" }, "cmake.buildDirectory": "${workspaceFolder}/out" }