pytorch StyleGan 3错误:加载C++扩展需要Ninja

djmepvbi  于 12个月前  发布在  其他
关注(0)|答案(3)|浏览(311)

我正在尝试运行StyleGan 3代码,但我一直得到这个错误:
第一个月
我pip安装了Ninja并获得了1.10.2.3版本,我在windows 10上,所以我使用这些说明安装,构建和运行docker:https://hangzhang.org/PyTorch-Encoding/notes/compile.html#using-docker
这是我得到的完整追溯:

Generating image for seed 2 (0/1) ...
Setting up PyTorch plugin "bias_act_plugin"... Failed!
Traceback (most recent call last):
  File "D:\Python\stylegan3\stylegan3-main\gen_images.py", line 143, in <module>
    generate_images() # pylint: disable=no-value-for-parameter
  File "C:\Users\a\AppData\Local\Programs\Python\Python39\lib\site-packages\click\core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "C:\Users\a\AppData\Local\Programs\Python\Python39\lib\site-packages\click\core.py", line 782, in main
    rv = self.invoke(ctx)
  File "C:\Users\a\AppData\Local\Programs\Python\Python39\lib\site-packages\click\core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Users\aAppData\Local\Programs\Python\Python39\lib\site-packages\click\core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "D:\Python\stylegan3\stylegan3-main\gen_images.py", line 135, in generate_images
    img = G(z, label, truncation_psi=truncation_psi, noise_mode=noise_mode)
  File "C:\Users\a\AppData\Local\Programs\Python\Python39\lib\site-packages\torch\nn\modules\module.py", line 727, in _call_impl
    result = self.forward(*input, **kwargs)
  File "<string>", line 503, in forward
  File "C:\Users\a\AppData\Local\Programs\Python\Python39\lib\site-packages\torch\nn\modules\module.py", line 727, in _call_impl
    result = self.forward(*input, **kwargs)
  File "<string>", line 143, in forward
  File "C:\Users\a\AppData\Local\Programs\Python\Python39\lib\site-packages\torch\nn\modules\module.py", line 727, in _call_impl
    result = self.forward(*input, **kwargs)
  File "<string>", line 92, in forward
  File "D:\Python\stylegan3\stylegan3-main\torch_utils\ops\bias_act.py", line 84, in bias_act
    if impl == 'cuda' and x.device.type == 'cuda' and _init():
  File "D:\Python\stylegan3\stylegan3-main\torch_utils\ops\bias_act.py", line 41, in _init
    _plugin = custom_ops.get_plugin(
  File "D:\Python\stylegan3\stylegan3-main\torch_utils\custom_ops.py", line 136, in get_plugin
    torch.utils.cpp_extension.load(name=module_name, build_directory=cached_build_dir,
  File "C:\Users\a\AppData\Local\Programs\Python\Python39\lib\site-packages\torch\utils\cpp_extension.py", line 986, in load
    return _jit_compile(
  File "C:\Users\a\AppData\Local\Programs\Python\Python39\lib\site-packages\torch\utils\cpp_extension.py", line 1193, in _jit_compile
    _write_ninja_file_and_build_library(
  File "C:\Users\a\AppData\Local\Programs\Python\Python39\lib\site-packages\torch\utils\cpp_extension.py", line 1268, in _write_ninja_file_and_build_library
    verify_ninja_availability()
  File "C:\Users\a\AppData\Local\Programs\Python\Python39\lib\site-packages\torch\utils\cpp_extension.py", line 1323, in verify_ninja_availability
    raise RuntimeError("Ninja is required to load C++ extensions")
RuntimeError: Ninja is required to load C++ extensions```

字符串

tct7dpnv

tct7dpnv1#

添加此选项可能会解决您的问题

sudo apt-get install ninja-build

字符串

vmdwslir

vmdwslir2#

您可以通过their github在Windows上获得ninja-build,它是ninja-win.zip。根据您安装的位置,您可能需要将其添加到Windows PATH。
编辑:这里有关于建造的说明

abithluo

abithluo3#

我也遇到了同样的问题,我通过安装Ninja with pip解决了这个问题:

pip install ninja

字符串
我也劝你注意这个issues

相关问题