Build pytorch from source fails again

This time I got the following error message:

[ 89%] Built target caffe2_gpu
[ 89%] Linking CXX executable …/bin/apply_test
[ 89%] Linking CXX executable …/bin/undefined_tensor_test
[ 89%] Linking CXX executable …/bin/stream_test
[ 89%] Linking CXX executable …/bin/cuda_rng_test
/root/install/pytorch/build/lib/libcaffe2_gpu.so: undefined reference to ncclGroupEnd' /root/install/pytorch/build/lib/libcaffe2_gpu.so: undefined reference toncclGroupStart’
collect2: error: ld returned 1 exit status
caffe2/CMakeFiles/cuda_rng_test.dir/build.make:101: recipe for target ‘bin/cuda_rng_test’ failed
make[2]: *** [bin/cuda_rng_test] Error 1
CMakeFiles/Makefile2:1391: recipe for target ‘caffe2/CMakeFiles/cuda_rng_test.dir/all’ failed
make[1]: *** [caffe2/CMakeFiles/cuda_rng_test.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs…
/root/install/pytorch/build/lib/libcaffe2_gpu.so: undefined reference to ncclGroupEnd' /root/install/pytorch/build/lib/libcaffe2_gpu.so: undefined reference toncclGroupStart’
/root/install/pytorch/build/lib/libcaffe2_gpu.so: undefined reference to ncclGroupEnd' /root/install/pytorch/build/lib/libcaffe2_gpu.so: undefined reference toncclGroupStart’
collect2: error: ld returned 1 exit status
caffe2/CMakeFiles/apply_test.dir/build.make:101: recipe for target ‘bin/apply_test’ failed
make[2]: *** [bin/apply_test] Error 1
CMakeFiles/Makefile2:1431: recipe for target ‘caffe2/CMakeFiles/apply_test.dir/all’ failed
make[1]: *** [caffe2/CMakeFiles/apply_test.dir/all] Error 2
collect2: error: ld returned 1 exit status
caffe2/CMakeFiles/stream_test.dir/build.make:101: recipe for target ‘bin/stream_test’ failed
make[2]: *** [bin/stream_test] Error 1
CMakeFiles/Makefile2:1351: recipe for target ‘caffe2/CMakeFiles/stream_test.dir/all’ failed
make[1]: *** [caffe2/CMakeFiles/stream_test.dir/all] Error 2
/root/install/pytorch/build/lib/libcaffe2_gpu.so: undefined reference to ncclGroupEnd' /root/install/pytorch/build/lib/libcaffe2_gpu.so: undefined reference toncclGroupStart’
collect2: error: ld returned 1 exit status
caffe2/CMakeFiles/undefined_tensor_test.dir/build.make:99: recipe for target ‘bin/undefined_tensor_test’ failed
make[2]: *** [bin/undefined_tensor_test] Error 1
CMakeFiles/Makefile2:1471: recipe for target ‘caffe2/CMakeFiles/undefined_tensor_test.dir/all’ failed
make[1]: *** [caffe2/CMakeFiles/undefined_tensor_test.dir/all] Error 2
Makefile:140: recipe for target ‘all’ failed
make: *** [all] Error 2
Failed to run ‘bash …/tools/build_pytorch_libs.sh --use-cuda --use-nnpack nccl caffe2 libshm gloo THD c10d’

This is related to caffe2 and nccl. I searched Internet, and didn’t find a solution yet.
My system is AMD x86_64 Ubuntu 18.04, with gcc 7.3.0, cuda 9.2, cudnn 7.2.1.

Got it done. Seems updated cmake from version 3.11.0 to 3.12.0 resolved the problem
(though I also updated some other software packages as well).

How to update cmake version?

pip install --upgrade cmake
or
apt upgrade cmake
depends on cmake which was installed via pip or apt (on ubuntu).