Hello world.
I’m trying to get the example notebook ‘resizer_pl.pynb’ working but I’m having trouble around where the allocate() function call occurs.
For reference, I am using Ubuntu 22.04 on the KR260 with the FW 1.04. I did see that 22.04 should use 1.02 to get DP working, but I don’t think that this is related.
I flashed 22.04 on my SD card and updated it using the instructions here, and then using the install.sh file in the git repo according to the instructions here.
After restarting, I logged into Jupyter notebooks and tried to run the code in the notebook and got the following output, shown below:
resize_factor = 2
new_width = int(old_width/resize_factor)
new_height = int(old_height/resize_factor)
We now allocate memory to process data on PL. Data is provided as contiguous memory blocks. The size of the buffer depends on the size of the input or output data. The image dimensions extracted from the read image are used to allocate contiguous memory blocks.
We will call allocate() to perform the allocation.
in_buffer = allocate(shape=(old_height, old_width, 3), 
                           dtype=np.uint8, cacheable=1)
out_buffer = allocate(shape=(new_height, new_width, 3), 
                            dtype=np.uint8, cacheable=1)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Input In [7], in <cell line: 1>()
----> 1 in_buffer = allocate(shape=(old_height, old_width, 3), 
      2                            dtype=np.uint8, cacheable=1)
      3 out_buffer = allocate(shape=(new_height, new_width, 3), 
      4                             dtype=np.uint8, cacheable=1)
File /usr/local/share/pynq-venv/lib/python3.10/site-packages/pynq/buffer.py:158, in allocate(shape, dtype, target, **kwargs)
    156 if target is None:
    157     target = Device.active_device
--> 158 return target.allocate(shape, dtype, **kwargs)
File /usr/local/share/pynq-venv/lib/python3.10/site-packages/pynq/pl_server/device.py:145, in Device.allocate(self, shape, dtype, **kwargs)
    127 def allocate(self, shape, dtype, **kwargs):
    128     """Allocate an array on the device
    129 
    130     Returns a buffer on memory accessible to the device
   (...)
    143 
    144     """
--> 145     return self.default_memory.allocate(shape, dtype, **kwargs)
File /usr/local/share/pynq-venv/lib/python3.10/site-packages/pynq/pl_server/xrt_device.py:156, in XrtMemory.allocate(self, shape, dtype, **kwargs)
    145 def allocate(self, shape, dtype, **kwargs):
    146     """Create a new  buffer in the memory bank
    147 
    148     Parameters
   (...)
    154 
    155     """
--> 156     buf = _xrt_allocate(shape, dtype, self.device, self.idx, **kwargs)
    157     buf.memory = self
    158     return buf
File /usr/local/share/pynq-venv/lib/python3.10/site-packages/pynq/pl_server/xrt_device.py:107, in _xrt_allocate(shape, dtype, device, memidx, cacheable, pointer, cache)
    105     buf = device.map_bo(bo)
    106     device_address = device.get_device_address(bo)
--> 107 ar = PynqBuffer(
    108     shape,
    109     dtype,
    110     bo=bo,
    111     device=device,
    112     buffer=buf,
    113     device_address=device_address,
    114     coherent=False,
    115 )
    116 if pointer is not None:
    117     weakref.finalize(buf, _free_bo, device, bo, ar.virtual_address, ar.nbytes)
File /usr/local/share/pynq-venv/lib/python3.10/site-packages/pynq/buffer.py:45, in PynqBuffer.__new__(cls, device, device_address, bo, coherent, *args, **kwargs)
     43 self.coherent = coherent
     44 self.bo = bo
---> 45 self.device = device
     46 self.offset = 0
     47 self.freed = False
AttributeError: attribute 'device' of 'numpy.ndarray' objects is not writable
All of this was after trying to follow the instructions perfectly the second time around; The first time I got the same output but thought that I may have modified something accidentally when I was trying to get something else unrelated to work.
I don’t know if it helps, but I did also notice that the scripts appear to install and uninstall different versions of numpy.
Thanks in advance for your help.