# How to Work Around Xlnk being used in https://github.com/Xilinx/LSTM-PYNQ

**URL:** <https://discuss.pynq.io/t/how-to-work-around-xlnk-being-used-in-https-github-com-xilinx-lstm-pynq/3810>\
**Category:** Support\
**Created:** [March 9, 2022, 7:49pm UTC](https://discuss.pynq.io/t/how-to-work-around-xlnk-being-used-in-https-github-com-xilinx-lstm-pynq/3810 "2022-03-09T19:49:59Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![savannah](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/savannah/32/3182_2.png) [@savannah](https://discuss.pynq.io/u/savannah)\
**Post date:** [March 9, 2022, 7:49pm UTC](https://discuss.pynq.io/t/how-to-work-around-xlnk-being-used-in-https-github-com-xilinx-lstm-pynq/3810/1 "2022-03-09T19:49:59Z")

</div>

Hi, I am trying to use the PYNQ board for Optical Character Recognition (OCR). I found [this git repo](https://github.com/Xilinx/LSTM-PYNQ) that does exactly what I am looking for; however, it is a few years old and is still using Xlnk.

So, when I try to clone the github, I get the following error in the terminal:

```auto
File "/tmp/pip-req-build-h3_p2379/lstm/lstm.py", line 36, in <module>  
  from pynq import Overlay, PL, Xlnk
ImportError: cannot import name 'Xlnk' from 'pynq' (/usr/local/lib/python3.8/dist-packages/pynq/\_\_init__.py)

```

Does anyone have any suggestions/tips on how to work around this?

I considered going back to SD image v2.6; however, I am having a difficult time finding the image file. I tried [this site](https://github.com/Xilinx/PYNQ/releases); however, when you click PYNQ-Z2 v2.6.0 SDCard image, nothing happens.

Thanks!

---

<div class="post-metadata">

**Author:** ![rwyoung](https://avatars.discourse-cdn.com/v4/letter/r/b5ac83/32.png) [@rwyoung](https://discuss.pynq.io/u/rwyoung)\
**Post date:** [March 9, 2022, 8:54pm UTC](https://discuss.pynq.io/t/how-to-work-around-xlnk-being-used-in-https-github-com-xilinx-lstm-pynq/3810/2 "2022-03-09T20:54:44Z")

</div>

Depending on what gets used from Xlnk, some of that has been deprecated and now appears in the pynq library.

[https://pynq.readthedocs.io/en/latest/changelog.html](https://pynq.readthedocs.io/en/latest/changelog.html)

- Removed Xlnk allocator and libraries for edge devices (replaced by XRT allocation)

---

<div class="post-metadata">

**Author:** ![savannah](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/savannah/32/3182_2.png) [@savannah](https://discuss.pynq.io/u/savannah)\
**Post date:** [March 9, 2022, 10:48pm UTC](https://discuss.pynq.io/t/how-to-work-around-xlnk-being-used-in-https-github-com-xilinx-lstm-pynq/3810/3 "2022-03-09T22:48:12Z")

</div>

It uses:

```auto
 def cleanup(self):
        xlnk = Xlnk()
        xlnk.xlnk_reset()

```

I am unsure how to work around this using allocate. I know that I should use `del buffer` but I do not know of all the specific buffers I would need to delete.

---

<div class="post-metadata">

**Author:** ![rwyoung](https://avatars.discourse-cdn.com/v4/letter/r/b5ac83/32.png) [@rwyoung](https://discuss.pynq.io/u/rwyoung)\
**Post date:** [March 9, 2022, 11:17pm UTC](https://discuss.pynq.io/t/how-to-work-around-xlnk-being-used-in-https-github-com-xilinx-lstm-pynq/3810/4 "2022-03-09T23:17:06Z")

</div>

right. xlnk\_reset() resets all the CMA buffers allocated across the system.

Now I think you use “del” but you probably have to call it per-buffer.

So maybe  
def cleanup(self):  
del buffer\_name1  
del buffer\_name2

as a brute force method

---

<div class="post-metadata">

**Author:** ![Smart\_Tech](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/smart_tech/32/7675_2.png) [@Smart\_Tech](https://discuss.pynq.io/u/Smart_Tech)\
**Post date:** [August 24, 2026, 2:22pm UTC](https://discuss.pynq.io/t/how-to-work-around-xlnk-being-used-in-https-github-com-xilinx-lstm-pynq/3810/5 "2026-08-24T14:22:10Z")

</div>

I came across this while looking into OCR implementations on PYNQ. It’s interesting to see how older projects can become difficult to run when libraries like Xlnk are deprecated. Updating the memory allocation and cleanup part seems like an important step when trying to keep an older [OCR](https://ocrnest.com/) project working on a newer PYNQ setup.
