Hey everyone! I’m trying to build Pytorch from source but it seems to keep getting stuck at Linking CXX Shared Library/bin/torch_cpu.dll.
There’s no error per say but it ends up stuck on this line for 1.5-2hrs.
Sorry Im very new to building from source, can someone help me with this?
My system:
OS: Windows 10
CUDA: 11.4
GPU: Nvidia GTX 970M
I’ve followed this guide GitHub - pytorch/pytorch: Tensors and Dynamic neural networks in Python with strong GPU acceleration 1
Below is my summary and the screenshot of the last line it hangs on.

– Found PythonInterp: C:/Users/biswa/anaconda3/envs/torch_dev/python.exe (found version “3.9.7”)
– Found PythonLibs: C:/Users/biswa/anaconda3/envs/torch_dev/libs/python39.lib (found version “3.9.7”)
Generated: C:/ProgramData/Workspace/open_source/pytorch/build/third_party/onnx/onnx/onnx_onnx_torch-ml.proto
Generated: C:/ProgramData/Workspace/open_source/pytorch/build/third_party/onnx/onnx/onnx-operators_onnx_torch-ml.proto
Generated: C:/ProgramData/Workspace/open_source/pytorch/build/third_party/onnx/onnx/onnx-data_onnx_torch.proto

– ******** Summary ********
–   CMake version             : 3.21.3
–   CMake command             : C:/Users/biswa/anaconda3/envs/torch_dev/Library/bin/cmake.exe
–   System                    : Windows
–   C++ compiler              : C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe
–   C++ compiler version      : 19.29.30133.0
–   CXX flags                 : /DWIN32 /D_WINDOWS /GR /EHsc /w /bigobj -DUSE_PTHREADPOOL -openmp:experimental -I/mkl/include /EHsc /wd26812
–   Build type                : Release
–   Compile definitions       : WIN32_LEAN_AND_MEAN;TH_BLAS_MKL;_OPENMP_NOFORCE_MANIFEST;ONNX_ML=1;ONNXIFI_ENABLE_EXT=1
–   CMAKE_PREFIX_PATH         : C:\Users\biswa\anaconda3\envs\torch_dev\Lib\site-packages;C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.4
–   CMAKE_INSTALL_PREFIX      : C:/ProgramData/Workspace/open_source/pytorch/torch
–   CMAKE_MODULE_PATH         : C:/ProgramData/Workspace/open_source/pytorch/cmake/Modules;C:/ProgramData/Workspace/open_source/pytorch/cmake/public/…/Modules_CUDA_fix

–   ONNX version              : 1.10.1
–   ONNX NAMESPACE            : onnx_torch
–   ONNX_USE_LITE_PROTO       : OFF
–   USE_PROTOBUF_SHARED_LIBS  : OFF
–   Protobuf_USE_STATIC_LIBS  : ON
–   ONNX_DISABLE_EXCEPTIONS   : OFF
–   ONNX_WERROR               : OFF
–   ONNX_BUILD_TESTS          : OFF
–   ONNX_BUILD_BENCHMARKS     : OFF
–   ONNXIFI_DUMMY_BACKEND     : OFF
–   ONNXIFI_ENABLE_EXT        : OFF

–   Protobuf compiler         :
–   Protobuf includes         :
–   Protobuf libraries        :
–   BUILD_ONNX_PYTHON         : OFF

– ******** Summary ********
–   CMake version         : 3.21.3
–   CMake command         : C:/Users/biswa/anaconda3/envs/torch_dev/Library/bin/cmake.exe
–   System                : Windows
–   C++ compiler          : C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe
–   C++ compiler version  : 19.29.30133.0
–   CXX flags             : /DWIN32 /D_WINDOWS /GR /EHsc /w /bigobj -DUSE_PTHREADPOOL -openmp:experimental -I/mkl/include
–   Build type            : Release
–   Compile definitions   : WIN32_LEAN_AND_MEAN;TH_BLAS_MKL;_OPENMP_NOFORCE_MANIFEST;ONNX_ML=1;ONNXIFI_ENABLE_EXT=1
–   CMAKE_PREFIX_PATH     : C:\Users\biswa\anaconda3\envs\torch_dev\Lib\site-packages;C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.4
–   CMAKE_INSTALL_PREFIX  : C:/ProgramData/Workspace/open_source/pytorch/torch
–   CMAKE_MODULE_PATH     : C:/ProgramData/Workspace/open_source/pytorch/cmake/Modules;C:/ProgramData/Workspace/open_source/pytorch/cmake/public/…/Modules_CUDA_fix

–   ONNX version          : 1.4.1
–   ONNX NAMESPACE        : onnx_torch
–   ONNX_BUILD_TESTS      : OFF
–   ONNX_BUILD_BENCHMARKS : OFF
–   ONNX_USE_LITE_PROTO   : OFF
–   ONNXIFI_DUMMY_BACKEND : OFF
–   Protobuf compiler     :
–   Protobuf includes     :
–   Protobuf libraries    :
–   BUILD_ONNX_PYTHON     : OFF
– Found CUDA with FP16 support, compiling with torch.cuda.HalfTensor
– Adding -DNDEBUG to compile flags
CMake Warning at cmake/Dependencies.cmake:1679 (message):
Not compiling with MAGMA.  Suppress this warning with -DUSE_MAGMA=OFF.
Call Stack (most recent call first):
CMakeLists.txt:656 (include)
– Could not find hardware support for NEON on this machine.
– No OMAP3 processor on this machine.
– No OMAP4 processor on this machine.
– Looking for cpuid.h
– Looking for cpuid.h - not found
– Performing Test NO_GCC_EBX_FPIC_BUG
– Performing Test NO_GCC_EBX_FPIC_BUG - Failed
– AVX compiler support found
– AVX2 compiler support found
– Found a library with LAPACK API (mkl).
disabling ROCM because NOT USE_ROCM is set
– MIOpen not found. Compiling without MIOpen support
– MKLDNN_CPU_RUNTIME = OMP
CMake Deprecation Warning at third_party/ideep/mkl-dnn/CMakeLists.txt:17 (cmake_minimum_required):
Compatibility with CMake < 2.8.12 will be removed from a future version of
CMake.
Update the VERSION argument  value or use a … suffix to tell
CMake that the project does not need compatibility with older versions.
– Intel MKL-DNN compat: set DNNL_ENABLE_CONCURRENT_EXEC to MKLDNN_ENABLE_CONCURRENT_EXEC with value ON
– Intel MKL-DNN compat: set DNNL_BUILD_EXAMPLES to MKLDNN_BUILD_EXAMPLES with value FALSE
– Intel MKL-DNN compat: set DNNL_BUILD_TESTS to MKLDNN_BUILD_TESTS with value FALSE
– Intel MKL-DNN compat: set DNNL_LIBRARY_TYPE to MKLDNN_LIBRARY_TYPE with value STATIC
– Intel MKL-DNN compat: set DNNL_ARCH_OPT_FLAGS to MKLDNN_ARCH_OPT_FLAGS with value ``
– Intel MKL-DNN compat: set DNNL_CPU_RUNTIME to MKLDNN_CPU_RUNTIME with value OMP
CMake Warning (dev) at C:/Users/biswa/anaconda3/envs/torch_dev/Library/share/cmake-3.21/Modules/FindPackageHandleStandardArgs.cmake:438 (message):
The package name passed to find_package_handle_standard_args (OpenMP_C)
does not match the name of the calling package (OpenMP).  This can lead to
problems in calling code that expects find_package result variables
(e.g., _FOUND) to follow a certain pattern.
Call Stack (most recent call first):
cmake/Modules/FindOpenMP.cmake:576 (find_package_handle_standard_args)
third_party/ideep/mkl-dnn/cmake/OpenMP.cmake:61 (find_package)
third_party/ideep/mkl-dnn/CMakeLists.txt:114 (include)
This warning is for project developers.  Use -Wno-dev to suppress it.
– Found OpenMP_C: -openmp:experimental -I/mkl/include
CMake Warning (dev) at C:/Users/biswa/anaconda3/envs/torch_dev/Library/share/cmake-3.21/Modules/FindPackageHandleStandardArgs.cmake:438 (message):
The package name passed to find_package_handle_standard_args (OpenMP_CXX)
does not match the name of the calling package (OpenMP).  This can lead to
problems in calling code that expects find_package result variables
(e.g., _FOUND) to follow a certain pattern.
Call Stack (most recent call first):
cmake/Modules/FindOpenMP.cmake:576 (find_package_handle_standard_args)
third_party/ideep/mkl-dnn/cmake/OpenMP.cmake:61 (find_package)
third_party/ideep/mkl-dnn/CMakeLists.txt:114 (include)
This warning is for project developers.  Use -Wno-dev to suppress it.
– Found OpenMP_CXX: -openmp:experimental -I/mkl/include
– Primitive cache is enabled
– Found MKL-DNN: TRUE
– Performing Test C_HAS_THREAD
– Performing Test C_HAS_THREAD - Success
– Version: 7.0.3
– Build type: Release
– CXX_STANDARD: 14
– Performing Test has_std_14_flag
– Performing Test has_std_14_flag - Failed
– Performing Test has_std_1y_flag
– Performing Test has_std_1y_flag - Failed
– Performing Test SUPPORTS_USER_DEFINED_LITERALS
– Performing Test SUPPORTS_USER_DEFINED_LITERALS - Success
– Performing Test FMT_HAS_VARIANT
– Performing Test FMT_HAS_VARIANT - Success
– Required features: cxx_variadic_templates
– Looking for _strtod_l
– Looking for _strtod_l - found
– Using CPU-only version of Kineto
– Configuring Kineto dependency:
–   KINETO_SOURCE_DIR = C:/ProgramData/Workspace/open_source/pytorch/third_party/kineto/libkineto
–   KINETO_BUILD_TESTS = OFF
–   KINETO_LIBRARY_TYPE = static
INFO CUDA_SOURCE_DIR =
INFO CUPTI unavailable or disabled - not building GPU profilers
– Kineto: FMT_SOURCE_DIR = C:/ProgramData/Workspace/open_source/pytorch/third_party/fmt
– Kineto: FMT_INCLUDE_DIR = C:/ProgramData/Workspace/open_source/pytorch/third_party/fmt/include
INFO CUPTI_INCLUDE_DIR = /extras/CUPTI/include
– Configured Kineto (CPU)
– Looking for backtrace
– Looking for backtrace - not found
– Could NOT find Backtrace (missing: Backtrace_LIBRARY Backtrace_INCLUDE_DIR)
– don’t use NUMA
– Performing Test COMPILER_SUPPORTS_NO_AVX256_SPLIT
– Performing Test COMPILER_SUPPORTS_NO_AVX256_SPLIT - Failed
– Using ATen parallel backend: OMP
AT_INSTALL_INCLUDE_DIR include/ATen/core
core header install: C:/ProgramData/Workspace/open_source/pytorch/build/aten/src/ATen/core/TensorBody.h
– NCCL operators skipped due to no CUDA support
– Excluding FakeLowP operators
– Including IDEEP operators
– Excluding image processing operators due to no opencv
– Excluding video processing operators due to no opencv
– MPI operators skipped due to no MPI support
– Include Observer library
CMake Warning (dev) at torch/CMakeLists.txt:407:
Syntax Warning in cmake code at column 107
Argument not separated from preceding token by whitespace.
This warning is for project developers.  Use -Wno-dev to suppress it.
CMake Warning (dev) at torch/CMakeLists.txt:407:
Syntax Warning in cmake code at column 115
Argument not separated from preceding token by whitespace.
This warning is for project developers.  Use -Wno-dev to suppress it.
CMake Warning at cmake/public/utils.cmake:365 (message):
In the future we will require one to explicitly pass TORCH_CUDA_ARCH_LIST
to cmake instead of implicitly setting it as an env variable.  This will
become a FATAL_ERROR in future version of pytorch.
Call Stack (most recent call first):
torch/CMakeLists.txt:374 (torch_cuda_get_nvcc_gencode_flag)
CMake Warning (dev) at C:/Users/biswa/anaconda3/envs/torch_dev/Library/share/cmake-3.21/Modules/FindPackageHandleStandardArgs.cmake:438 (message):
The package name passed to find_package_handle_standard_args (OpenMP_C)
does not match the name of the calling package (OpenMP).  This can lead to
problems in calling code that expects find_package result variables
(e.g., _FOUND) to follow a certain pattern.
Call Stack (most recent call first):
cmake/Modules/FindOpenMP.cmake:576 (find_package_handle_standard_args)
caffe2/CMakeLists.txt:1204 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.
CMake Warning (dev) at C:/Users/biswa/anaconda3/envs/torch_dev/Library/share/cmake-3.21/Modules/FindPackageHandleStandardArgs.cmake:438 (message):
The package name passed to find_package_handle_standard_args (OpenMP_CXX)
does not match the name of the calling package (OpenMP).  This can lead to
problems in calling code that expects find_package result variables
(e.g., _FOUND) to follow a certain pattern.
Call Stack (most recent call first):
cmake/Modules/FindOpenMP.cmake:576 (find_package_handle_standard_args)
caffe2/CMakeLists.txt:1204 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.
– pytorch is compiling with OpenMP.
OpenMP CXX_FLAGS: -openmp:experimental -I/mkl/include.
OpenMP libraries: /mkl/lib/libiomp5md.lib.
– Caffe2 is compiling with OpenMP.
OpenMP CXX_FLAGS: -openmp:experimental -I/mkl/include.
OpenMP libraries: /mkl/lib/libiomp5md.lib.
– Using Lib/site-packages as python relative installation path
CMake Warning at CMakeLists.txt:988 (message):
Generated cmake files are only fully tested if one builds with system glog,
gflags, and protobuf.  Other settings may generate files that are not well
tested.

–
– ******** Summary ********
– General:
–   CMake version         : 3.21.3
–   CMake command         : C:/Users/biswa/anaconda3/envs/torch_dev/Library/bin/cmake.exe
–   System                : Windows
–   C++ compiler          : C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe
–   C++ compiler id       : MSVC
–   C++ compiler version  : 19.29.30133.0
–   Using ccache if found : OFF
–   CXX flags             : /DWIN32 /D_WINDOWS /GR /EHsc /w /bigobj -DUSE_PTHREADPOOL -openmp:experimental -I/mkl/include -DNDEBUG -DUSE_KINETO -DLIBKINETO_NOCUPTI -DUSE_FBGEMM -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE -DEDGE_PROFILER_USE_KINETO
–   Build type            : Release
–   Compile definitions   : WIN32_LEAN_AND_MEAN;TH_BLAS_MKL;_OPENMP_NOFORCE_MANIFEST;ONNX_ML=1;ONNXIFI_ENABLE_EXT=1;ONNX_NAMESPACE=onnx_torch;_CRT_SECURE_NO_DEPRECATE=1;IDEEP_USE_MKL;USE_EXTERNAL_MZCRC;MINIZ_DISABLE_ZIP_READER_CRC32_CHECKS
–   CMAKE_PREFIX_PATH     : C:\Users\biswa\anaconda3\envs\torch_dev\Lib\site-packages;C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.4
–   CMAKE_INSTALL_PREFIX  : C:/ProgramData/Workspace/open_source/pytorch/torch
–   USE_GOLD_LINKER       : OFF
–   TORCH_VERSION         : 1.11.0
–   CAFFE2_VERSION        : 1.11.0
–   BUILD_CAFFE2          : ON
–   BUILD_CAFFE2_OPS      : ON
–   BUILD_CAFFE2_MOBILE   : OFF
–   BUILD_STATIC_RUNTIME_BENCHMARK: OFF
–   BUILD_TENSOREXPR_BENCHMARK: OFF
–   BUILD_NVFUSER_BENCHMARK: ON
–   BUILD_BINARY          : OFF
–   BUILD_CUSTOM_PROTOBUF : ON
–     Link local protobuf : ON
–   BUILD_DOCS            : OFF
–   BUILD_PYTHON          : True
–     Python version      : 3.9.7
–     Python executable   : C:/Users/biswa/anaconda3/envs/torch_dev/python.exe
–     Pythonlibs version  : 3.9.7
–     Python library      : C:/Users/biswa/anaconda3/envs/torch_dev/libs/python39.lib
–     Python includes     : C:/Users/biswa/anaconda3/envs/torch_dev/include
–     Python site-packages: Lib/site-packages
–   BUILD_SHARED_LIBS     : ON
–   CAFFE2_USE_MSVC_STATIC_RUNTIME     : OFF
–   BUILD_TEST            : True
–   BUILD_JNI             : OFF
–   BUILD_MOBILE_AUTOGRAD : OFF
–   BUILD_LITE_INTERPRETER: OFF
–   INTERN_BUILD_MOBILE   :
–   USE_BLAS              : 1
–     BLAS                : mkl
–   USE_LAPACK            : 1
–     LAPACK              : mkl
–   USE_ASAN              : OFF
–   USE_CPP_CODE_COVERAGE : OFF
–   USE_CUDA              : ON
–     Split CUDA          : OFF
–     CUDA static link    : OFF
–     USE_CUDNN           : ON
–     USE_EXPERIMENTAL_CUDNN_V8_API: OFF
–     CUDA version        : 11.4
–     cuDNN version       : 8.2.4
–     CUDA root directory : C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.4
–     CUDA library        : C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.4/lib/x64/cuda.lib
–     cudart library      : C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.4/lib/x64/cudart_static.lib
–     cublas library      : C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.4/lib/x64/cublas.lib
–     cufft library       : C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.4/lib/x64/cufft.lib
–     curand library      : C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.4/lib/x64/curand.lib
–     cuDNN library       : C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.4/lib/x64/cudnn.lib
–     nvrtc               : C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.4/lib/x64/nvrtc.lib
–     CUDA include path   : C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.4/include
–     NVCC executable     : C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.4/bin/nvcc.exe
–     NVCC flags          : -Xcompiler;/w;-w;-Xfatbin;-compress-all;-DONNX_NAMESPACE=onnx_torch;–use-local-env;-gencode;arch=compute_52,code=sm_52;-Xcudafe;–diag_suppress=cc_clobber_ignored,–diag_suppress=integer_sign_change,–diag_suppress=useless_using_declaration,–diag_suppress=set_but_not_used,–diag_suppress=field_without_dll_interface,–diag_suppress=base_class_has_different_dll_interface,–diag_suppress=dll_interface_conflict_none_assumed,–diag_suppress=dll_interface_conflict_dllexport_assumed,–diag_suppress=implicit_return_from_non_void_function,–diag_suppress=unsigned_compare_with_zero,–diag_suppress=declared_but_not_referenced,–diag_suppress=bad_friend_decl;–Werror;cross-execution-space-call;–no-host-device-move-forward;-Xcompiler;-MD$<$CONFIG:Debug:d>;–expt-relaxed-constexpr;–expt-extended-lambda;-Xcompiler=/wd4819,/wd4503,/wd4190,/wd4244,/wd4251,/wd4275,/wd4522;-Wno-deprecated-gpu-targets;–expt-extended-lambda;-DCUDA_HAS_FP16=1;-D__CUDA_NO_HALF_OPERATORS__;-D__CUDA_NO_HALF_CONVERSIONS__;-D__CUDA_NO_BFLOAT16_CONVERSIONS__;-D__CUDA_NO_HALF2_OPERATORS__
–     CUDA host compiler  : C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe
–     NVCC --device-c     : OFF
–     USE_TENSORRT        : OFF
–   USE_ROCM              : OFF
–   USE_EIGEN_FOR_BLAS    :
–   USE_FBGEMM            : ON
–     USE_FAKELOWP          : OFF
–   USE_KINETO            : ON
–   USE_FFMPEG            : OFF
–   USE_GFLAGS            : OFF
–   USE_GLOG              : OFF
–   USE_LEVELDB           : OFF
–   USE_LITE_PROTO        : OFF
–   USE_LMDB              : OFF
–   USE_METAL             : OFF
–   USE_PYTORCH_METAL     : OFF
–   USE_PYTORCH_METAL_EXPORT     : OFF
–   USE_FFTW              : OFF
–   USE_MKL               : ON
–   USE_MKLDNN            : ON
–   USE_MKLDNN_ACL        : OFF
–   USE_MKLDNN_CBLAS      : OFF
–   USE_NCCL              : OFF
–   USE_NNPACK            : OFF
–   USE_NUMPY             : ON
–   USE_OBSERVERS         : ON
–   USE_OPENCL            : OFF
–   USE_OPENCV            : OFF
–   USE_OPENMP            : ON
–   USE_TBB               : OFF
–   USE_VULKAN            : OFF
–   USE_PROF              : OFF
–   USE_QNNPACK           : OFF
–   USE_PYTORCH_QNNPACK   : OFF
–   USE_REDIS             : OFF
–   USE_ROCKSDB           : OFF
–   USE_ZMQ               : OFF
–   USE_DISTRIBUTED       : ON
–     USE_MPI               : OFF
–     USE_GLOO              : ON
–     USE_GLOO_WITH_OPENSSL : OFF
–     USE_TENSORPIPE        : OFF
–   USE_DEPLOY           : OFF
–   USE_BREAKPAD         : ON
–   Public Dependencies  : Threads::Threads;caffe2::mkl;caffe2::mkldnn
–   Private Dependencies : pthreadpool;cpuinfo;XNNPACK;fbgemm;fp16;gloo;aten_op_header_gen;foxi_loader;fmt::fmt-header-only;kineto
–   USE_COREML_DELEGATE     : OFF
– Configuring done
– Generating done
– Build files have been written to: C:/ProgramData/Workspace/open_source/pytorch/build
cmake --build . --target install --config Release
[21/6330] Building RC object third_party\protobuf\cmake\CMakeFiles\protoc.dir\version.rc.res
Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384
Copyright (C) Microsoft Corporation.  All rights reserved.
[24/6330] Building RC object third_party\protobuf\cmake\CMakeFiles\libprotobuf-lite.dir\version.rc.res
Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384
Copyright (C) Microsoft Corporation.  All rights reserved.
Below is the screenshot of the last screen output

torch_compile1920×1080 264 KB