parlance / ctcdecode

PyTorch CTC Decoder bindings
MIT License
829 stars 245 forks source link

Installaion Fail - 'Error compiling objects for extension' #165

Open avramandrei opened 4 years ago

avramandrei commented 4 years ago

Hello,

I am trying to install ctcdecode in a docker environment with PyTorch 1.5.1 and Cuda 10.1 in it.

This is the Dockerfile:

FROM pytorch/pytorch:1.5.1-cuda10.1-cudnn7-devel

# install basics
RUN apt-get update -y
RUN apt-get install -y git curl ca-certificates bzip2 cmake tree htop bmon iotop sox libsox-dev libsox-fmt-all vim

# install ctcdecode
RUN git clone --recursive https://github.com/parlance/ctcdecode.git
RUN cd ctcdecode && pip install .

and this is the error I get:

ninja: build stopped: subcommand failed.
    Traceback (most recent call last):
      File "/opt/conda/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 1423, in _run_ninja_build
        check=True)
      File "/opt/conda/lib/python3.7/subprocess.py", line 512, in run
        output=stdout, stderr=stderr)
    subprocess.CalledProcessError: Command '['ninja', '-v']' returned non-zero exit status 1.

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-req-build-zav02cia/setup.py", line 55, in <module>
        cmdclass={'build_ext': BuildExtension}
      File "/opt/conda/lib/python3.7/site-packages/setuptools/__init__.py", line 144, in setup
        return distutils.core.setup(**attrs)
      File "/opt/conda/lib/python3.7/distutils/core.py", line 148, in setup
        dist.run_commands()
      File "/opt/conda/lib/python3.7/distutils/dist.py", line 966, in run_commands
        self.run_command(cmd)
      File "/opt/conda/lib/python3.7/distutils/dist.py", line 985, in run_command
        cmd_obj.run()
      File "/opt/conda/lib/python3.7/site-packages/setuptools/command/install.py", line 61, in run
        return orig.install.run(self)
      File "/opt/conda/lib/python3.7/distutils/command/install.py", line 545, in run
        self.run_command('build')
      File "/opt/conda/lib/python3.7/distutils/cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "/opt/conda/lib/python3.7/distutils/dist.py", line 985, in run_command
        cmd_obj.run()
      File "/opt/conda/lib/python3.7/distutils/command/build.py", line 135, in run
        self.run_command(cmd_name)
      File "/opt/conda/lib/python3.7/distutils/cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "/opt/conda/lib/python3.7/distutils/dist.py", line 985, in run_command
        cmd_obj.run()
      File "/opt/conda/lib/python3.7/site-packages/setuptools/command/build_ext.py", line 87, in run
        _build_ext.run(self)
      File "/opt/conda/lib/python3.7/distutils/command/build_ext.py", line 340, in run
        self.build_extensions()
      File "/opt/conda/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 603, in build_extensions
        build_ext.build_extensions(self)
      File "/opt/conda/lib/python3.7/distutils/command/build_ext.py", line 449, in build_extensions
        self._build_extensions_serial()
      File "/opt/conda/lib/python3.7/distutils/command/build_ext.py", line 474, in _build_extensions_serial
        self.build_extension(ext)
      File "/opt/conda/lib/python3.7/site-packages/setuptools/command/build_ext.py", line 208, in build_extension
        _build_ext.build_extension(self, ext)
      File "/opt/conda/lib/python3.7/distutils/command/build_ext.py", line 534, in build_extension
        depends=ext.depends)
      File "/opt/conda/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 437, in unix_wrap_ninja_compile
        with_cuda=with_cuda)
      File "/opt/conda/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 1163, in _write_ninja_file_and_compile_objects
        error_prefix='Error compiling objects for extension')
      File "/opt/conda/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 1436, in _run_ninja_build
        raise RuntimeError(message)
    RuntimeError: Error compiling objects for extension

Any ideas why the build fails?

Thank you, Andrei

SeanNaren commented 4 years ago

thanks for the report! will try to track down what's going on here...

SeanNaren commented 4 years ago

Ties to https://github.com/SeanNaren/deepspeech.pytorch/issues/574

Elizabeth65 commented 3 years ago

Hi, I used to have the similar problem but eventually find a solution that works for me, hopefully it is useful for others.

I used ubuntu in a virtual machine. Then I installed these packages in conda virtual environment.

  1. python 3.6 (conda create -n myproject python=3.6)
  2. pytorch 1.0.0 (use conda command : conda install pytorch==1.0.0 torchvision==0.2.1 cuda100 -c pytorch)
  3. sudo apt install build-essential , this install packages such as gcc, g++ and make

We can check whether g++ and gcc are installed properly using g++ --version and gcc --version command

With these, the compiling is working fine hopefully. Cheers!

CracKCatZ commented 3 years ago

Hey @Elizabeth65 is there any pip installation repo for build-essential?