Building pytorch from source in conda fails in .../pytorch/caffe2/operators/crash_op.cc

On a (older - with glibc v2.12) linux Centos6.5 cluster using conda 4.5.0, following instructions here and then here, as the result of the command…

python setup.py install

…here are the error messages…

[ 69%] Building CXX object caffe2/CMakeFiles/caffe2.dir/operators/cube_op.cc.o
(snip)/pytorch/caffe2/operators/crash_op.cc: In member function ‘virtual bool caffe2::CrashOp::RunOnDevice()’:
(snip)/pytorch/caffe2/operators/crash_op.cc:14:11: error: ‘SIGABRT’ was not declared in this scope
raise(SIGABRT);
^
(snip)/pytorch/caffe2/operators/crash_op.cc:14:18: error: ‘raise’ was not declared in this scope
raise(SIGABRT);
^

Also, I believe the following shows where to find, e.g., SIGABRT.

find /usr/include -name signal.h -printf \n -print -exec grep SIGABRT {} ;

/usr/include/asm/signal.h
#define SIGABRT 6

/usr/include/signal.h

/usr/include/asm-generic/signal.h
#define SIGABRT 6

/usr/include/sys/signal.h

/usr/include/linux/signal.h

FYI, I’ve already added the following line…

set(CMAKE_CXX_FLAGS “${CMAKE_CXX_FLAGS} -D_FORCE_INLINES”)

…in order to avoid the error message…

‘errno’ not declared in this scope

Also, I’ve tried additional include_directories commands in CMakeLists.txt but to no avail so far, e.g. as in the following.

include_directories(
AFTER
/usr/include/asm/
)

Also, I’ve tried appending CMAKE_PREFIX_PATH but to no avail as in the following.

export CMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH:/usr/include/asm

Please advise and please let me know if I can provide more info, thanks.

Best,
CB

1 Like

I have the same error and I guess that it may be caused by glibc v2.12, since I have built libtorch with glibc v2.17 successfully.

For this error:
Try adding:

#include <signal.h>

for example, in the file

pytorch/third_party/protobuf/src/google/protobuf/inlined_string_field.h

which works out for me.

Thanks, I saw another post suggesting that same omission. Thus, in my case I’ve added that same line:

#include <signal.h>

to the file:

pytorch/caffe2/operators/crash_op.cc

and the pytorch build succeeded, but then the import failed:

$ python -c “import torch”
Traceback (most recent call last):
File “”, line 1, in
File “torch/init.py”, line 17, in
from ._six import string_classes as _string_classes
File “torch/_six.py”, line 23, in
import builtins
ImportError: No module named builtins

Thus as posted in other fora, I then did the following:

pip install future

I then got the following result from the import attempt:

$ python -c “import torch”
Traceback (most recent call last):
File “”, line 1, in
File “torch/init.py”, line 79, in
from torch._C import *
ImportError: No module named _C

I then saw this thread, including the recommendation “Could you please try opening torch in any directory other than repo’s root?..”

Observing all this while that I had been in the pytorch directory, I simply cd’ed to the parent and the import now succeeds.

$ cd …
$ python -c “import torch”
$

Best,
CB