• stylegan3相关代码报错解决


    前言
    我认为所有运行报错的相关问题都能在stylegan3的github库的issues中找到答案,我遇到的问题以及解决办法也都是参考自里面
    1、RuntimeError: Could not find MSVC/GCC/CLANG

    相关issue:Training on Win10, RuntimeError: Could not find MSVC/GCC/CLANG

    其实就是未安装C++编译器。
    在windows环境下需要安装visual studio。
    安装很简单,去官网下载社区版就行。如果你平时也不用visual studio,只需要安装c++相关工具就行。(不过还是得吐槽一下,为了使用C++编译器,需要下载2个多G的IDE,真是浪费空间)
    在这里插入图片描述
    需要注意的是,如果你安装的vs是2017版以上,还需要在代码中修改路径。

    找到torch_utils/custom_ops.py文件

    def _find_compiler_bindir():
        patterns = [
             'C:/Program Files (x86)/Microsoft Visual Studio/*/Professional/VC/Tools/MSVC/*/bin/Hostx64/x64',
             'C:/Program Files (x86)/Microsoft Visual Studio/*/BuildTools/VC/Tools/MSVC/*/bin/Hostx64/x64',
             'C:/Program Files (x86)/Microsoft Visual Studio/*/Community/VC/Tools/MSVC/*/bin/Hostx64/x64',
             'C:/Program Files (x86)/Microsoft Visual Studio */vc/bin',
        ]
        for pattern in patterns:
            matches = sorted(glob.glob(pattern))
            if len(matches):
                return matches[-1]
        return None
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12

    将路径修改为你的bin路径
    比如我的修改:

    def _find_compiler_bindir():
        patterns = [
            r'C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.32.31326\bin\Hostx64\x64',
        ]
        for pattern in patterns:
            matches = sorted(glob.glob(pattern))
            if len(matches):
                return matches[-1]
        return None
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9

    2、ninja: build stopped: subcommand failed.

    相关issue:ninja: build stopped: subcommand failed.

    首先确保你已经安装了ninja库,如果没有,使用pip安装:

    pip install ninja
    
    • 1

    如果安装了还出现问题,那就是c++编译器版本过低造成(貌似版本必须>7),比如vs2017就会出现此问题

    解决办法:升级vs,安装方法见上一条

  • 相关阅读:
    前端周刊第八期
    C语言模拟最简单的计算机
    Spring(五):Spring Boot 的配置和日志
    【职场成长】一篇文章,讲清复盘!
    spring cloud rebuild project z
    SpringSecurity之UserDetailsService详解
    Pull down实验步骤
    在线PDF查看器和PDF编辑器:GrapeCity Documents PDF (GcPdf)
    函数式编程基本语法
    AWS SAA-C03 #217
  • 原文地址:https://blog.csdn.net/corruptwww/article/details/125454641