HelloCuda 系列 第四章: CUDA Profiling

2025-06-16 · 约 1 分钟 · 标签: CUDA , 性能分析 , GPU调优
  • 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);
评论
评论功能尚未配置:在 GitHub 仓库开启 Discussions,并按项目 README 里的步骤填好 src/consts.ts 即可启用(基于 Giscus,评论需要 GitHub 账号)。