Accessing an overlay from multiple python interpreters

I’m trying to access the loaded overlay from multiple python interpreters while writing a package and can’t get a proof of concept to work in a root ipython interpreter. I know this is possible as running to notebooks and downloading an overlay in one will clearly affect what is available in the other.

I’ve tried pynq.Device.active_device.ip_dict thinking that would pull from the default global pl_server but it did not.

In essence what I’d like is a way to do the following:
Program 1 (possibly a jupyter notebook):

import pynq
pynq.Overlay('my bitstream.bit')

Program 2

import pynq

ol = pynq.<get_active_overlay>

This post seems related but the suggestions there didn’t seem to work here.

1 Like


What pynq version are you using?

In 2.7 I was able to do this using this piece of code

import pynq
ol = pynq.Overlay(<your_overlay>.bit, download=False)
pynq.Device.active_device.reset(ol.parser, ol.timestamp, ol.bitfile_name)


We were on 2.6 on this board (ZCU111). On a possibly related note we were finding a difference in the list of devices available. In the script this code:

def configure(bitstream, mig='mig_modified_ip_layout_mem_topology.xclbin', ignore_version=False, clocks=False, download=True):
    import pynq, xrfclk
    from pynq import PL

    global _gen3_overlay, _mig_overlay
    _gen3_overlay = pynq.Overlay(bitstream, ignore_version=ignore_version, download=download)

    if mig:
        _mig_overlay = pynq.Overlay(mig, device=pynq.Device.devices[1], download=download)

    if clocks:
            getLogger(__name__).info('Failed to set clocks with set_all_ref_clks, trying new driver call')

would also choke with an index error on devices[1] (there is only one present) whereas in a jupyter notebook there are two. So my takeaway is there is something different about the way the notebook server is starting the interpreter (either working directories, paths, or environment variables) that I’m not reproducing.

The idea would be in one process I’d make the call with download=True and in others with download=False. I don’t think we are going to need multiprocessing within an instance so I’m not too worried about the proper picklability of the the overlay objects (plus I can simple set them to none and reconnect with some getstate setstate hooks if needed.

I did try the active_device call but it didn’t seem to work.

1 Like

@marioruiz any chance you know of a workaround for 2.6 or have any other thoughts?


Mario gave you the solution. Have only one python process, the first one to start, when you invoke Overlay(…) set download=True. Have all the others set it to download=False. Then of course don’t access the same PL entities/registers at once for hardware that can’t tolerate it.

This works in v2.6 also.

Kind regards

1 Like