I’m trying to build pytorch from source inside a conda environment using the official documentation. I have gcc and a c++ compiler(cxx-compiler) as wells as mkl and mkl-include installed in the environment. Unfortunately after calling python setup.py install it fails with the foillowing output:
1/2275] Generating libmkldnn.a
[2/2275] Generating contrib/playground/resnetdemo/rendezvous_filestore.py
[3/2275] Linking C shared library lib/libtorch_global_deps.so
FAILED: lib/libtorch_global_deps.so
: && path_to_conda/miniconda3/envs/pytorch_build/bin/x86_64-conda_cos6-linux-gnu-cc -fPIC -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem path_to_conda/miniconda3/envs/pytorch_build/include -fopenmp -DNDEBUG -O3 -DNDEBUG -DNDEBUG  -Wl,--no-as-needed -rdynamic -shared -Wl,-soname,libtorch_global_deps.so -o lib/libtorch_global_deps.so caffe2/CMakeFiles/torch_global_deps.dir/__/torch/csrc/empty.c.o  -Wl,-rpath,:::::::  -lmkl_intel_lp64  -lmkl_gnu_thread  -lmkl_core  -fopenmp  -lpthread  path_to_conda/miniconda3/envs/pytorch_build/x86_64-conda_cos6-linux-gnu/sysroot/usr/lib/libm.so  path_to_conda/miniconda3/envs/pytorch_build/x86_64-conda_cos6-linux-gnu/sysroot/usr/lib/libdl.so && :
path_to_conda/miniconda3/envs/pytorch_build/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: cannot find -lmkl_intel_lp64
path_to_conda/miniconda3/envs/pytorch_build/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: cannot find -lmkl_gnu_thread
path_to_conda/miniconda3/envs/pytorch_build/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: cannot find -lmkl_core
collect2: error: ld returned 1 exit status
[4/2275] Generating contrib/playground/resnetdemo/override_no_test_model_no_checkpoint.py
[5/2275] Generating contrib/prof/__init__.py
[6/2275] Generating contrib/prof/cuda_profile_ops_test.py
ninja: build stopped: subcommand failed.
Building wheel torch-1.6.0a0+0f60c8d
-- Building version 1.6.0a0+0f60c8d
cmake --build . --target install --config Release -- -j 4
Traceback (most recent call last):
  File "setup.py", line 740, in <module>
    build_deps()
  File "setup.py", line 318, in build_deps
    build_caffe2(version=version,
  File "/home/user/pytorch_git/pytorch/tools/build_pytorch_libs.py", line 62, in build_caffe2
    cmake.build(my_env)
  File "/home/user/pytorch_git/pytorch/tools/setup_helpers/cmake.py", line 345, in build
    self.run(build_args, my_env)
  File "/home/user/pytorch_git/pytorch/tools/setup_helpers/cmake.py", line 141, in run
    check_call(command, cwd=self.build_dir, env=env)
  File "path_to_conda/miniconda3/envs/pytorch_build/lib/python3.8/subprocess.py", line 364, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', '--build', '.', '--target', 'install', '--config', 'Release', '--', '-j', '4']' returned non-zero exit status 1.

This happens in a newly created conda environement which contains little addititonal packages besides those required for the build according to the documentation. If I append --cmake to the call the same happens but only after 1848 of 4207 steps work well. I am unsure, what lkml is in this context and I wasn’t able to find a way to have it available within the conda environment. I’m pretty much stuck and would appreciate any suggestion on what to try next.