sp-uhh / sgmse

Score-based Generative Models (Diffusion Models) for Speech Enhancement and Dereverberation
MIT License
454 stars 69 forks source link

The required environment for C++ #5

Closed lxrswdd closed 7 months ago

lxrswdd commented 2 years ago

Hi It appears that the model requires a C++ compiler to run. I have VS2019 on my computer but still encounter foloowing problem. I am running the codes on a Windows system. Is there any suggestion? Thanks

E:\Anaconda\lib\site-packages\torch\utils\cpp_extension.py:346: UserWarning: Error checking compiler version for cl: [WinError 2] 系统找不到指定的文件。
  warnings.warn(f'Error checking compiler version for {compiler}: {error}')
信息: 用提供的模式无法找到文件。
Traceback (most recent call last):
  File "D:\A\Pycodes\Speech enhancement and derverberation with diffusion-based generative models\sgmse-main\enhancement.py", line 10, in <module>
    from sgmse.model import ScoreModel
  File "D:\A\Pycodes\Speech enhancement and derverberation with diffusion-based generative models\sgmse-main\sgmse\model.py", line 11, in <module>
    from sgmse.backbones import BackboneRegistry
  File "D:\A\Pycodes\Speech enhancement and derverberation with diffusion-based generative models\sgmse-main\sgmse\backbones\__init__.py", line 2, in <module>
    from .ncsnpp import NCSNpp
  File "D:\A\Pycodes\Speech enhancement and derverberation with diffusion-based generative models\sgmse-main\sgmse\backbones\ncsnpp.py", line 18, in <module>
    from .ncsnpp_utils import layers, layerspp, normalization
  File "D:\A\Pycodes\Speech enhancement and derverberation with diffusion-based generative models\sgmse-main\sgmse\backbones\ncsnpp_utils\layerspp.py", line 20, in <module>
    from . import up_or_down_sampling
  File "D:\A\Pycodes\Speech enhancement and derverberation with diffusion-based generative models\sgmse-main\sgmse\backbones\ncsnpp_utils\up_or_down_sampling.py", line 10, in <module>
    from .op import upfirdn2d
  File "D:\A\Pycodes\Speech enhancement and derverberation with diffusion-based generative models\sgmse-main\sgmse\backbones\ncsnpp_utils\op\__init__.py", line 1, in <module>
    from .fused_act import FusedLeakyReLU, fused_leaky_relu
  File "D:\A\Pycodes\Speech enhancement and derverberation with diffusion-based generative models\sgmse-main\sgmse\backbones\ncsnpp_utils\op\fused_act.py", line 11, in <module>
    fused = load(
  File "E:\Anaconda\lib\site-packages\torch\utils\cpp_extension.py", line 1202, in load
    return _jit_compile(
  File "E:\Anaconda\lib\site-packages\torch\utils\cpp_extension.py", line 1425, in _jit_compile
    _write_ninja_file_and_build_library(
  File "E:\Anaconda\lib\site-packages\torch\utils\cpp_extension.py", line 1524, in _write_ninja_file_and_build_library
    _write_ninja_file_to_build_library(
  File "E:\Anaconda\lib\site-packages\torch\utils\cpp_extension.py", line 1963, in _write_ninja_file_to_build_library
    _write_ninja_file(
  File "E:\Anaconda\lib\site-packages\torch\utils\cpp_extension.py", line 2090, in _write_ninja_file
    cl_paths = subprocess.check_output(['where',
  File "E:\Anaconda\lib\subprocess.py", line 424, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "E:\Anaconda\lib\subprocess.py", line 528, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['where', 'cl']' returned non-zero exit status 1.
PS D:\A\Pycodes\Speech enhancement and derverberation with diffusion-based generative models\sgmse-main>
julius-richter commented 2 years ago

Hi,

this may have to do with a Python version mismatch. We used Python 3.8.

See this related issue in the original NCSN++ repo: https://github.com/yang-song/score_sde_pytorch/issues/16

lxrswdd commented 2 years ago

Hi,

this may have to do with a Python version mismatch. We used Python 3.8.

See this related issue in the original NCSN++ repo: yang-song/score_sde_pytorch#16

The problem persist after I change to Python 3.8.13 No CUDA runtime is found, using CUDA_HOME='E:\Cuda' E:\Anaconda\envs\py38\lib\site-packages\torch\utils\cpp_extension.py:346: UserWarning: Error checking compiler version for cl: [WinError 2] 系统找不到指定的文件。 warnings.warn(f'Error checking compiler version for {compiler}: {error}')

Traceback (most recent call last): File "D:\A\Pycodes\Speech enhancement and derverberation with diffusion-based generative models\sgmse-main\enhancement.py", line 10, in from sgmse.model import ScoreModel File "D:\A\Pycodes\Speech enhancement and derverberation with diffusion-based generative models\sgmse-main\sgmse\model.py", line 11, in from sgmse.backbones import BackboneRegistry File "D:\A\Pycodes\Speech enhancement and derverberation with diffusion-based generative models\sgmse-main\sgmse\backbones__init.py", line 2, in from .ncsnpp import NCSNpp File "D:\A\Pycodes\Speech enhancement and derverberation with diffusion-based generative models\sgmse-main\sgmse\backbones\ncsnpp.py", line 18, in from .ncsnpp_utils import layers, layerspp, normalization File "D:\A\Pycodes\Speech enhancement and derverberation with diffusion-based generative models\sgmse-main\sgmse\backbones\ncsnpp_utils\layerspp.py", line 20, in from . import up_or_down_sampling File "D:\A\Pycodes\Speech enhancement and derverberation with diffusion-based generative models\sgmse-main\sgmse\backbones\ncsnpp_utils\up_or_down_sampling.py", line 10, in from .op import upfirdn2d File "D:\A\Pycodes\Speech enhancement and derverberation with diffusion-based generative models\sgmse-main\sgmse\backbones\ncsnpp_utils\op\init__.py", line 1, in from .fused_act import FusedLeakyReLU, fused_leaky_relu File "D:\A\Pycodes\Speech enhancement and derverberation with diffusion-based generative models\sgmse-main\sgmse\backbones\ncsnpp_utils\op\fused_act.py", line 11, in fused = load( File "E:\Anaconda\envs\py38\lib\site-packages\torch\utils\cpp_extension.py", line 1202, in load return _jit_compile( File "E:\Anaconda\envs\py38\lib\site-packages\torch\utils\cpp_extension.py", line 1425, in _jit_compile _write_ninja_file_and_build_library( File "E:\Anaconda\envs\py38\lib\site-packages\torch\utils\cpp_extension.py", line 1524, in _write_ninja_file_and_build_library _write_ninja_file_to_build_library( File "E:\Anaconda\envs\py38\lib\site-packages\torch\utils\cpp_extension.py", line 1922, in _write_ninja_file_to_build_library cuda_flags = common_cflags + COMMON_NVCC_FLAGS + _get_cuda_arch_flags() File "E:\Anaconda\envs\py38\lib\site-packages\torch\utils\cpp_extension.py", line 1694, in _get_cuda_arch_flags arch_list[-1] += '+PTX' IndexError: list index out of range

julius-richter commented 2 years ago

Please check if torch.cuda.is_available() is True.

The arch_list is supposed to be constructed with discovered architectures with torch.cuda.get_device_capability(i)

See: https://github.com/pytorch/pytorch/blob/master/torch/utils/cpp_extension.py#L1760

The problem is that if torch.cuda.device_count() function returns 0, no CUDA card is detected, and thus no architecture is added to this list.

lxrswdd commented 2 years ago

subprocess.CalledProcessError: Command '['where', 'cl']' returned non-zero exit status 1.

The thing is , i have reinstalled the pytorch and CUDA in the python 3.8 environment. This C++ error comes up again. torch.cuda.is_available() is True and cuda device available is 1

cobalamin commented 2 years ago

It's unclear to me what the error you're experiencing is at the moment. Is it the one with where cl returning nonzero exit status, or the one in your previous post with the arch_list[-1] access being out of range? They're two different errors, no?

The where cl issue seems to be a problem with Windows itself not being set up to have cl available. You may find a solution in this issue: https://github.com/HRNet/HRNet-Semantic-Segmentation/issues/39

fakufaku commented 1 year ago

The NCSN++ model has some sub-modules that need to be compiled. They are dynamically compiled the first time you call the module, but you need to have a C++ compiler and CUDA's nvcc installed. For me it worked with python 3.10, so I don't think the version is so important.

Addalin commented 1 year ago

@fakufaku, thanks for your comment. What cuda, cudnn, and PyTorch versions are used with Python 3.10 to make NCSN++ work? What cpp compiler are you using? tnx

fakufaku commented 1 year ago

@Addalin I have gcc. I think it should be version 5 or higher. Here is the one I actually have installed.

$ gcc --version
gcc (GCC) 8.3.1 20190311 (Red Hat 8.3.1-3)
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.