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

Kaleido crashes when rendering a plot to an image using Plotly's to_image() method using Alpine Linux #239

Open
chkp-noampo opened this issue Dec 29, 2024 · 1 comment
Assignees
Labels

Comments

@chkp-noampo
Copy link

Description:
I am using Kaleido to render Plotly plots as images via the to_image() method in an Alpine-based Docker environment. The process fails when Kaleido attempts to open Chromium, resulting in a GPU process crash. The error details and debug logs are provided below.

I’ve been trying to find a solution for this issue for a very long time now, and I’ve explored almost every possible approach, but Alpine Linux seems to be incompatible with Kaleido.

This issue has a substantial impact on our product and, I assume, on many other Plotly and Kaleido users facing similar constraints.

We would deeply appreciate it if you could prioritize this issue and allocate resources to apply a fix as soon as possible. The resolution of this problem is critical for our company, and we are willing to support the effort.

Steps to Reproduce:

  1. Build a Docker image using Alpine Linux.
  2. Install Kaleido and Plotly.
  3. Run plotly.graph_objects with to_image() to generate an image.
  4. Observe the error related to GPU process failure.

Expected Behavior:
Kaleido should render the Plotly plot to an image without crashing.

Actual Behavior:
Kaleido fails to launch the GPU process and crashes, as shown in the error traceback.

Error Traceback:

Full traceback (with KALEIDO_DEBUG enabled) is attached at the end of the issue

[1229/134817.090956:ERROR:gpu_process_host.cc(976)] GPU process launch failed: error_code=1002
[1229/134817.090956:WARNING:gpu_process_host.cc(1416)] The GPU process has crashed 1 time(s)
qemu: uncaught target signal 5 (Trace/breakpoint trap) - core dumped
[1229/134817.705795:FATAL:gpu_data_manager_impl_private.cc(423)] GPU process isn't usable. Goodbye.

Additional Information:

  • Chromium Path: /usr/bin/chromium
  • Python Version: 3.11
  • Plotly Version: 5.24.1
  • Kaleido Version: 1.0.0rc0 (0.2.1 version does not works for Alpine Linux)
  • Kaleido Debug Logs: The debug logs indicate that Kaleido is trying to launch the Chromium browser but fails due to GPU process issues:
**Displaying generated HTML***
<!DOCTYPE html>
<html>
<head>
<style id="head-style"></style>
<title>Kaleido-fier</title>
<script>
window.KaleidoReport = ["start"];
function logError(e) {
window.KaleidoReport.push("error");
window.KaleidoReport.push(e);
if (!navigator.onLine) {
window.KaleidoReport.push("offline");
}
}
</script>
<script>
window.PlotlyConfig = {MathJaxConfig: 'local'}
</script>
<script src="https://cdn.plot.ly/plotly-2.35.2.min.js" charset="utf-8" onerror="logError('plotly')"></script>
<script type="text/javascript" id="MathJax-script" src="file:///usr/local/lib/python3.11/site-packages/kaleido/vendor/mathjax/MathJax.js?config=TeX-AMS-MML_SVG" onerror="logError('mathjax')"></script>
<script src="file:///usr/local/lib/python3.11/site-packages/kaleido/vendor/kaleido_scopes.js" onerror="logError('scoper')"></script>  </head>
<body style="{margin: 0; padding: 0;}"><img id="kaleido-image"><img></body>
</html>
***end****
**Displaying generated HTML***
<!DOCTYPE html>
<html>
<head>
<style id="head-style"></style>
<title>Kaleido-fier</title>
<script>
window.KaleidoReport = ["start"];
function logError(e) {
window.KaleidoReport.push("error");
window.KaleidoReport.push(e);
if (!navigator.onLine) {
window.KaleidoReport.push("offline");
}
}
</script>
<script>
window.PlotlyConfig = {MathJaxConfig: 'local'}
</script>
<script src="file:///usr/local/lib/python3.11/site-packages/plotly/package_data/plotly.min.js" charset="utf-8" onerror="logError('plotly')"></script>
<script type="text/javascript" id="MathJax-script" src="file:///usr/local/lib/python3.11/site-packages/kaleido/vendor/mathjax/MathJax.js?config=TeX-AMS-MML_SVG" onerror="logError('mathjax')"></script>
<script src="file:///usr/local/lib/python3.11/site-packages/kaleido/vendor/kaleido_scopes.js" onerror="logError('scoper')"></script>  </head>
<body style="{margin: 0; padding: 0;}"><img id="kaleido-image"><img></body>
</html>
***end****
No loop, no thread
STDERR: <_io.TextIOWrapper name='<stderr>' mode='w' encoding='utf-8'>
TEMP DIR NAME: /tmp/tmpm8s2vf_a
DEBUG REPORT:
BROWSER_PATH: /usr/bin/chromium
USER_DATA_DIR: /tmp/tmpm8s2vf_a
read_jsons (blocking):
write_json:Starting watchdog

write_json: {"id": 0, "method": "Target.getTargets"}
wrote_json.
Old Headless mode will be removed from the Chrome binary soon. Please use the new Headless mode (https://developer.chrome.com/docs/chromium/new-headless) or the chrome-headless-shell which is a standalone implementation of the old Headless mode (https://developer.chrome.com/blog/chrome-headless-shell).

qemu: uncaught target signal 5 (Trace/breakpoint trap) - core dumped
qemu: uncaught target signal 5 (Trace/breakpoint trap) - core dumped
[1229/134816.424079:ERROR:bus.cc(407)] Failed to connect to the bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory
[1229/134816.472629:ERROR:bus.cc(407)] Failed to connect to the bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory
[1229/134816.475996:ERROR:bus.cc(407)] Failed to connect to the bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory
[1229/134817.080670:WARNING:bluez_dbus_manager.cc(234)] Floss manager service not available, cannot set Floss enable/disable.
[1229/134817.090198:ERROR:gpu_process_host.cc(976)] GPU process launch failed: error_code=1002
[1229/134817.090956:WARNING:gpu_process_host.cc(1416)] The GPU process has crashed 1 time(s)
{"id":0,"result":{"targetInfos":[]}}
[1229/134817.200035:ERROR:gpu_process_host.cc(976)] GPU process launch failed: error_code=1002
[1229/134817.200133:WARNING:gpu_process_host.cc(1416)] The GPU process has crashed 2 time(s)
read_jsons: {'id': 0, 'result': {'targetInfos': []}}
run_read_loop() found future for key ('', 0)
read_jsons (blocking):
Creating tab w/ file: file:///root/.kaleido-s36n1r02/index.html
write_json:
[1229/134817.228431:ERROR:gpu_process_host.cc(976)] GPU process launch failed: error_code=1002
[1229/134817.228537:WARNING:gpu_process_host.cc(1416)] The GPU process has crashed 3 time(s)
write_json: {"id": 1, "method": "Target.createTarget", "params": {"url": "file:///root/.kaleido-s36n1r02/index.html"}}
wrote_json.
{"id":1,"result":{"targetId":"8A944A2E7E2C38FFA32651B3B76FC251"}}
[1229/134817.572600:ERROR:gpu_process_host.cc(976)] GPU process launch failed: error_code=1002
[1229/134817.574345:WARNING:gpu_process_host.cc(1416)] The GPU process has crashed 4 time(s)
read_jsons: {'id': 1, 'result': {'targetId': '8A944A2E7E2C38FFA32651B3B76FC251'}}
run_read_loop() found future for key ('', 1)
write_json:
write_json: {"id": 2, "method": "Target.attachToTarget", "params": {"targetId": "8A944A2E7E2C38FFA32651B3B76FC251", "flatten": true}}
wrote_json.
read_jsons (blocking):
[1229/134817.649732:ERROR:gpu_process_host.cc(976)] GPU process launch failed: error_code=1002
[1229/134817.649846:WARNING:gpu_process_host.cc(1416)] The GPU process has crashed 5 time(s)
{"method":"Target.attachedToTarget","params":{"sessionId":"82ABBD20EBBEDF8A0A4CF0BF552E0648","targetInfo":{"targetId":"8A944A2E7E2C38FFA32651B3B76FC251","type":"page","title":"","url":"file:///root/.kaleido-s36n1r02/index.html","attached":true,"canAccessOpener":false,"browserContextId":"DA133DEF98442C73694452C71FBB83AB"},"waitingForDebugger":false}}
read_jsons: {'method': 'Target.attachedToTarget', 'params': {'sessionId': '82ABBD20EBBEDF8A0A4CF0BF552E0648', 'targetInfo': {'targetId': '8A944A2E7E2C38FFA32651B3B76FC251', 'type': 'page', 'title': '', 'url': 'file:///root/.kaleido-s36n1r02/index.html', 'attached': True, 'canAccessOpener': False, 'browserContextId': 'DA133DEF98442C73694452C71FBB83AB'}, 'waitingForDebugger': False}}
Checking subscription key: * against event method Target.attachedToTarget
All subscription: {'method': 'Target.attachedToTarget', 'params': {'sessionId': '82ABBD20EBBEDF8A0A4CF0BF552E0648', 'targetInfo': {'targetId': '8A944A2E7E2C38FFA32651B3B76FC251', 'type': 'page', 'title': '', 'url': 'file:///root/.kaleido-s36n1r02/index.html', 'attached': True, 'canAccessOpener': False, 'browserContextId': 'DA133DEF98442C73694452C71FBB83AB'}, 'waitingForDebugger': False}}
read_jsons (blocking):
{"id":2,"result":{"sessionId":"82ABBD20EBBEDF8A0A4CF0BF552E0648"}}
read_jsons: {'id': 2, 'result': {'sessionId': '82ABBD20EBBEDF8A0A4CF0BF552E0648'}}
run_read_loop() found future for key ('', 2)
Activating page
write_json:
write_json: {"id": 0, "method": "Page.bringToFront", "sessionId": "82ABBD20EBBEDF8A0A4CF0BF552E0648"}
wrote_json.
read_jsons (blocking):
[1229/134817.705593:ERROR:gpu_process_host.cc(976)] GPU process launch failed: error_code=1002
[1229/134817.705708:WARNING:gpu_process_host.cc(1416)] The GPU process has crashed 6 time(s)
[1229/134817.705795:FATAL:gpu_data_manager_impl_private.cc(423)] GPU process isn't usable. Goodbye.
qemu: uncaught target signal 5 (Trace/breakpoint trap) - core dumped
Browser is being closed because chrom* closed
is_closed called with wait: 0
Browser was already closed.
caught OSError in read() [Errno 9] Bad file descriptor
Tempfile still exists?: False
Exception in callback Browser.run_read_loop.<locals>.check_error(<Task cancell...owser.py:671>>) at /usr/local/lib/python3.11/site-packages/choreographer/browser.py:663
handle: <Handle Browser.run_read_loop.<locals>.check_error(<Task cancell...owser.py:671>>) at /usr/local/lib/python3.11/site-packages/choreographer/browser.py:663>
Traceback (most recent call last):
File "/usr/local/lib/python3.11/asyncio/runners.py", line 190, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/asyncio/runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/asyncio/base_events.py", line 654, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/kaleido/**init**.py", line 65, in to_image
res = await tab.send_command("Page.bringToFront")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
choreographer.browser.BrowserClosedError: Command not completed because browser closed.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.11/asyncio/events.py", line 84, in _run
self._context.run(self._callback, *self._args)
File "/usr/local/lib/python3.11/site-packages/choreographer/browser.py", line 664, in check_error
e = result.exception()
^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/choreographer/browser.py", line 673, in read_loop
responses = await self.loop.run_in_executor(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
asyncio.exceptions.CancelledError
Error while generating bar chart. Command not completed because browser closed.
@ayjayt
Copy link
Collaborator

ayjayt commented Jan 29, 2025

So this should be fixed, I believe, in newer versions, since by default we DONT enable to the GPU.

This improves our first-run success rates.

We have a new kaleido push coming out very soon chkp-noampo, but fair warning, its a major version bump, and it changes the API. Its also significantly faster.

@ayjayt ayjayt self-assigned this Jan 29, 2025
@ayjayt ayjayt added the active label Jan 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants