Skip to content
This repository was archived by the owner on Oct 31, 2023. It is now read-only.

RuntimeError: Error compiling objects for extension #1236

Closed
akiyamakodai opened this issue Apr 30, 2020 · 26 comments
Closed

RuntimeError: Error compiling objects for extension #1236

akiyamakodai opened this issue Apr 30, 2020 · 26 comments

Comments

@akiyamakodai
Copy link

%%writefile setup.sh

maskrcnn_benchmark and coco api dependencies

pip install ninja yacs cython matplotlib tqdm opencv-python cityscapesscripts

follow PyTorch installation in https://pytorch.org/get-started/locally/

we give the instructions for CUDA 9.0

pip install -c pytorch pytorch-nightly torchvision cudatoolkit=9.0

git clone https://github.com/cocodataset/cocoapi.git
cd cocoapi/PythonAPI
python setup.py build_ext install
cd ../../

install apex

rm -rf apex
git clone https://github.com/NVIDIA/apex.git
cd apex
git pull
python setup.py install --cuda_ext --cpp_ext
cd ../

install PyTorch Detection

git clone https://github.com/facebookresearch/maskrcnn-benchmark.git
cd maskrcnn-benchmark

the following will install the lib with

symbolic links, so that you can modify

the files if you want and won't need to

re-build it

python setup.py build develop


!sh setup.sh


RuntimeError: Error compiling objects for extension


When I execute the above command, I get an error. why.
running on google colab

@gerald0057
Copy link

I have the same problem. Please let me know if you can solve it. Thank you

@gerald0057
Copy link

is there any updates?

@gerald0057
Copy link

6 errors detected in the compilation of "/tmp/tmpxft_00009924_00000000-6_deform_conv_cuda.cpp1.ii".
ninja: build stopped: subcommand failed.
Traceback (most recent call last):
File "/home/gerald/miniconda3/envs/maskrcnn_benchmark/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 1395, in _run_ninja_build
subprocess.run(
File "/home/gerald/miniconda3/envs/maskrcnn_benchmark/lib/python3.8/subprocess.py", line 512, in run
raise CalledProcessError(retcode, process.args,
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 "setup.py", line 59, in
setup(
File "/home/gerald/miniconda3/envs/maskrcnn_benchmark/lib/python3.8/site-packages/setuptools/init.py", line 144, in setup
return distutils.core.setup(**attrs)
File "/home/gerald/miniconda3/envs/maskrcnn_benchmark/lib/python3.8/distutils/core.py", line 148, in setup
dist.run_commands()
File "/home/gerald/miniconda3/envs/maskrcnn_benchmark/lib/python3.8/distutils/dist.py", line 966, in run_commands
self.run_command(cmd)
File "/home/gerald/miniconda3/envs/maskrcnn_benchmark/lib/python3.8/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/home/gerald/miniconda3/envs/maskrcnn_benchmark/lib/python3.8/distutils/command/build.py", line 135, in run
self.run_command(cmd_name)
File "/home/gerald/miniconda3/envs/maskrcnn_benchmark/lib/python3.8/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/home/gerald/miniconda3/envs/maskrcnn_benchmark/lib/python3.8/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/home/gerald/miniconda3/envs/maskrcnn_benchmark/lib/python3.8/site-packages/setuptools/command/build_ext.py", line 87, in run
_build_ext.run(self)
File "/home/gerald/miniconda3/envs/maskrcnn_benchmark/lib/python3.8/site-packages/Cython/Distutils/old_build_ext.py", line 186, in run
_build_ext.build_ext.run(self)
File "/home/gerald/miniconda3/envs/maskrcnn_benchmark/lib/python3.8/distutils/command/build_ext.py", line 340, in run
self.build_extensions()
File "/home/gerald/miniconda3/envs/maskrcnn_benchmark/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 580, in build_extensions
build_ext.build_extensions(self)
File "/home/gerald/miniconda3/envs/maskrcnn_benchmark/lib/python3.8/site-packages/Cython/Distutils/old_build_ext.py", line 195, in build_extensions
_build_ext.build_ext.build_extensions(self)
File "/home/gerald/miniconda3/envs/maskrcnn_benchmark/lib/python3.8/distutils/command/build_ext.py", line 449, in build_extensions
self._build_extensions_serial()
File "/home/gerald/miniconda3/envs/maskrcnn_benchmark/lib/python3.8/distutils/command/build_ext.py", line 474, in _build_extensions_serial
self.build_extension(ext)
File "/home/gerald/miniconda3/envs/maskrcnn_benchmark/lib/python3.8/site-packages/setuptools/command/build_ext.py", line 208, in build_extension
_build_ext.build_extension(self, ext)
File "/home/gerald/miniconda3/envs/maskrcnn_benchmark/lib/python3.8/distutils/command/build_ext.py", line 528, in build_extension
objects = self.compiler.compile(sources,
File "/home/gerald/miniconda3/envs/maskrcnn_benchmark/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 414, in unix_wrap_ninja_compile
_write_ninja_file_and_compile_objects(
File "/home/gerald/miniconda3/envs/maskrcnn_benchmark/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 1135, in _write_ninja_file_and_compile_objects
_run_ninja_build(
File "/home/gerald/miniconda3/envs/maskrcnn_benchmark/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 1413, in _run_ninja_build
raise RuntimeError(message)
RuntimeError: Error compiling objects for extension

@akiyamakodai
Copy link
Author

I solved it.
Please check pytorch version, it can may go well.

@gerald0057
Copy link

thank you very much!

@sabine1993
Copy link

hey, I have the same problem but I cant figure out how i can change my pytorch version to the correct version. I have the following Version

Python 3.8.2 (default, May 6 2020, 09:02:42) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.

import torch
print(torch.version)
1.6.0.dev20200514

and i have the cuda driver 10.2

Can you please help me to solve the problem.
Thanks a lot in advance

@gerald0057
Copy link

i finally chose Detectron2 and the installation (ubuntu20 cuda 10.2 pytorch 1.5stable) is very easy

@vanessasidrim
Copy link

I have the same problem.

I use:

  • Ubuntu 18.04
  • GCC 7.5
  • CUDA 10.1
  • Pytorch 1.5

I tried other versions of Pytorch, Cuda, GCC and Ubuntu. But the error remains.

Can you help me?!
Thanks.

@akiyamakodai
Copy link
Author

akiyamakodai commented May 20, 2020

I use :
pytorch 1.4
torchvision 0.5.0
cuda 10.1

I was able to run the program.

@amsword
Copy link

amsword commented May 23, 2020

i was able to compile it with pytorch 1.4, but fails with teh same error on pytorch 1.5

@vanessasidrim
Copy link

vanessasidrim commented May 23, 2020

In my case it worked when using version 0.5.0 of torchvision that comes with pytorch 1.4. In version 1.5 of pytorch the default torchdivion is version 0.6.0.

When using torchdivion 0.6.0 the same error occurs.

@ebrahim31
Copy link

The current release works in windows 10 if you have torch==1.4.0 and torchvision ==0.5.0.

@navidre
Copy link

navidre commented Jul 14, 2020

Works with PyTorch 1.4.0 and torchvision 0.5.0 for me. Not PyTorch 1.5.1 and torchvision 0.6.1!

@HaiyiMei
Copy link

Thank you guys!

  • Ubuntu 18.04
  • GCC 7.5
  • CUDA 10.1
  • Pytorch 1.4.0
  • torchvision 0.5.0
  • apex 0.1.0

This works perfectly well.

@floschne
Copy link

@HaiyiMei same for me! pyTorch 1.4.0 and torchvision 0.5.0 seems to be the only working version combination with CUDA 10.1

@jetleg
Copy link

jetleg commented Apr 20, 2021

Thanks for answering! I failed when I used torch.version=1.8.1 and torchvision.version=0.9.x, after I degraded my torch version to 1.5.0 it still failed. Only when I degraded my torch to 1.4.0 and torchvision to 0.5.0(at the same time I degrade my cuda to 10.1), I successfully compile 'python setup.py build develop'

@oh-livia
Copy link

I have torch=1.4.0, torchvision=0.5.0, and cuda=10.1 and I am still getting this error :(

@MitraTj
Copy link

MitraTj commented May 1, 2021

I use:
python 3.8
pytorch '1.7.1.post2'
torchvision 0.10.0a0+730c5e1
Cuda 9

and I am still getting this error :(

@tiankx2020
Copy link

I hava this save problem

@DbrRoxane
Copy link

I followed the instruction there and solved this issue by typing

cuda_dir="maskrcnn_benchmark/csrc/cuda"
perl -i -pe 's/AT_CHECK/TORCH_CHECK/' $cuda_dir/deform_pool_cuda.cu $cuda_dir/deform_conv_cuda.cu
# You can then run the regular setup command
python3 setup.py build develop

Now it works with CUDA 11.0 and Pytorch 1.7

Hope it helps!

@Seal1026
Copy link

Seal1026 commented Sep 6, 2021

I followed the instruction there and solved this issue by typing

cuda_dir="maskrcnn_benchmark/csrc/cuda"
perl -i -pe 's/AT_CHECK/TORCH_CHECK/' $cuda_dir/deform_pool_cuda.cu $cuda_dir/deform_conv_cuda.cu
# You can then run the regular setup command
python3 setup.py build develop

Now it works with CUDA 11.0 and Pytorch 1.7

Hope it helps!

Thanks!!!!! it even works with PyTorch 1.9

@ashok-arjun
Copy link

Thank you guys!

  • Ubuntu 18.04
  • GCC 7.5
  • CUDA 10.1
  • Pytorch 1.4.0
  • torchvision 0.5.0
  • apex 0.1.0

This works perfectly well.

It's also important to add the python version. This only works for Python 1.6 for me - doesn't work for 1.7/1.8/1.9.
For later versions of python, one would need CUDA 11 and PyTorch 1.7 / 1.9

@ojoaobrito
Copy link

ojoaobrito commented Sep 28, 2021

I followed the instruction there and solved this issue by typing

cuda_dir="maskrcnn_benchmark/csrc/cuda"
perl -i -pe 's/AT_CHECK/TORCH_CHECK/' $cuda_dir/deform_pool_cuda.cu $cuda_dir/deform_conv_cuda.cu
# You can then run the regular setup command
python3 setup.py build develop

Now it works with CUDA 11.0 and Pytorch 1.7

Hope it helps!

You are a legend! Many thanks!

@tan199954
Copy link

I followed the instruction there and solved this issue by typing

cuda_dir="maskrcnn_benchmark/csrc/cuda"
perl -i -pe 's/AT_CHECK/TORCH_CHECK/' $cuda_dir/deform_pool_cuda.cu $cuda_dir/deform_conv_cuda.cu
# You can then run the regular setup command
python3 setup.py build develop

Now it works with CUDA 11.0 and Pytorch 1.7

Hope it helps!

it not works in my googlecolab huhu
CUDA 10.1, Pytorch 1.7.1

@itzhuang
Copy link

itzhuang commented Mar 1, 2022

I followed the instruction there and solved this issue by typing

cuda_dir="maskrcnn_benchmark/csrc/cuda"
perl -i -pe 's/AT_CHECK/TORCH_CHECK/' $cuda_dir/deform_pool_cuda.cu $cuda_dir/deform_conv_cuda.cu
# You can then run the regular setup command
python3 setup.py build develop

Now it works with CUDA 11.0 and Pytorch 1.7

Hope it helps!

Awesome! Thank you!

@Stevenhani10
Copy link

still have the same error
File "C:\Users\steve.conda\envs\deformable_detr\lib\site-packages\torch\utils\cpp_extension.py", line 1436, in _run_ninja_build
raise RuntimeError(message)
RuntimeError: Error compiling objects for extension

Any help?
thanks in advance

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests