Start CUDA Debugging greyed out in cmake project on VS2022

I’m struggling in debugging a CUDA code within a cmake project on VS2022. Specifically, I open a cmake project in VS2022 and build it with ‘-G’ nvcc flag. But I can’t debug into the kernel code. Meanwhile I can’t click “Start CUDA Debugging” in “Extension->Nsight” because it greyed out.

My toy cmake project only contain a hello.cu and a CMakeLists.txt.

cmake_minimum_required(VERSION 3.18 FATAL_ERROR)
project(hello LANGUAGES CUDA)
add_executable(hello hello.cu)
target_compile_options(hello PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:-G>)

VisualStudio 2022; Nsight 2022; CUDA Toolkit 11.7

Faced same issue with same setup. Additionally, i had created VS project based on MSBuild with (cuda snippet) and got debug toolchain available, but, ‘Start CUDA Debugging (nextgen)’ led to endless waiting for a breakpoint. After manual stop debug launch button was no longer enabled.

VS summary

Microsoft Visual Studio Community 2022
Version 17.3.3
VisualStudio.17.Release/17.3.3+32825.248
Microsoft .NET Framework
Version 4.8.04084

Installed Version: Community

Visual C++ 2022 00482-90000-00000-AA424
Microsoft Visual C++ 2022

ASP.NET and Web Tools 17.3.376.3011
ASP.NET and Web Tools

Azure App Service Tools v3.0.0 17.3.376.3011
Azure App Service Tools v3.0.0

C# Tools 4.3.0-3.22423.10+b35bb0baca1071d50cc4f8cf5a1a89e7cc112461
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Linux Core Dump Debugging 1.0.9.32708
Enables debugging of Linux core dumps.

Microsoft JVM Debugger 1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

NuGet Package Manager 6.3.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/

NVIDIA CUDA 11.7 Wizards 11.7
Wizards to create new NVIDIA CUDA projects and source files.

NVIDIA Nsight Visual Studio Edition 2022.2.1.22136
NVIDIA Nsight Visual Studio Edition provides tools for GPGPU and graphics development. Copyright © NVIDIA 2010 - 2022.
•Direct3D® and DirectX® are registered trademarks of Microsoft Corporation in the United States and/or other countries.
•Microsoft Detours is used under the Professional license (http://research.microsoft.com/en-us/projects/detours/).
•Gardens Point Parser Generator Copyright 2005 Queensland University of Technology (QUT). All rights reserved.
•Icons from Axialis Software used under the licensing terms found here: www.axialis.com
•NLog Copyright © 2004-2006 Jaroslaw Kowalski (jaak@jkowalski.net)
•zlib and libpng used under the zlib/libpnc license (The zlib/libpng License (Zlib) | Open Source Initiative)
•Breakpad Copyright ©2006, Google Inc. All rights reserved.
•The OpenGL Extension Wrangler Library
Copyright ©2008-2016, Nigel Stewart (nigels@users.sourceforge.net), Copyright ©2002-2008, Milan Ikits (milan.ikits@ieee.org), Copyright ©2002-2008, Marcelo E. Magallon (mmagallo@debian.org), Copyright ©2002, Lev Povalahev.
All rights reserved.
•LIBSSH2 Copyright ©2004-2007 Sara Golemon (sarag@libssh2.org), Copyright ©2005,2006 Mikhail Gusarov (dottedmag@dottedmag.net),Copyright ©2006-2007 The Written Word, Inc.,Copyright ©2007 Eli Fant (elifantu@mail.ru),Copyright ©2009-2014 Daniel Stenberg., Copyright ©2008, 2009 Simon Josefsson.
All rights reserved.
•Protobuf Copyright ©2014, Google Inc. All rights reserved.
•xxHASH Library Copyright ©2012-2014, Yann Collet. All rights reserved.
•FMT Copyright ©2012 - 2016, Victor Zverovich
•Font Awesome Copyright 2018 Fonticons, Inc.
•ELF Definitions Copyright (c) 2010 Joseph Koshy, All rights reserved.

Warning: This computer program is protected by copyright law and international treaties. Unauthorized reproduction or distribution of this program, or any portion of it, may result in severe civil and criminal penalties, and will be prosecuted to the maximum extent possible under the law.

NVIDIA Nsight Visual Studio Edition - CUDA support 2022.2.1.22136
NVIDIA Nsight Visual Studio Edition - CUDA support provides tools for CUDA development and debugging.

Test Adapter for Boost.Test 1.0
Enables Visual Studio’s testing tools with unit tests written for Boost.Test. The use terms and Third Party Notices are available in the extension installation directory.

Test Adapter for Google Test 1.0
Enables Visual Studio’s testing tools with unit tests written for Google Test. The use terms and Third Party Notices are available in the extension installation directory.

TypeScript Tools 17.0.10701.2001
TypeScript Tools for Microsoft Visual Studio

Visual Basic Tools 4.3.0-3.22423.10+b35bb0baca1071d50cc4f8cf5a1a89e7cc112461
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual C++ for Linux Development 1.0.9.32708
Visual C++ for Linux Development

Visual Studio IntelliCode 2.2
AI-assisted development for Visual Studio.

@michael.ky I am facing a similar issue and using a VS-based project does not help:

Nsight Visual Studio Edition 2022.2 error: debugging buttons greyed out, Nsight Monitor does not autolaunch, Nsight Monitor shows 0 connections - Development Tools / Nsight Visual Studio Edition - NVIDIA Developer Forums