TernausNetV2 icon indicating copy to clipboard operation
TernausNetV2 copied to clipboard

RuntimeError: Error building extension 'inplace_abn'

Open zhizhang77 opened this issue 6 years ago • 3 comments

Anyone happen to encounter the same problem? My envrionment: Ubuntu 16.04 Torch 1.0 ninja 1.8.2.post2 cuda 9.2

RuntimeError: Error building extension 'inplace_abn': [1/3] c++ -MMD -MF inplace_abn_cpu.o.d -DTORCH_EXTENSION_NAME=inplace_abn -DTORCH_API_INCLUDE_EXTENSION_H -isystem /usr/local/lib/python3.5/dist-packages/torch/lib/include -isystem /usr/local/lib/python3.5/dist-packages/torch/lib/include/torch/csrc/api/include -isystem /usr/local/lib/python3.5/dist-packages/torch/lib/include/TH -isystem /usr/local/lib/python3.5/dist-packages/torch/lib/include/THC -isystem /usr/local/cuda/include -isystem /usr/include/python3.5m -D_GLIBCXX_USE_CXX11_ABI=0 -fPIC -std=c++11 -O3 -c /home/zhizhang77/ref_projects/TernausNetV2/modules/src/inplace_abn_cpu.cpp -o inplace_abn_cpu.o FAILED: inplace_abn_cpu.o c++ -MMD -MF inplace_abn_cpu.o.d -DTORCH_EXTENSION_NAME=inplace_abn -DTORCH_API_INCLUDE_EXTENSION_H -isystem /usr/local/lib/python3.5/dist-packages/torch/lib/include -isystem /usr/local/lib/python3.5/dist-packages/torch/lib/include/torch/csrc/api/include -isystem /usr/local/lib/python3.5/dist-packages/torch/lib/include/TH -isystem /usr/local/lib/python3.5/dist-packages/torch/lib/include/THC -isystem /usr/local/cuda/include -isystem /usr/include/python3.5m -D_GLIBCXX_USE_CXX11_ABI=0 -fPIC -std=c++11 -O3 -c /home/zhizhang77/ref_projects/TernausNetV2/modules/src/inplace_abn_cpu.cpp -o inplace_abn_cpu.o /home/zhizhang77/ref_projects/TernausNetV2/modules/src/inplace_abn_cpu.cpp: In function ‘std::vectorat::Tensor backward_cpu(at::Tensor, at::Tensor, at::Tensor, at::Tensor, at::Tensor, at::Tensor, at::Tensor, bool, float)’: /home/zhizhang77/ref_projects/TernausNetV2/modules/src/inplace_abn_cpu.cpp:82:34: error: could not convert ‘z.at::Tensor::type()’ from ‘at::Type’ to ‘c10::IntList {aka c10::ArrayRef}’ auto dweight = at::empty(z.type(), {0}); ^ /home/zhizhang77/ref_projects/TernausNetV2/modules/src/inplace_abn_cpu.cpp:83:32: error: could not convert ‘z.at::Tensor::type()’ from ‘at::Type’ to ‘c10::IntList {aka c10::ArrayRef}’ auto dbias = at::empty(z.type(), {0}); ^ /home/zhizhang77/ref_projects/TernausNetV2/modules/src/inplace_abn_cpu.cpp:89:29: error: could not convert ‘{dx, dweight, dbias}’ from ‘’ to ‘std::vectorat::Tensor’ return {dx, dweight, dbias}; ^ [2/3] /usr/local/cuda/bin/nvcc -DTORCH_EXTENSION_NAME=inplace_abn -DTORCH_API_INCLUDE_EXTENSION_H -isystem /usr/local/lib/python3.5/dist-packages/torch/lib/include -isystem /usr/local/lib/python3.5/dist-packages/torch/lib/include/torch/csrc/api/include -isystem /usr/local/lib/python3.5/dist-packages/torch/lib/include/TH -isystem /usr/local/lib/python3.5/dist-packages/torch/lib/include/THC -isystem /usr/local/cuda/include -isystem /usr/include/python3.5m -D_GLIBCXX_USE_CXX11_ABI=0 -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ --compiler-options '-fPIC' --expt-extended-lambda -std=c++11 -c /home/zhizhang77/ref_projects/TernausNetV2/modules/src/inplace_abn_cuda.cu -o inplace_abn_cuda.cuda.o FAILED: inplace_abn_cuda.cuda.o /usr/local/cuda/bin/nvcc -DTORCH_EXTENSION_NAME=inplace_abn -DTORCH_API_INCLUDE_EXTENSION_H -isystem /usr/local/lib/python3.5/dist-packages/torch/lib/include -isystem /usr/local/lib/python3.5/dist-packages/torch/lib/include/torch/csrc/api/include -isystem /usr/local/lib/python3.5/dist-packages/torch/lib/include/TH -isystem /usr/local/lib/python3.5/dist-packages/torch/lib/include/THC -isystem /usr/local/cuda/include -isystem /usr/include/python3.5m -D_GLIBCXX_USE_CXX11_ABI=0 -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ --compiler-options '-fPIC' --expt-extended-lambda -std=c++11 -c /home/zhizhang77/ref_projects/TernausNetV2/modules/src/inplace_abn_cuda.cu -o inplace_abn_cuda.cuda.o /home/zhizhang77/ref_projects/TernausNetV2/modules/src/inplace_abn_cuda.cu(99): error: no suitable user-defined conversion from "at::Type" to "c10::IntList" exists

/home/zhizhang77/ref_projects/TernausNetV2/modules/src/inplace_abn_cuda.cu(99): error: no instance of constructor "at::TensorOptions::TensorOptions" matches the argument list argument types are: (int64_t)

/home/zhizhang77/ref_projects/TernausNetV2/modules/src/inplace_abn_cuda.cu(100): error: no suitable user-defined conversion from "at::Type" to "c10::IntList" exists

/home/zhizhang77/ref_projects/TernausNetV2/modules/src/inplace_abn_cuda.cu(100): error: no instance of constructor "at::TensorOptions::TensorOptions" matches the argument list argument types are: (int64_t)

/home/zhizhang77/ref_projects/TernausNetV2/modules/src/inplace_abn_cuda.cu(202): error: no suitable user-defined conversion from "at::Type" to "c10::IntList" exists

/home/zhizhang77/ref_projects/TernausNetV2/modules/src/inplace_abn_cuda.cu(202): error: no instance of constructor "at::TensorOptions::TensorOptions" matches the argument list argument types are: (int64_t)

/home/zhizhang77/ref_projects/TernausNetV2/modules/src/inplace_abn_cuda.cu(203): error: no suitable user-defined conversion from "at::Type" to "c10::IntList" exists

/home/zhizhang77/ref_projects/TernausNetV2/modules/src/inplace_abn_cuda.cu(203): error: no instance of constructor "at::TensorOptions::TensorOptions" matches the argument list argument types are: (int64_t)

8 errors detected in the compilation of "/tmp/tmpxft_000052c0_00000000-6_inplace_abn_cuda.cpp1.ii". ninja: build stopped: subcommand failed.

zhizhang77 avatar Jan 25 '19 11:01 zhizhang77

Same error here,

Ubuntu 18.04 Torch 1.0.1 Cuda 10 Anaconda

edit: I have tried both on python 3.6 and 3.7

stefat77 avatar Feb 06 '19 14:02 stefat77

Downgrading torch to 0.4.1 solved the issue for me. README specifies 0.4 as the supported torch version.

piyush-jaiswal avatar Feb 26 '19 12:02 piyush-jaiswal

Same error here ( I have 4 errors showing)

Ubuntu: 16.04 CUDA: 9.0.176 Pytorch: 0.4.1 g++ --version: 7.3.0

/opt/anaconda3/lib/python3.6/site-packages/torch/utils/cpp_extension.py:114: UserWarning:

                       !! WARNING !!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Your compiler (c++) may be ABI-incompatible with PyTorch! Please use a compiler that is ABI-compatible with GCC 4.9 and above. See https://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html.

See https://gist.github.com/goldsborough/d466f43e8ffc948ff92de7486c5216d6 for instructions on how to install GCC 4.9 or higher. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

                      !! WARNING !!

warnings.warn(ABI_INCOMPATIBILITY_WARNING.format(compiler))

CalledProcessError Traceback (most recent call last) /opt/anaconda3/lib/python3.6/site-packages/torch/utils/cpp_extension.py in _build_extension_module(name, build_directory) 738 subprocess.check_output( --> 739 ['ninja', '-v'], stderr=subprocess.STDOUT, cwd=build_directory) 740 except subprocess.CalledProcessError:

/opt/anaconda3/lib/python3.6/subprocess.py in check_output(timeout, *popenargs, **kwargs) 355 return run(*popenargs, stdout=PIPE, timeout=timeout, check=True, --> 356 **kwargs).stdout 357

/opt/anaconda3/lib/python3.6/subprocess.py in run(input, timeout, check, *popenargs, **kwargs) 437 raise CalledProcessError(retcode, process.args, --> 438 output=stdout, stderr=stderr) 439 return CompletedProcess(process.args, retcode, stdout, stderr)

CalledProcessError: Command '['ninja', '-v']' returned non-zero exit status 1.

During handling of the above exception, another exception occurred:

RuntimeError Traceback (most recent call last) in ----> 1 from models.ternausnet2 import TernausNetV2

~/TernausNetV2/models/ternausnet2.py in 9 from torch.nn import Sequential 10 from collections import OrderedDict ---> 11 from modules.bn import ABN 12 13 from modules.wider_resnet import WiderResNet

~/TernausNetV2/modules/bn.py in 7 from queue import Queue 8 ----> 9 from .functions import (ACT_ELU, ACT_RELU, ACT_LEAKY_RELU, inplace_abn, inplace_abn_sync) 10 11

~/TernausNetV2/modules/functions.py in 16 "inplace_abn_cuda.cu" 17 ]], ---> 18 extra_cuda_cflags=["--expt-extended-lambda"]) 19 20 # Activation names

/opt/anaconda3/lib/python3.6/site-packages/torch/utils/cpp_extension.py in load(name, sources, extra_cflags, extra_cuda_cflags, extra_ldflags, extra_include_paths, build_directory, verbose, with_cuda) 492 build_directory or _get_build_directory(name, verbose), 493 verbose, --> 494 with_cuda=with_cuda) 495 496

/opt/anaconda3/lib/python3.6/site-packages/torch/utils/cpp_extension.py in _jit_compile(name, sources, extra_cflags, extra_cuda_cflags, extra_ldflags, extra_include_paths, build_directory, verbose, with_cuda) 660 if verbose: 661 print('Building extension module {}...'.format(name)) --> 662 _build_extension_module(name, build_directory) 663 finally: 664 baton.release()

/opt/anaconda3/lib/python3.6/site-packages/torch/utils/cpp_extension.py in _build_extension_module(name, build_directory) 743 # error.output contains the stdout and stderr of the build attempt. 744 raise RuntimeError("Error building extension '{}': {}".format( --> 745 name, error.output.decode())) 746 747

RuntimeError: Error building extension 'inplace_abn': [1/4] /opt/anaconda3/lib/python3.6/site-packages/torch/cuda/bin/nvcc -DTORCH_EXTENSION_NAME=inplace_abn -I/opt/anaconda3/lib/python3.6/site-packages/torch/lib/include -I/opt/anaconda3/lib/python3.6/site-packages/torch/lib/include/TH -I/opt/anaconda3/lib/python3.6/site-packages/torch/lib/include/THC -I/opt/anaconda3/lib/python3.6/site-packages/torch/cuda/include -I/opt/anaconda3/include/python3.6m --compiler-options '-fPIC' --expt-extended-lambda -std=c++11 -c /home/ubuntu/TernausNetV2/modules/src/inplace_abn_cuda.cu -o inplace_abn_cuda.cuda.o FAILED: inplace_abn_cuda.cuda.o /opt/anaconda3/lib/python3.6/site-packages/torch/cuda/bin/nvcc -DTORCH_EXTENSION_NAME=inplace_abn -I/opt/anaconda3/lib/python3.6/site-packages/torch/lib/include -I/opt/anaconda3/lib/python3.6/site-packages/torch/lib/include/TH -I/opt/anaconda3/lib/python3.6/site-packages/torch/lib/include/THC -I/opt/anaconda3/lib/python3.6/site-packages/torch/cuda/include -I/opt/anaconda3/include/python3.6m --compiler-options '-fPIC' --expt-extended-lambda -std=c++11 -c /home/ubuntu/TernausNetV2/modules/src/inplace_abn_cuda.cu -o inplace_abn_cuda.cuda.o /bin/sh: 1: /opt/anaconda3/lib/python3.6/site-packages/torch/cuda/bin/nvcc: not found [2/4] c++ -MMD -MF inplace_abn_cpu.o.d -DTORCH_EXTENSION_NAME=inplace_abn -I/opt/anaconda3/lib/python3.6/site-packages/torch/lib/include -I/opt/anaconda3/lib/python3.6/site-packages/torch/lib/include/TH -I/opt/anaconda3/lib/python3.6/site-packages/torch/lib/include/THC -I/opt/anaconda3/lib/python3.6/site-packages/torch/cuda/include -I/opt/anaconda3/include/python3.6m -fPIC -std=c++11 -O3 -c /home/ubuntu/TernausNetV2/modules/src/inplace_abn_cpu.cpp -o inplace_abn_cpu.o /home/ubuntu/TernausNetV2/modules/src/inplace_abn_cpu.cpp: In function 'std::vectorat::Tensor backward_cpu(at::Tensor, at::Tensor, at::Tensor, at::Tensor, at::Tensor, at::Tensor, at::Tensor, bool, float)': /home/ubuntu/TernausNetV2/modules/src/inplace_abn_cpu.cpp:82:41: warning: 'at::Tensor at::empty(const at::Type&, at::IntList)' is deprecated [-Wdeprecated-declarations] auto dweight = at::empty(z.type(), {0}); ^ In file included from /opt/anaconda3/lib/python3.6/site-packages/torch/lib/include/ATen/ATen.h:14:0, from /home/ubuntu/TernausNetV2/modules/src/inplace_abn_cpu.cpp:1: /opt/anaconda3/lib/python3.6/site-packages/torch/lib/include/ATen/Functions.h:3521:22: note: declared here static inline Tensor empty(const Type & dtype, IntList size) { ^~~~~ /home/ubuntu/TernausNetV2/modules/src/inplace_abn_cpu.cpp:83:39: warning: 'at::Tensor at::empty(const at::Type&, at::IntList)' is deprecated [-Wdeprecated-declarations] auto dbias = at::empty(z.type(), {0}); ^ In file included from /opt/anaconda3/lib/python3.6/site-packages/torch/lib/include/ATen/ATen.h:14:0, from /home/ubuntu/TernausNetV2/modules/src/inplace_abn_cpu.cpp:1: /opt/anaconda3/lib/python3.6/site-packages/torch/lib/include/ATen/Functions.h:3521:22: note: declared here static inline Tensor empty(const Type & dtype, IntList size) { ^~~~~ [3/4] c++ -MMD -MF inplace_abn.o.d -DTORCH_EXTENSION_NAME=inplace_abn -I/opt/anaconda3/lib/python3.6/site-packages/torch/lib/include -I/opt/anaconda3/lib/python3.6/site-packages/torch/lib/include/TH -I/opt/anaconda3/lib/python3.6/site-packages/torch/lib/include/THC -I/opt/anaconda3/lib/python3.6/site-packages/torch/cuda/include -I/opt/anaconda3/include/python3.6m -fPIC -std=c++11 -O3 -c /home/ubuntu/TernausNetV2/modules/src/inplace_abn.cpp -o inplace_abn.o ninja: build stopped: subcommand failed.

himabindu13198 avatar Mar 05 '19 19:03 himabindu13198