Build pytorch 1.8 failure on Windows with cuda 11.2.2

Error message:

C:/Users/xq114/AppData/Local/.xmake/cache/packages/2103/l/libtorch/v1.8.0/source/libtorch/aten/src/ATen/native/cuda/AdaptiveAveragePooling.cu(69): error : calling a __host__ function("__floorf") from a __global__ function("at::native::_NV_ANON_NAMESPACE::adaptive_average_pool<double> ") is not allowed [C:\Users\xq114\AppData\Local\.xmake\cache\packages\2103\l\libtorch\v1.8.0\source\libtorch\build_D45C6846\caffe2\torch_cuda.vcxproj]

It repeated for many times. The corresponding line reads

#define START_IND(a,b,c) (int)std::floor((float)(a * c) / b)

It seems that calling std::floor from a cuda kernel function is forbidden. Is there anyone who can help me with this? Thanks!

This might be related to this issue, which is caused by a VS regression. You could use the mentioned workarounds from the issue.