Published on

HelloCuda 系列 第四章: CUDA Profiling

  • nvprof
nvprof --metrics achieved_occupancy,kernel_duration ./a.out
  • Check Available Memory
   size_t freeMem, totalMem;
   cudaError_t err = cudaMemGetInfo(&freeMem, &totalMem);

   if (err != cudaSuccess) {
      fprintf(stderr, "Error: %s\n", cudaGetErrorString(err));
      exit(EXIT_FAILURE);
   }

   printf("可用显存: %.2f MB, 总显存: %.2f MB\n", 
         freeMem/1024.0/1024.0, 
         totalMem/1024.0/1024.0);

THE END