cuda - 有没有办法以编程方式知道我们的 CUDA 代码在哪个 GPU 上运行?
问题描述
我想知道我的 CUDA 内核将在哪个 GPU 上运行,以便我可以以编程方式决定要使用的最佳块大小,以最大限度地提高任何算法的 GPU 实现的性能。
解决方案
Yes, the deviceQuery sample code demonstrates how to query the device for information such as the number of SMs which could be used to optimize kernel launch configuration.
In addition, CUDA provides an occupancy API which demonstrates how to construct thread block sizes that can yield highest occupancy. There is a sample code also.
If you have 3 GPU devices, and you don't make use of the cudaSetDevice()
API in your code to select a particular GPU, then CUDA will run your code on the first GPU enumerated by CUDA, which is the same as the first GPU displayed by the deviceQuery
sample code.
推荐阅读
- python - Ansible 和 python 实现
- android - Android 单元测试 Mockito 返回 null
- c# - 如何从 .NET Core 中的 appsettings.json 读取节值
- java - 如何使用单选按钮更改android应用程序中的设置?
- mysql - 从 MySQL 获取每小时数据
- javascript - 导入的网格没有碰撞 - Babylon.js
- algorithm - 如何以每位球员的最大休息时间对循环赛进行排序?
- reactjs - 如何在 React 中使用 React-Map-GL 使 Geojson 图层可拖动?
- image - 将多个图像转换为 JPG 时出错
- laravel - 在 laravel 集合中使用 where 后缺少分页信息