What does cudadevicereset() do in relation to CUDA runtime API?

Asked 2 years ago, Updated 2 years ago, 98 views

What is the role of cudaDeviceReset();? Does the printf contained in the kernel run only if it has a cudaDeviceReset(); acting like cudaMemcpy?

I wonder what changes if I write cudaDeviceReset(); cudaDeviceSynchronize(); instead.

#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>

__global__ void funct(void){
    printf("Hello from GPU!\n");
}

int main(void){
    funct << < 2, 4 >> >();


    printf("Hello, World from CPU!\n");
        cudaDeviceReset();  

    return 0;
}

cuda

2022-09-22 21:58

1 Answers

Note: What is Cuda? It is a parallel computing platform and API created by NVIDIA. It allows developers to process computations using graphics cards (GPU) with CUDA functions.

Below is an answer to the same question in stackoverflow, which is translated (multiple translations).

Use cudaDeviceReset() to remove all resource allocations. cudaDeviceReset() also has the effect of synchronizing. However, the API document says that it will be reset immediately, so there is no guarantee that it will be reset after the synchronize is complete. Therefore, for safe use, it is recommended that you use it as follows.


2022-09-22 21:58

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.