Pytorch unsupported Microsoft Visual Studio version! Only the versions between 2017 and 2019

Windows 下 Pytorch需要编译cpp文件,出现如下错误:

fatal error C1189: #error:  -- unsupported Microsoft Visual Studio version! Only the versions between 2017 and 2019 (inclusive) are supported! The nvcc flag '-allow-unsupported-compiler' can be used to override this version check

我安装的VS2022,那么需要重新安装VS2019么?

其实不需要,正如上面提示,编译时加个参数即可。

 旧代码:

upfirdn2d_op = load(
    "upfirdn2d",
    sources=[
        os.path.join(module_path, "upfirdn2d.cpp"),
        os.path.join(module_path, "upfirdn2d_kernel.cu"),
    ],
)

加一行,新代码: 

upfirdn2d_op = load(
    "upfirdn2d",
    sources=[
        os.path.join(module_path, "upfirdn2d.cpp"),
        os.path.join(module_path, "upfirdn2d_kernel.cu"),
    ],
    extra_cuda_cflags=['-allow-unsupported-compiler'],
)

也就是加上一行:   extra_cuda_cflags=['-allow-unsupported-compiler'], 

猜你喜欢

转载自blog.csdn.net/makao007/article/details/127643583