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

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 install

…here are the error messages…

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

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

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

#define SIGABRT 6


#define SIGABRT 6



FYI, I’ve already added the following line…


…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.


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.


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


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:


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/”, line 17, in
from ._six import string_classes as _string_classes
File “torch/”, 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/”, 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”