pytorch
c66847af - Add workaround for nvcc header dependecies bug (#62550)

Commit
3 years ago
Add workaround for nvcc header dependecies bug (#62550) Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/62550 I noticed that running the build twice in a row resulted in ~80 CUDA files being rebuilt. Running `ninja -d explain` shows ``` ninja explain: TH/generic/THStorage.h is dirty ninja explain: TH/generic/THStorageCopy.h is dirty ninja explain: THC/generic/THCStorage.h is dirty ninja explain: THC/generic/THCStorageCopy.h is dirty ninja explain: TH/generic/THTensor.h is dirty ninja explain: THC/generic/THCTensor.h is dirty ninja explain: THC/generic/THCTensorCopy.h is dirty ninja explain: THC/generic/THCTensorMath.h is dirty ninja explain: THC/generic/THCTensorMathMagma.h is dirty ninja explain: THC/generic/THCTensorMathPairwise.h is dirty ninja explain: THC/generic/THCTensorScatterGather.h is dirty ``` considering `ninja` is working relative to the `build` folder, these files don't actually exist. I traced this back to the output of `nvcc -MD` containing paths relative to the include directory, instead of being absolute. This adds a little script to launch the compiler then resolve any relative paths in the `.d` file before `ninja` looks at it. To use it, I run the build with ``` export CMAKE_CUDA_COMPILER_LAUNCHER="python;`pwd`/tools/nvcc_fix_deps.py;ccache" ``` There are some possible pit-falls here. The same relative path might work for two include directories, and the compiler could pick a different one. Or, the compiler might have additional implicit include directories that are needed to resolve the path. However, this has worked perfectly in my testing and it's completely opt-in so should be fine. Test Plan: Imported from OSS Reviewed By: ejguan Differential Revision: D31503351 Pulled By: malfet fbshipit-source-id: b184c4526679d976b93829b5715cafcb1c7db2ae
Author
Parents
Loading