我無法讓內核在兩個不同的OpenCL平臺上運行。在平臺上的唯一區別是一個的OpenCL 1.1和其他1.2這樣:PyOpenCL enqueue_copy在不同設備上運行時掛起
代碼工作在這個裝置上(OS X 10.8):
===============================================================
('Platform name:', 'Apple')
('Platform profile:', 'FULL_PROFILE')
('Platform vendor:', 'Apple')
('Platform version:', 'OpenCL 1.2 (Sep 20 2012 17:42:28)')
---------------------------------------------------------------
('Device name:', 'Intel(R) Core(TM) i5-3427U CPU @ 1.80GHz')
('Device type:', 'CPU')
('Device memory: ', 8192L, 'MB')
('Device max clock speed:', 1800, 'MHz')
('Device compute units:', 4)
目標設備(Ubuntu的11.04):
===============================================================
('Platform name:', 'NVIDIA CUDA')
('Platform profile:', 'FULL_PROFILE')
('Platform vendor:', 'NVIDIA Corporation')
('Platform version:', 'OpenCL 1.1 CUDA 4.2.1')
---------------------------------------------------------------
('Device name:', 'Tesla M2050')
('Device type:', 'GPU')
('Device memory: ', 3071, 'MB')
('Device max clock speed:', 1147, 'MHz')
('Device compute units:', 14)
===============================================================
('Platform name:', 'NVIDIA CUDA')
('Platform profile:', 'FULL_PROFILE')
('Platform vendor:', 'NVIDIA Corporation')
('Platform version:', 'OpenCL 1.1 CUDA 4.2.1')
---------------------------------------------------------------
('Device name:', 'Tesla M2050')
('Device type:', 'GPU')
('Device memory: ', 3071, 'MB')
('Device max clock speed:', 1147, 'MHz')
('Device compute units:', 14)
我跟蹤了我認爲的掛在下面的代碼來源:
# set up
host_array = numpy.array(arr)
device_buffer = pyopencl.Buffer(context, pyopencl.mem_flags.WRITE_ONLY, host_array.nbytes)
# run the kernel
program.run(queue, host_array.shape, None, device_buffer)
# copy the results back --- this call causes the code to hang ----
pyopencl.enqueue_copy(queue, host_array, device_buffer)
有一請注意兩臺設備之間沒有代碼更改,兩臺設備都運行PyOpenCL 2013.1。我錯過了什麼嗎?任何建議,非常感謝。
我嘗試添加一個'.wait()''到program.run'以及從調用'program.run'接收的'event'對象,但該方案仍然在enqueue_copy'的'第一呼叫掛起(我在兩次調用之間使用了一個「print」)。 – Justin
如果不運行內核,掛起是否也會發生? –
是的。原來是pyopencl之外的線程問題。 – Justin