"Not in executable format: file format not recognized" when attempting to debug with NVSC

I am trying to debug my CUDA code on a remote server using VSCode from my local machine. The server has Ubuntu 18.04 os, two Quadro RTX 6000 GPUs, dirver version 455.45.01 and CUDA 11.1.

My task.json file is the following

    "version": "2.0.0",
    "tasks": [
            "label": "CUDA",
            "type": "shell",
            "command": "make dbg=1",
            "problemMatcher": ["$nvcc"],
            "group": {
                "kind": "build",
                "isDefault": true

My launch.json file is the following:

    "version": "0.2.0",
    "configurations": [
            "name": "CUDA C++: Launch",
            "type": "cuda-gdb",
            "request": "launch",
            "program": "${workspaceFolder}/test.cu"

When I pressed F5 for debugging, an error occurs which says “Not in executable format: file format not recognized”. How do I resolve this issue? Thanks!

The problem is you specified test.cu but that’s the source, not the executable program. What’s the name of the executable that’s produced by your build system? That will be your program.

Thanks for the response. When I ran “Tasks: Run Build Task”, I got the following:

make: *** No targets specified and no makefile found. Stop.
The terminal process “bash ‘-c’, ‘make dbg=1’” terminated with exit code: 2.

and no executable was generated. How do I solve this issue?

You can add a tasks.json for your build tasks, you can find details at Integrate with External Tools via Tasks. You can also build on the command-line with whatever build system you are using and then in the launch.json point "program" at your built executable. Then you should be able to debug as long as you built with debug information, for more details on that see Debug Compilation.