簡體   English   中英

AttributeError:'CommandQueue'對象沒有屬性'dtype'

[英]AttributeError: 'CommandQueue' object has no attribute 'dtype'

我正在嘗試使用pyFFT計算FFT。 但是以下代碼會導致錯誤。

self.ctx = cl.create_some_context(interactive=False)            
self.queue = cl.CommandQueue(self.ctx)   
self.plan = Plan(fft_size, self.queue)   
gpu_data0 = cl_array.to_device(self.ctx, self.queue, ref_input)   

ref_input的類型為:

< type 'numpy.ndarray' >

調試輸出:

< pyopencl._cl.CommandQueue object at 0x7f0686c10628 >    
['__class__', '__delattr__', '__dict__', '__doc__', '__enter__', '__eq__', 
 '__exit__','__format__', '__getattribute__', '__hash__', '__init__', 
 '__instance_size__', '__module__', '__ne__', '__new__', '__reduce__', 
 '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', 
 '__subclasshook__', '__weakref__', '_get_cl_version', 'context', 'device', 
 'finish', 'flush', 'from_int_ptr', 'get_info', 'int_ptr', 'properties',    
 'reference_count']   

Traceback (most recent call last):
   File "../dsp.py", line 200, in gpu_fft
     gpu_data0 = cl_array.to_device(self.ctx, self.queue, ref_data)
   File "/usr/lib/python2.7/dist-packages/pyopencl/array.py", line 1446, in to_device
     if ary.dtype == object:
 AttributeError: 'CommandQueue' object has no attribute 'dtype'

實際上我找不到'dtype'。 但為什么?

根據文檔,函數pyopencl.array.to_device不將上下文作為參數。 使用此代替:

gpu_data0 = cl_array.to_device(self.queue, ref_input)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM