NVIDIA / cuda-samples

Samples for CUDA Developers which demonstrates features in CUDA Toolkit
Other
6.49k stars 1.84k forks source link

Nsight CLI doesn't record any CUDA Event Traceback #213

Closed ElinLiu0 closed 1 year ago

ElinLiu0 commented 1 year ago

Hi there: This is my first time to using Nsight System to profiling a GPU program,here is my project strcture looks like below:

(base) elin@ElinStation:~/dataStrcture/final$ tree -L 3
.
├── bin
│   ├── main.cuo
│   ├── main.ptx
│   └── profile
├── include
│   ├── cuda
│   │   └── custring.cuh
│   └── host
│       └── cudaCalls.cuh
├── makefile
├── report1.nsys-rep
├── run.sh
└── src
    └── main.cu

5 directories, 9 files
(base) elin@ElinStation:~/dataStrcture/final$ 

Oh,btw this project were running and compiled on my WSL vm.

The main.cu looks like this:

#include <stdio.h>
#include <stdlib.h>
#include <cuda.h>
#include <string.h>
#include <cuda_runtime.h>
#include "../include/host/cudaCalls.cuh"

int main(void)
{
    // create CUDA Event
    cudaEvent_t start, stop;
    cudaEventCreate(&start);
    cudaEventCreate(&stop);
    // Record start
    cudaEventRecord(start, 0);
    char *str = "Hello World";
    const unsigned int beginIndex = 6;
    const unsigned int endIndex = 10;
    char *subHost = getSubStringHost(str, beginIndex, endIndex);
    printf("Substring from %d to %d is %s\n", beginIndex, endIndex, subHost);
    char *reverseHost  = reverseStringHost(str);
    printf("Reverse of %s is %s\n", str, reverseHost);
    deleteSubStringHost(subHost,3,5);
    printf("After deleting substring from 3 to 5, string is %s\n", subHost);
    str = replaceHost(str, "World", "CUDA");
    printf("After replacing World with CUDA, string is %s\n", str);
    insertHost(str, "Hello", 5);
    cudaEventRecord(stop, 0);
    cudaEventSynchronize(stop);
    float elapsedTime;
    cudaEventElapsedTime(&elapsedTime, start, stop);
    printf("Time to generate:  %3.1f ms\n", elapsedTime);
    cudaEventDestroy(start);
    cudaEventDestroy(stop);
    return 0;
}

all the function with "Host" ending is came from the "cudaCalls.cuh" file,which is a collection of CUDA Kernel calls. And my makefile looks like this:

all:generate ptx info
generate:
    nvcc -O3 -rdc=true ./src/main.cu -o ./bin/main.cuo 
ptx:
    nvcc -ptx ./src/main.cu -o ./bin/main.ptx
info:
    nvcc -rdc=true ./src/main.cu -o ./bin/profile --generate-line-info

After all this compiled done,here i use below command to generate report:

nsys profile --trace=cuda ./bin/profile

Then when i using Host Nsight System to open this record,there is the screen shot below: image No cuda pipeline record at all,so what is the problem there?Should i change some command line or source code.This is my first using Nsight so it looks like kind nuts lol,so just bring me your suggestion plz,thanks alot :)

ElinLiu0 commented 1 year ago

Closing it by mismatched host CUDA version and WSL CUDA version,this cause Nsight doesn't recognize maybe.