I had the same issue compiling Pytorch on a Raspberry Pi 1 B.
Even though I added NO_DISTRIBUTED=1, it still wanted to compile gloo, crashing with the same error.
I dug through the code a bit and found the line, in which the gloo build was started.
In pytorch/torch/lib/build_libs.sh, line 162-173:
# Build
for arg in "$@"; do
    if [[ "$arg" == "nccl" ]]; then
        build_nccl
    elif [[ "$arg" == "gloo" ]]; then
        build gloo $GLOO_FLAGS
    elif [[ "$arg" == "ATen" ]]; then
        build_aten
    else
        build $arg
    fi
done

Apparently the build gloo $GLOO_FLAGS line was called, even though NO_DISTRIBUTED was set.
Since I couldn’t figure out, which script called it, I just commented out the line, added a simple echo 'Would build gloo' instead, and it worked! 
I will try to figure out why the line is still called, even though gloo shouldn’t be built.