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"),
],
)
加一行,新代码: 文章来源:https://www.toymoban.com/news/detail-511402.html
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'], 文章来源地址https://www.toymoban.com/news/detail-511402.html
到了这里,关于Pytorch unsupported Microsoft Visual Studio version! Only the versions between 2017 and 2019的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!