我通过从 multiverse 获取 python-pyopencl 并安装 amd app sdk 在我的笔记本电脑上设置了 pyopencl。为了获取 Nvidia ICD,我从驱动程序管理器重新安装了最新的 Nvidia 驱动程序。
我的系统是 Thinkpad t540p、i7 4700hq、Nvidia gt 730m、64 位 Ubuntu 14.04
为了测试 opencl 安装,我运行了这个 pyopencl 示例:http://wiki.tiker.net/PyOpenCL/Examples/MatrixMultiply
不幸的是,性能非常糟糕:只有 2 GFlop/s。当然,笔记本电脑可以做得更好。所以我打印了供应商信息。它是“GenuineIntel”,显然内核不是在GPU上运行,而是在CPU上运行。我怎样才能改变它?
pyopencl 似乎找不到 GPU。
for dev in ctx.devices:
print dev.vendor
这仅返回“GenuineIntel”
上下文是通过以下方式创建的:
import pyopencl as cl
ctx=cl.create_some_context()
更新:
这似乎是以下内容的重复:ERROR: pyopencl: creating context for specific device
最佳答案
这里有两个问题。
首先,您应该指定 GPU 作为执行内核的设备。替换:
ctx = cl.create_some_context()
与:
platform = cl.get_platforms()
gpus = platform[0].get_devices(device_type=cl.device_type.GPU)
ctx = cl.Context(devices=gpus)
其次,您似乎拥有 Optimus 可切换显卡,因此 NVIDIA 卡实际上处于待机状态,所有图形任务都由 CPU 处理以节省电量。您需要使用 Bumblebee 启动程序来激活程序的独立 GPU:
optirun python yourscript.py
关于python - 为什么不在我的 GPU 上运行 OpenCL (Ubuntu),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24970265/