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'], 

你可能感兴趣的:(深度学习,windows,深度学习,pytorch)