Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RuntimeError: There is no current event loop in thread 'ScriptRunner.scriptThread'. #108

Open
manudwd opened this issue Oct 23, 2023 · 1 comment

Comments

@manudwd
Copy link

manudwd commented Oct 23, 2023

Hello!
DPU Target: DPUCZDX8G_ISA1_B4096

Vitis Verison: 2.5.0 (CPU)

I am using the Xilinx-RFSoC ZCU 111 for a custom neural net, I am using that with combinations to some other tools to create something along the lines of a dash board for my results, all of which is intended to happen on the board using board Jupyter terminal.

I am able to load the bitstream as usual using dpu = DpuOverlay("dpu.bit") when I run it on the jupyter notebook. The problem occurs when I use it in combination with this web app creating tool called streamlit. streamlit hosts on the local system as well typically on localhost:8501 port, while PYNQ hosts on port:8080.

Expected Behaviour: when I run streamlit run myDPU_file.py, the app should be hosted on local computer's browser since the Board is connected to my local computer via UART.

Actual Behaviour: The error message:

RuntimeError: There is no current event loop in thread 'ScriptRunner.scriptThread'.
Traceback:

File "/usr/local/share/pynq-venv/lib/python3.10/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 541, in _run_script
    exec(code, module.__dict__)
File "/home/xilinx/jupyter_notebooks/pynq-dpu/present_Complete_DPU.py", line 394, in <module>
    overlay = DpuOverlay("dpu.bit")
File "/usr/local/share/pynq-venv/lib/python3.10/site-packages/pynq_dpu/dpu.py", line 98, in __init__
    super().__init__(abs_bitfile_name,
File "/usr/local/share/pynq-venv/lib/python3.10/site-packages/pynq/overlay.py", line 315, in __init__
    super().__init__(bitfile_name, dtbo, partial=False, device=device)
File "/usr/local/share/pynq-venv/lib/python3.10/site-packages/pynq/bitstream.py", line 88, in __init__
    device = Device.active_device
File "/usr/local/share/pynq-venv/lib/python3.10/site-packages/pynq/pl_server/device.py", line 70, in active_device
    if len(cls.devices) == 0:
File "/usr/local/share/pynq-venv/lib/python3.10/site-packages/pynq/pl_server/device.py", line 54, in devices
    cls._devices.extend(DeviceMeta._subclasses[key]._probe_())
File "/usr/local/share/pynq-venv/lib/python3.10/site-packages/pynq/pl_server/embedded_device.py", line 545, in _probe_
    return [EmbeddedDevice()]
File "/usr/local/share/pynq-venv/lib/python3.10/site-packages/pynq/pl_server/embedded_device.py", line 568, in __init__
    super().__init__(0, "embedded_xrt{}")
File "/usr/local/share/pynq-venv/lib/python3.10/site-packages/pynq/pl_server/xrt_device.py", line 325, in __init__
    self._loop = asyncio.get_event_loop()
File "/usr/lib/python3.10/asyncio/events.py", line 656, in get_event_loop
    raise RuntimeError('There is no current event loop in thread %r.'

I understand this problem may not be answered since it is raised in combination with other tools, but the error message seems to suggest that no device is found, which shouldn't be the case. It seems like a fundamental problem of threading, any help in diagnosing would be really appreciated.

@skalade
Copy link
Collaborator

skalade commented Dec 4, 2023

Hi @manudwd,

Looking at #106 I ran into the exact same error message as you have reported here. In that case vaitrace was destroying the event loop that xrt_device was grabbing. The solution that worked for me was starting a new event loop inside the vaitrace application like so:

import asyncio
asyncio.set_event_loop(asyncio.new_event_loop())

Not very familiar with your application, but maybe it helps. If you resolved your issue another way please share a solution and/or close the issue. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants