Error when compiling PyTorch from Source (libgfortran.so.4 not found)

When I compile from sorce, I hit following error (libgfortran.so.4 not found).
I am just doing following commands on fc22bf3e82723178015708ae1265ec14710c2dec

python setup.py build develop

Is there good way to solve this issue?

[ 92%] Built target caffe2
[ 92%] Linking CXX executable ../bin/verify_api_visibility
[ 92%] Linking CXX executable ../bin/tbb_init_test
[ 92%] Linking CXX executable ../bin/undefined_tensor_test
[ 93%] Linking CXX executable ../bin/scalar_tensor_test
/usr/bin/ld: warning: libgfortran.so.4, needed by //opt/conda/lib/libopenblas.so.0, not found (try using -rpath or -rpath-link)
//opt/conda/lib/libopenblas.so.0: undefined reference to `_gfortran_etime@GFORTRAN_7'
//opt/conda/lib/libopenblas.so.0: undefined reference to `_gfortran_concat_string@GFORTRAN_7'
//opt/conda/lib/libopenblas.so.0: undefined reference to `_gfortran_compare_string@GFORTRAN_7'
collect2: error: ld returned 1 exit status
caffe2/CMakeFiles/verify_api_visibility.dir/build.make:95: recipe for target 'bin/verify_api_visibility' failed
make[2]: *** [bin/verify_api_visibility] Error 1
CMakeFiles/Makefile2:896: recipe for target 'caffe2/CMakeFiles/verify_api_visibility.dir/all' failed
make[1]: *** [caffe2/CMakeFiles/verify_api_visibility.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
/usr/bin/ld: warning: libgfortran.so.4, needed by //opt/conda/lib/libopenblas.so.0, not found (try using -rpath or -rpath-link)
//opt/conda/lib/libopenblas.so.0: undefined reference to `_gfortran_etime@GFORTRAN_7'
//opt/conda/lib/libopenblas.so.0: undefined reference to `_gfortran_concat_string@GFORTRAN_7'
//opt/conda/lib/libopenblas.so.0: undefined reference to `_gfortran_compare_string@GFORTRAN_7'
collect2: error: ld returned 1 exit status
caffe2/CMakeFiles/tbb_init_test.dir/build.make:95: recipe for target 'bin/tbb_init_test' failed
make[2]: *** [bin/tbb_init_test] Error 1
CMakeFiles/Makefile2:858: recipe for target 'caffe2/CMakeFiles/tbb_init_test.dir/all' failed
make[1]: *** [caffe2/CMakeFiles/tbb_init_test.dir/all] Error 2
/usr/bin/ld: warning: libgfortran.so.4, needed by //opt/conda/lib/libopenblas.so.0, not found (try using -rpath or -rpath-link)
//opt/conda/lib/libopenblas.so.0: undefined reference to `_gfortran_etime@GFORTRAN_7'
//opt/conda/lib/libopenblas.so.0: undefined reference to `_gfortran_concat_string@GFORTRAN_7'
//opt/conda/lib/libopenblas.so.0: undefined reference to `_gfortran_compare_string@GFORTRAN_7'
collect2: error: ld returned 1 exit status
caffe2/CMakeFiles/undefined_tensor_test.dir/build.make:95: recipe for target 'bin/undefined_tensor_test' failed
make[2]: *** [bin/undefined_tensor_test] Error 1
CMakeFiles/Makefile2:934: recipe for target 'caffe2/CMakeFiles/undefined_tensor_test.dir/all' failed
make[1]: *** [caffe2/CMakeFiles/undefined_tensor_test.dir/all] Error 2
/usr/bin/ld: warning: libgfortran.so.4, needed by //opt/conda/lib/libopenblas.so.0, not found (try using -rpath or -rpath-link)
//opt/conda/lib/libopenblas.so.0: undefined reference to `_gfortran_etime@GFORTRAN_7'
//opt/conda/lib/libopenblas.so.0: undefined reference to `_gfortran_concat_string@GFORTRAN_7'
//opt/conda/lib/libopenblas.so.0: undefined reference to `_gfortran_compare_string@GFORTRAN_7'
collect2: error: ld returned 1 exit status
caffe2/CMakeFiles/scalar_tensor_test.dir/build.make:95: recipe for target 'bin/scalar_tensor_test' failed
make[2]: *** [bin/scalar_tensor_test] Error 1
CMakeFiles/Makefile2:972: recipe for target 'caffe2/CMakeFiles/scalar_tensor_test.dir/all' failed
make[1]: *** [caffe2/CMakeFiles/scalar_tensor_test.dir/all] Error 2
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2
Failed to run 'bash tools/build_pytorch_libs.sh --use-cuda --use-nnpack nccl caffe2 nanopb libshm gloo THD c10d'

your installed openblas needs, but cannot find gfortran.

Is there a reason you installed openblas, instead of recommend MKL?

Did you follow instructions from: https://github.com/pytorch/pytorch#from-source

Thank you. I compiled successfully.