# Enable C++17 failed when build pytorch from source on windows

**URL:** <https://discuss.pytorch.org/t/enable-c-17-failed-when-build-pytorch-from-source-on-windows/189959>\
**Category:** windows\
**Created:** [October 15, 2023, 6:49am UTC](https://discuss.pytorch.org/t/enable-c-17-failed-when-build-pytorch-from-source-on-windows/189959 "2023-10-15T06:49:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![xianshunw](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/xianshunw/32/18700_2.png) [@xianshunw](https://discuss.pytorch.org/u/xianshunw)\
**Post date:** [October 15, 2023, 6:49am UTC](https://discuss.pytorch.org/t/enable-c-17-failed-when-build-pytorch-from-source-on-windows/189959/1 "2023-10-15T06:49:05Z")

</div>

Hi all,

It’s my first time to try build pytorch from source on windows. I followed the official build docs. Here is the cmake summaries

```auto
  -- System : Windows
  -- C++ compiler : C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Tools/MSVC/14.37.32822/bin/Hostx64/x64/cl.exe
  -- C++ compiler version : 19.37.32825.0
  -- CXX flags : /DWIN32 /D_WINDOWS /GR /EHsc /bigobj /FS -DUSE_PTHREADPOOL /std:c++17 /EHsc /wd26812
  -- Build type : Release
  -- Compile definitions : ONNX_ML=1;ONNXIFI_ENABLE_EXT=1;__STDC_FORMAT_MACROS
  -- CMAKE_PREFIX_PATH : D:\workspace\envs\py38_torch1.13.1_cuda11.6\Lib\site-packages;C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.6
  -- CMAKE_INSTALL_PREFIX : D:/workspace/codes/pytorch/torch
  -- CMAKE_MODULE_PATH : D:/workspace/codes/pytorch/cmake/Modules;D:/workspace/codes/pytorch/cmake/public/../Modules_CUDA_fix
  --
  -- ONNX version : 1.14.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
  --
  -- Protobuf compiler :
  -- Protobuf includes :
  -- Protobuf libraries :
  -- BUILD_ONNX_PYTHON : OFF
  --
  -- ********Summary********
  -- CMake version : 3.24.1
  -- CMake command : D:/workspace/envs/py38_torch1.13.1_cuda11.6/Library/bin/cmake.exe
  -- System : Windows
  -- C++ compiler : C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Tools/MSVC/14.37.32822/bin/Hostx64/x64/cl.exe
  -- C++ compiler version : 19.37.32825.0
  -- CXX flags : /DWIN32 /D_WINDOWS /GR /EHsc /bigobj /FS -DUSE_PTHREADPOOL
  -- Build type : Release
  -- Compile definitions : ONNX_ML=1;ONNXIFI_ENABLE_EXT=1
  -- CMAKE_PREFIX_PATH : D:\workspace\envs\py38_torch1.13.1_cuda11.6\Lib\site-packages;C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.6
  -- CMAKE_INSTALL_PREFIX : D:/workspace/codes/pytorch/torch
  -- CMAKE_MODULE_PATH : D:/workspace/codes/pytorch/cmake/Modules;D:/workspace/codes/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 :
  --
  -- 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
  -- MAGMA not found. Compiling without MAGMA support
  -- Could not find hardware support for NEON on this machine.
  -- No OMAP3 processor on this machine.
  -- No OMAP4 processor on this machine.
  -- MKL_THREADING = OMP
  -- Checking for [mkl_intel_lp64 - mkl_intel_thread - mkl_core - libiomp5md]
  -- Library mkl_intel_lp64: not found
  -- Checking for [mkl_intel - mkl_intel_thread - mkl_core - libiomp5md]
  -- Library mkl_intel: not found
  -- Checking for [mkl_intel_lp64 - mkl_intel_thread - mkl_core]
  -- Library mkl_intel_lp64: not found
  -- Checking for [mkl_intel - mkl_intel_thread - mkl_core]
  -- Library mkl_intel: not found
  -- Checking for [mkl_intel_lp64 - mkl_sequential - mkl_core]
  -- Library mkl_intel_lp64: not found
  -- Checking for [mkl_intel - mkl_sequential - mkl_core]
  -- Library mkl_intel: not found
  -- Checking for [mkl_intel_lp64 - mkl_core - libiomp5md - pthread]
  -- Library mkl_intel_lp64: not found
  -- Checking for [mkl_intel - mkl_core - libiomp5md - pthread]
  -- Library mkl_intel: not found
  -- Checking for [mkl_intel_lp64 - mkl_core - pthread]
  -- Library mkl_intel_lp64: not found
  -- Checking for [mkl_intel - mkl_core - pthread]
  -- Library mkl_intel: not found
  -- Checking for [mkl - guide - pthread - m]
  -- Library mkl: not found
  -- MKL library not found
  -- Checking for [blis]
  -- Library blis: BLAS_blis_LIBRARY-NOTFOUND
  -- Checking for [Accelerate]
  -- Library Accelerate: BLAS_Accelerate_LIBRARY-NOTFOUND
  -- Checking for [vecLib]
  -- Library vecLib: BLAS_vecLib_LIBRARY-NOTFOUND
  -- Checking for [flexiblas]
  -- Library flexiblas: BLAS_flexiblas_LIBRARY-NOTFOUND
  -- Checking for [openblas]
  -- Library openblas: BLAS_openblas_LIBRARY-NOTFOUND
  -- Checking for [openblas - pthread - m]
  -- Library openblas: BLAS_openblas_LIBRARY-NOTFOUND
  -- Checking for [openblas - pthread - m - gomp]
  -- Library openblas: BLAS_openblas_LIBRARY-NOTFOUND
  -- Checking for [libopenblas]
  -- Library libopenblas: BLAS_libopenblas_LIBRARY-NOTFOUND
  -- Checking for [goto2 - gfortran]
  -- Library goto2: BLAS_goto2_LIBRARY-NOTFOUND
  -- Checking for [goto2 - gfortran - pthread]
  -- Library goto2: BLAS_goto2_LIBRARY-NOTFOUND
  -- Checking for [acml - gfortran]
  -- Library acml: BLAS_acml_LIBRARY-NOTFOUND
  -- Checking for [blis]
  -- Library blis: BLAS_blis_LIBRARY-NOTFOUND
  -- Could NOT find Atlas (missing: Atlas_CBLAS_INCLUDE_DIR Atlas_CLAPACK_INCLUDE_DIR Atlas_CBLAS_LIBRARY Atlas_BLAS_LIBRARY Atlas_LAPACK_LIBRARY)
  -- Checking for [ptf77blas - atlas - gfortran]
  -- Library ptf77blas: BLAS_ptf77blas_LIBRARY-NOTFOUND
  -- Checking for []
  -- Cannot find a library with BLAS API. Not using BLAS.
  -- LAPACK requires BLAS
  -- Cannot find a library with LAPACK API. Not using LAPACK.
  disabling ROCM because NOT USE_ROCM is set
  -- MIOpen not found. Compiling without MIOpen support
  -- MKL_THREADING = OMP
  -- Checking for [mkl_intel_lp64 - mkl_intel_thread - mkl_core - libiomp5md]
  -- Library mkl_intel_lp64: not found
  -- Checking for [mkl_intel - mkl_intel_thread - mkl_core - libiomp5md]
  -- Library mkl_intel: not found
  -- Checking for [mkl_intel_lp64 - mkl_intel_thread - mkl_core]
  -- Library mkl_intel_lp64: not found
  -- Checking for [mkl_intel - mkl_intel_thread - mkl_core]
  -- Library mkl_intel: not found
  -- Checking for [mkl_intel_lp64 - mkl_sequential - mkl_core]
  -- Library mkl_intel_lp64: not found
  -- Checking for [mkl_intel - mkl_sequential - mkl_core]
  -- Library mkl_intel: not found
  -- Checking for [mkl_intel_lp64 - mkl_core - libiomp5md - pthread]
  -- Library mkl_intel_lp64: not found
  -- Checking for [mkl_intel - mkl_core - libiomp5md - pthread]
  -- Library mkl_intel: not found
  -- Checking for [mkl_intel_lp64 - mkl_core - pthread]
  -- Library mkl_intel_lp64: not found
  -- Checking for [mkl_intel - mkl_core - pthread]
  -- Library mkl_intel: not found
  -- Checking for [mkl - guide - pthread - m]
  -- Library mkl: not found
  -- MKL library not found
  -- Checking for [blis]
  -- Library blis: BLAS_blis_LIBRARY-NOTFOUND
  -- Checking for [Accelerate]
  -- Library Accelerate: BLAS_Accelerate_LIBRARY-NOTFOUND
  -- Checking for [vecLib]
  -- Library vecLib: BLAS_vecLib_LIBRARY-NOTFOUND
  -- Checking for [flexiblas]
  -- Library flexiblas: BLAS_flexiblas_LIBRARY-NOTFOUND
  -- Checking for [openblas]
  -- Library openblas: BLAS_openblas_LIBRARY-NOTFOUND
  -- Checking for [openblas - pthread - m]
  -- Library openblas: BLAS_openblas_LIBRARY-NOTFOUND
  -- Checking for [openblas - pthread - m - gomp]
  -- Library openblas: BLAS_openblas_LIBRARY-NOTFOUND
  -- Checking for [libopenblas]
  -- Library libopenblas: BLAS_libopenblas_LIBRARY-NOTFOUND
  -- Checking for [goto2 - gfortran]
  -- Library goto2: BLAS_goto2_LIBRARY-NOTFOUND
  -- Checking for [goto2 - gfortran - pthread]
  -- Library goto2: BLAS_goto2_LIBRARY-NOTFOUND
  -- Checking for [acml - gfortran]
  -- Library acml: BLAS_acml_LIBRARY-NOTFOUND
  -- Checking for [blis]
  -- Library blis: BLAS_blis_LIBRARY-NOTFOUND
  -- Could NOT find Atlas (missing: Atlas_CBLAS_INCLUDE_DIR Atlas_CLAPACK_INCLUDE_DIR Atlas_CBLAS_LIBRARY Atlas_BLAS_LIBRARY Atlas_LAPACK_LIBRARY)
  -- Checking for [ptf77blas - atlas - gfortran]
  -- Library ptf77blas: BLAS_ptf77blas_LIBRARY-NOTFOUND
  -- Checking for []
  -- Cannot find a library with BLAS API. Not using BLAS.
  -- MKLDNN_CPU_RUNTIME = OMP
  -- DNNL_TARGET_ARCH: X64
  -- DNNL_LIBRARY_NAME: dnnl
  CMake Warning (dev) at D:/workspace/envs/py38_torch1.13.1_cuda11.6/Library/share/cmake-3.24/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:584 (find_package_handle_standard_args)
    third_party/ideep/mkl-dnn/cmake/OpenMP.cmake:69 (find_package)
    third_party/ideep/mkl-dnn/CMakeLists.txt:117 (include)
  This warning is for project developers. Use -Wno-dev to suppress it.
  
  CMake Warning (dev) at D:/workspace/envs/py38_torch1.13.1_cuda11.6/Library/share/cmake-3.24/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:584 (find_package_handle_standard_args)
    third_party/ideep/mkl-dnn/cmake/OpenMP.cmake:69 (find_package)
    third_party/ideep/mkl-dnn/CMakeLists.txt:117 (include)
  This warning is for project developers. Use -Wno-dev to suppress it.
  
  -- Could NOT find Doxyrest (missing: DOXYREST_EXECUTABLE)
  -- Found PythonInterp: D:/workspace/envs/py38_torch1.13.1_cuda11.6/python.exe (found suitable version "3.8.18", minimum required is "2.7")
  -- Could NOT find Sphinx (missing: SPHINX_EXECUTABLE)
  -- Enabled workload: TRAINING
  -- Enabled primitives: ALL
  -- Enabled primitive CPU ISA: ALL
  -- Enabled primitive GPU ISA: ALL
  -- Primitive cache is enabled
  -- Graph component is enabled
  -- Found MKL-DNN: TRUE
  -- Version: 10.1.0
  -- Build type: Release
  -- Using CPU-only version of Kineto
  -- Configuring Kineto dependency:
  -- KINETO_SOURCE_DIR = D:/workspace/codes/pytorch/third_party/kineto/libkineto
  -- KINETO_BUILD_TESTS = OFF
  -- KINETO_LIBRARY_TYPE = static
  -- Found PythonInterp: D:/workspace/envs/py38_torch1.13.1_cuda11.6/python.exe (found version "3.8.18")
  INFO CUDA_SOURCE_DIR =
  INFO ROCM_SOURCE_DIR =
  INFO CUPTI unavailable or disabled - not building GPU profilers
  -- Kineto: FMT_SOURCE_DIR = D:/workspace/codes/pytorch/third_party/fmt
  -- Kineto: FMT_INCLUDE_DIR = D:/workspace/codes/pytorch/third_party/fmt/include
  INFO CUPTI_INCLUDE_DIR = /extras/CUPTI/include
  INFO ROCTRACER_INCLUDE_DIR = /include/roctracer
  INFO DYNOLOG_INCLUDE_DIR = D:/workspace/codes/pytorch/third_party/kineto/libkineto/third_party/dynolog/
  INFO IPCFABRIC_INCLUDE_DIR = D:/workspace/codes/pytorch/third_party/kineto/libkineto/third_party/dynolog//dynolog/src/ipcfabric/
  -- Configured Kineto (CPU)
  CMake Warning (dev) at D:/workspace/envs/py38_torch1.13.1_cuda11.6/Library/share/cmake-3.24/Modules/CMakeDependentOption.cmake:89 (message):
    Policy CMP0127 is not set: cmake_dependent_option() supports full Condition
    Syntax. Run "cmake --help-policy CMP0127" for policy details. Use the
    cmake_policy command to set the policy and suppress this warning.
  Call Stack (most recent call first):
    CMakeLists.txt:725 (cmake_dependent_option)
  This warning is for project developers. Use -Wno-dev to suppress it.
  
  --
  -- Use the C++ compiler to compile (MI_USE_CXX=ON)
  --
  -- Library base name: mimalloc
  -- Version : 1.8
  -- Build type : release
  -- C++ Compiler : C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Tools/MSVC/14.37.32822/bin/Hostx64/x64/cl.exe
  -- Compiler flags : /Zc:__cplusplus
  -- Compiler defines :
  -- Link libraries : psapi;shell32;user32;advapi32;bcrypt
  -- Build targets : static
  --
  -- Could NOT find Backtrace (missing: Backtrace_LIBRARY Backtrace_INCLUDE_DIR)
  -- don't use NUMA
  -- headers outputs:
  -- sources outputs:
  -- declarations_yaml outputs:
  -- Using ATen parallel backend: OMP
  AT_INSTALL_INCLUDE_DIR include/ATen/core
  core header install: D:/workspace/codes/pytorch/build/aten/src/ATen/core/TensorBody.h
  core header install: D:/workspace/codes/pytorch/build/aten/src/ATen/core/aten_interned_strings.h
  core header install: D:/workspace/codes/pytorch/build/aten/src/ATen/core/enum_tag.h
  -- Generating sources for unboxing kernels D:/workspace/envs/py38_torch1.13.1_cuda11.6/python.exe;-m;torchgen.gen_executorch;--source-path=D:/workspace/codes/pytorch/test/edge/../../test/edge;--install-dir=D:/workspace/codes/pytorch/build/out;--tags-path=D:/workspace/codes/pytorch/test/edge/../../aten/src/ATen/native/tags.yaml;--aten-yaml-path=D:/workspace/codes/pytorch/test/edge/../../aten/src/ATen/native/native_functions.yaml;--use-aten-lib;--op-selection-yaml-path=D:/workspace/codes/pytorch/test/edge/../../test/edge/selected_operators.yaml;--custom-ops-yaml-path=D:/workspace/codes/pytorch/test/edge/../../test/edge/custom_ops.yaml
  CMake Warning (dev) at torch/CMakeLists.txt:389:
    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:389:
    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.
  
  -- Autodetected CUDA architecture(s): 8.6 6.1
  -- Using Lib/site-packages as python relative installation path
  CMake Warning at CMakeLists.txt:1113 (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.
  
  
  -- somehow this is happening
  --
  -- ********Summary********
  -- General:
  -- CMake version : 3.24.1
  -- CMake command : D:/workspace/envs/py38_torch1.13.1_cuda11.6/Library/bin/cmake.exe
  -- System : Windows
  -- C++ compiler : C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Tools/MSVC/14.37.32822/bin/Hostx64/x64/cl.exe
  -- C++ compiler id : MSVC
  -- C++ compiler version : 19.37.32825.0
  -- Using ccache if found : OFF
  -- CXX flags : /DWIN32 /D_WINDOWS /GR /EHsc /bigobj /FS -DUSE_PTHREADPOOL -DNDEBUG -DUSE_KINETO -DLIBKINETO_NOCUPTI -DLIBKINETO_NOROCTRACER -DUSE_FBGEMM -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE /utf-8 /wd4624 /wd4068 /wd4067 /wd4267 /wd4661 /wd4717 /wd4244 /wd4804 /wd4273
  -- Build type : Release
  -- Compile definitions : ONNX_ML=1;ONNXIFI_ENABLE_EXT=1;ONNX_NAMESPACE=onnx_torch;_CRT_SECURE_NO_DEPRECATE=1;USE_EXTERNAL_MZCRC;MINIZ_DISABLE_ZIP_READER_CRC32_CHECKS;WIN32_LEAN_AND_MEAN;_UCRT_LEGACY_INFINITY;NOMINMAX;USE_MIMALLOC;BUILD_NVFUSER
  -- CMAKE_PREFIX_PATH : D:\workspace\envs\py38_torch1.13.1_cuda11.6\Lib\site-packages;C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.6
  -- CMAKE_INSTALL_PREFIX : D:/workspace/codes/pytorch/torch
  -- USE_GOLD_LINKER : OFF
  --
  -- TORCH_VERSION : 2.1.0
  -- BUILD_CAFFE2 : OFF
  -- BUILD_CAFFE2_OPS : OFF
  -- BUILD_STATIC_RUNTIME_BENCHMARK: OFF
  -- BUILD_TENSOREXPR_BENCHMARK: OFF
  -- BUILD_NVFUSER_BENCHMARK: OFF
  -- BUILD_BINARY : OFF
  -- BUILD_CUSTOM_PROTOBUF : ON
  -- Link local protobuf : ON
  -- BUILD_DOCS : OFF
  -- BUILD_PYTHON : True
  -- Python version : 3.8.18
  -- Python executable : D:/workspace/envs/py38_torch1.13.1_cuda11.6/python.exe
  -- Pythonlibs version : 3.8.18
  -- Python library : D:/workspace/envs/py38_torch1.13.1_cuda11.6/libs/python38.lib
  -- Python includes : D:/workspace/envs/py38_torch1.13.1_cuda11.6/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 :
  -- TRACING_BASED : OFF
  -- USE_BLAS : 0
  -- USE_LAPACK : 0
  -- USE_ASAN : OFF
  -- USE_TSAN : OFF
  -- USE_CPP_CODE_COVERAGE : OFF
  -- USE_CUDA : ON
  -- Split CUDA :
  -- CUDA static link : OFF
  -- USE_CUDNN : ON
  -- USE_EXPERIMENTAL_CUDNN_V8_API: ON
  -- USE_CUSPARSELT : OFF
  -- CUDA version : 11.6
  -- USE_FLASH_ATTENTION : ON
  -- cuDNN version : 8.9.5
  -- CUDA root directory : C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.6
  -- CUDA library : C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.6/lib/x64/cuda.lib
  -- cudart library : C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.6/lib/x64/cudart.lib
  -- cublas library : C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.6/lib/x64/cublas.lib
  -- cufft library : C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.6/lib/x64/cufft.lib
  -- curand library : C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.6/lib/x64/curand.lib
  -- cusparse library : C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.6/lib/x64/cusparse.lib
  -- cuDNN library : C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.6/lib/x64/cudnn.lib
  -- nvrtc : C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.6/lib/x64/nvrtc.lib
  -- CUDA include path : C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.6/include
  -- NVCC executable : C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.6/bin/nvcc.exe
  -- CUDA compiler : C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.6/bin/nvcc.exe
  -- CUDA flags : -D_WINDOWS -Xcompiler=" /GR /EHsc" -Xcompiler /w -w -Xcompiler /FS -Xfatbin -compress-all -DONNX_NAMESPACE=onnx_torch --use-local-env -gencode arch=compute_86,code=sm_86 -gencode arch=compute_61,code=sm_61 -Xcudafe --diag_suppress=cc_clobber_ignored,--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=bad_friend_decl --Werror cross-execution-space-call --no-host-device-move-forward --expt-relaxed-constexpr --expt-extended-lambda -Xcompiler=/wd4819,/wd4503,/wd4190,/wd4244,/wd4251,/wd4275,/wd4522 -Wno-deprecated-gpu-targets --expt-extended-lambda -DCUB_WRAPPED_NAMESPACE=at_cuda_detail -DCUDA_HAS_FP16=1 -D __CUDA_NO_HALF_OPERATORS__ -D __CUDA_NO_HALF_CONVERSIONS__ -D __CUDA_NO_HALF2_OPERATORS__ -D __CUDA_NO_BFLOAT16_CONVERSIONS__
  -- CUDA host compiler :
  -- CUDA --device-c : OFF
  -- USE_TENSORRT : OFF
  -- USE_ROCM : OFF
  -- BUILD_NVFUSER : ON
  -- USE_EIGEN_FOR_BLAS : ON
  -- 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_MPS : OFF
  -- USE_FFTW : OFF
  -- USE_MKL : OFF
  -- USE_MKLDNN : ON
  -- USE_MKLDNN_ACL : OFF
  -- USE_MKLDNN_CBLAS : OFF
  -- USE_UCC : OFF
  -- USE_ITT : ON
  -- 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_MIMALLOC : ON
  -- USE_VULKAN : OFF
  -- USE_PROF : OFF
  -- USE_QNNPACK : OFF
  -- USE_PYTORCH_QNNPACK : OFF
  -- USE_XNNPACK : ON
  -- 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
  -- Public Dependencies :
  -- Private Dependencies : Threads::Threads;pthreadpool;cpuinfo;XNNPACK;fbgemm;ittnotify;fp16;caffe2::openmp;gloo;foxi_loader;fmt::fmt-header-only;kineto
  -- Public CUDA Deps. : caffe2::cufft;caffe2::curand;caffe2::cublas
  -- Private CUDA Deps. : torch::cudnn;gloo_cuda;C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.6/lib/x64/cudart_static.lib;CUDA::cusparse;CUDA::curand;CUDA::cufft;CUDA::cusolver;ATEN_CUDA_FILES_GEN_LIB
  -- USE_COREML_DELEGATE : OFF
  -- BUILD_LAZY_TS_BACKEND : ON
  -- TORCH_DISABLE_GPU_ASSERTS : OFF
  -- Configuring done
  -- Generating done

```

The build goes well at the beginning. but when it comes `caffe2` module, a fatal error occurs：

```auto
D:/workspace/codes/pytorch\c10/util/C++17.h(27): fatal error C1189: #error: You need C++17 to compile PyTorch

```

It seems that the cmake try to enable c++17 by adding `-std=c++17` flag instead of `/std:c++17`:

```auto
FAILED: caffe2/CMakeFiles/torch_cuda.dir/__/aten/src/ATen/cuda/cub.cu.obj
C:\PROGRA~1\NVIDIA~2\CUDA\v11.6\bin\nvcc.exe -forward-unknown-to-host-compiler -DAT_PER_OPERATOR_HEADERS -DMINIZ_DISABLE_ZIP_READER_CRC32_CHECKS -DNOMINMAX -DONNXIFI_ENABLE_EXT=1 -DONNX_ML=1 -DONNX_NAMESPACE=onnx_torch -DTORCH_CUDA_BUILD_MAIN_LIB -DUSE_C10D_GLOO -DUSE_CUDA -DUSE_DISTRIBUTED -DUSE_EXPERIMENTAL_CUDNN_V8_API -DUSE_EXTERNAL_MZCRC -DUSE_FLASH_ATTENTION -DUSE_MIMALLOC -DWIN32_LEAN_AND_MEAN -D_CRT_SECURE_NO_DEPRECATE=1 -D_UCRT_LEGACY_INFINITY -Dtorch_cuda_EXPORTS -ID:\workspace\codes\pytorch\build\aten\src -ID:\workspace\codes\pytorch\aten\src -ID:\workspace\codes\pytorch\build -ID:\workspace\codes\pytorch -ID:\workspace\codes\pytorch\cmake\..\third_party\benchmark\include -ID:\workspace\codes\pytorch\third_party\onnx -ID:\workspace\codes\pytorch\build\third_party\onnx -ID:\workspace\codes\pytorch\third_party\foxi -ID:\workspace\codes\pytorch\build\third_party\foxi -ID:\workspace\codes\pytorch\third_party\mimalloc\include -ID:\workspace\codes\pytorch\aten\src\THC -ID:\workspace\codes\pytorch\aten\src\ATen\cuda -ID:\workspace\codes\pytorch\aten\src\ATen\..\..\..\third_party\cutlass\include -ID:\workspace\codes\pytorch\build\caffe2\aten\src -ID:\workspace\codes\pytorch\aten\src\ATen\.. -ID:\workspace\codes\pytorch\c10\cuda\..\.. -ID:\workspace\codes\pytorch\c10\.. -ID:\workspace\codes\pytorch\torch\csrc\api -ID:\workspace\codes\pytorch\torch\csrc\api\include -isystem=D:\workspace\codes\pytorch\build\third_party\gloo -isystem=D:\workspace\codes\pytorch\cmake\..\third_party\gloo -isystem=D:\workspace\codes\pytorch\cmake\..\third_party\googletest\googlemock\include -isystem=D:\workspace\codes\pytorch\cmake\..\third_party\googletest\googletest\include -isystem=D:\workspace\codes\pytorch\third_party\protobuf\src -isystem=D:\workspace\codes\pytorch\third_party\XNNPACK\include -isystem=D:\workspace\codes\pytorch\third_party\ittapi\include -isystem=D:\workspace\codes\pytorch\cmake\..\third_party\eigen -isystem="C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.6\include" -isystem=D:\workspace\codes\pytorch\third_party\ideep\mkl-dnn\include\oneapi\dnnl -isystem=D:\workspace\codes\pytorch\third_party\ideep\include -isystem="C:\Program Files\NVIDIA Corporation\NvToolsExt\include" -isystem=D:\workspace\codes\pytorch\cmake\..\third_party\cudnn_frontend\include -D_WINDOWS -Xcompiler=" /GR /EHsc" -Xcompiler /w -w -Xcompiler /FS -Xfatbin -compress-all -DONNX_NAMESPACE=onnx_torch --use-local-env -gencode arch=compute_86,code=sm_86 -gencode arch=compute_61,code=sm_61 -Xcudafe --diag_suppress=cc_clobber_ignored,--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=bad_friend_decl --Werror cross-execution-space-call --no-host-device-move-forward --expt-relaxed-constexpr --expt-extended-lambda -Xcompiler=/wd4819,/wd4503,/wd4190,/wd4244,/wd4251,/wd4275,/wd4522 -Wno-deprecated-gpu-targets --expt-extended-lambda -DCUB_WRAPPED_NAMESPACE=at_cuda_detail -DCUDA_HAS_FP16=1 -D __CUDA_NO_HALF_OPERATORS__ -D __CUDA_NO_HALF_CONVERSIONS__ -D __CUDA_NO_HALF2_OPERATORS__ -D __CUDA_NO_BFLOAT16_CONVERSIONS__ -Xcompiler="-O2 -Ob2" -DNDEBUG -Xcompiler /MD -Xcompiler=-MD -DCAFFE2_USE_GLOO -DTH_HAVE_THREAD -Xcompiler= -std=c++17 -MD -MT caffe2\CMakeFiles\torch_cuda.dir\ __\aten\src\ATen\cuda\cub.cu.obj -MF caffe2\CMakeFiles\torch_cuda.dir\__ \aten\src\ATen\cuda\cub.cu.obj.d -x cu -c D:\workspace\codes\pytorch\aten\src\ATen\cuda\cub.cu -o caffe2\CMakeFiles\torch_cuda.dir\__\aten\src\ATen\cuda\cub.cu.obj -Xcompiler=-Fdcaffe2\CMakeFiles\torch_cuda.dir\,-FS
cl: 命令行 warning D9002 :忽略未知选项“-std=c++17”

```

So I try add `/std:c++17` to `${CMAKE_CXX_FLAGS}` . But this seems not work.  
Is there any configs are missed in this process? Hope someone can give me some help or tips.

Thanks.

---

<div class="post-metadata">

**Author:** ![julienw](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/julienw/32/63566_2.png) [@julienw](https://discuss.pytorch.org/u/julienw)\
**Post date:** [November 20, 2023, 6:34am UTC](https://discuss.pytorch.org/t/enable-c-17-failed-when-build-pytorch-from-source-on-windows/189959/2 "2023-11-20T06:34:36Z")

</div>

I got exactly the same error when trying to build the cuda version on Windows. I would really appreciate it if anyone could help me out here.

---

<div class="post-metadata">

**Author:** ![Subham](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/subham/32/61931_2.png) [@Subham](https://discuss.pytorch.org/u/Subham)\
**Post date:** [May 4, 2024, 9:33am UTC](https://discuss.pytorch.org/t/enable-c-17-failed-when-build-pytorch-from-source-on-windows/189959/3 "2024-05-04T09:33:22Z")

</div>

Hi, did you solve this yet?

---

<div class="post-metadata">

**Author:** ![Subham](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/subham/32/61931_2.png) [@Subham](https://discuss.pytorch.org/u/Subham)\
**Post date:** [May 4, 2024, 9:34am UTC](https://discuss.pytorch.org/t/enable-c-17-failed-when-build-pytorch-from-source-on-windows/189959/4 "2024-05-04T09:34:00Z")

</div>

Hi, did you solve this yet? Can you help me with this same error?
