Libtorch with c++23 giving CUDA23 error

Libtorch: libtorch CUDA12.1 nightly build
OS: Windows
CUDA: 12.1

With C++ set to version 23, I’m getting an error stating that Target "cmTC_f8cbf" requires the language dialect "CUDA23" . But the current compiler "NVIDIA" does not support this, or CMake does not know the flags to enable it.

Works fine with C++20 set(CMAKE_CXX_STANDARD 20) but not 23.

CMake error:

  Target "cmTC_f8cbf" requires the language dialect "CUDA23" .  But the
  current compiler "NVIDIA" does not support this, or CMake does not know the
  flags to enable it.


CMake Error at C:/DevDependencies/libtorch-win-shared-with-deps-latest/libtorch/share/cmake/Caffe2/Modules_CUDA_fix/upstream/FindCUDA/select_compute_arch.cmake:106 (try_run):
  Failed to generate test project build system.
Call Stack (most recent call first):
  C:/DevDependencies/libtorch-win-shared-with-deps-latest/libtorch/share/cmake/Caffe2/Modules_CUDA_fix/upstream/FindCUDA/select_compute_arch.cmake:166 (CUDA_DETECT_INSTALLED_GPUS)
  C:/DevDependencies/libtorch-win-shared-with-deps-latest/libtorch/share/cmake/Caffe2/public/utils.cmake:401 (cuda_select_nvcc_arch_flags)
  C:/DevDependencies/libtorch-win-shared-with-deps-latest/libtorch/share/cmake/Caffe2/public/cuda.cmake:325 (torch_cuda_get_nvcc_gencode_flag)
  C:/DevDependencies/libtorch-win-shared-with-deps-latest/libtorch/share/cmake/Caffe2/Caffe2Config.cmake:87 (include)
  C:/DevDependencies/libtorch-win-shared-with-deps-latest/libtorch/share/cmake/Torch/TorchConfig.cmake:68 (find_package)
  CMakeLists.txt:27 (find_package)


-- Configuring incomplete, errors occurred!

Does anyone manage to get libtorch working with C++23?

CUDA12 supports up to C++20 as described here so the limitation is expected.

1 Like

Can I compile PyTorch 2.0.1 or the nightly build with C++20 on the M1 Mac platform?