gpu - 如何让 SYCL“default_selector”选择 Intel GPU 而不是 NVIDIA GPU?
问题描述
我目前正在使用 SYCL 对图像应用非锐化蒙版的项目。我的机器里面有一个 NVIDIA 和一个 Intel GPU。我从以下代码开始:
default_selector deviceSelector;
queue myQueue(deviceSelector);
问题是代码行“default_selector deviceSelector;” 自动抓取我机器内的 NVIDIA GPU,这会破坏后面的所有代码,因为 SYCL 不适用于 NVIDIA。
因此我的问题是 - 我如何强制“default_selector deviceSelector;” 获取我的 Intel GPU 而不是 NVIDIA GPU?也许我可以这样说:
if (device.has_extension(cl::sycl::string_class("Intel")))
if (device.get_info<info::device::device_type>() == info::device_type::gpu)
then select this GPU;//pseudo code
从而使代码跳过NVIDIA GPU并保证选择我的Intel GPU。
解决方案
您正在检查扩展是否包含一个名为“Intel”的条目,但它不会。扩展是设备支持的东西,比如 SPIR-V 你可以通过在命令行调用 clinfo 来查看支持的扩展。要选择英特尔 GPU,您需要检查设备制造商以选择正确的。
所以在自定义设备选择的示例代码中https://github.com/codeplaysoftware/computecpp-sdk/blob/master/samples/custom-device-selector.cpp#L46
你只需要有类似的东西
if (device.get_info<info::device::name>() == "Name of device") {
return 100;
}
你可以打印出价值
device.get_info<info::device::name>
获取要检查的值。
推荐阅读
- kubernetes-helm - helm 中的 initdbScripts 参数
- spring-boot - 如何获取嵌入式 Redis 指标?
- omnet++ - 用inet实现一种看门狗
- c - 用C语言从文件中读取分离的数据到不同的数据类型
- javascript - 当状态改变时停止重新渲染的方法?(反应原生)
- php - Laravel 使用 Carbon::now() 保存数据的格式与 created_at 不同
- python - 有没有办法在 PuLP 优化中从字符串调用 LpVariables?
- c++ - 有没有办法使用谷歌云客户端库将文件从 FTP 上传到 GCS?
- javascript - 使用路由器 Vuetify 选项卡 - tab.isActive 始终为 false
- asp.net-mvc - 部署在虚拟文件夹中时无法访问 MVC 应用程序静态文件