plotly / Kaleido

Fast static image export for web-based visualization libraries with zero dependencies
Other
349 stars 33 forks source link

ValueError: Failed to start Kaleido subprocess. #130

Open Yovoss opened 2 years ago

Yovoss commented 2 years ago

I use conda-pack command to remove my gru conda environment from server A to server B, and there is an error about kaleido while i use the fig.write_image(). The error message is as follows:

**

Traceback (most recent call last): File "5_hyperparameter_tuner_HMMEF_optuna.py", line 419, in fig.write_image(os.path.join(output_path, "optimization_history({}).png".format(LABEL_DICT[str(ARGS.label)]))) File "/home/zju/anaconda3/envs/gru/lib/python3.6/site-packages/plotly/basedatatypes.py", line 3806, in write_image return pio.write_image(self, *args, **kwargs) File "/home/zju/anaconda3/envs/gru/lib/python3.6/site-packages/plotly/io/_kaleido.py", line 252, in write_image engine=engine, File "/home/zju/anaconda3/envs/gru/lib/python3.6/site-packages/plotly/io/_kaleido.py", line 132, in to_image fig_dict, format=format, width=width, height=height, scale=scale File "/home/zju/anaconda3/envs/gru/lib/python3.6/site-packages/kaleido/scopes/plotly.py", line 154, in transform figure, format=format, width=width, height=height, scale=scale File "/home/zju/anaconda3/envs/gru/lib/python3.6/site-packages/kaleido/scopes/base.py", line 293, in _perform_transform self._ensure_kaleido() File "/home/zju/anaconda3/envs/gru/lib/python3.6/site-packages/kaleido/scopes/base.py", line 198, in _ensure_kaleido raise ValueError(message) ValueError: Failed to start Kaleido subprocess. Error stream:

/home/zju/anaconda3/envs/gru/bin/kaleido: line 3: /home/conda/feedstock_root/build_artifacts/kaleido-core_1615199303525/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehol/bin/KaleidoApp/kaleido: No such file or directory

**

So i want to know how to fix it? and the import is normal. image

mikeylinton commented 2 years ago

Hi, wanted to add that I also am having the same issue

ValueError: Failed to start Kaleido subprocess. Error stream:

[0406/024334.965007:WARNING:resource_bundle.cc(431)] locale_file_path.empty() for locale 
prctl(PR_SET_NO_NEW_PRIVS) failed
[0406/024335.025482:FATAL:zygote_communication_linux.cc(255)] Cannot communicate with zygote
#0 0x55f266e5bd79 base::debug::CollectStackTrace()
#1 0x55f266dd9633 base::debug::StackTrace::StackTrace()
#2 0x55f266de915f logging::LogMessage::~LogMessage()
#3 0x55f265585d85 content::ZygoteCommunication::Init()
#4 0x55f2655863c7 content::CreateUnsandboxedZygote()
#5 0x55f266b4280b content::ContentMainRunnerImpl::Initialize()
#6 0x55f266b40bbc content::RunContentProcess()
#7 0x55f266b40cfc content::ContentMain()
#8 0x55f266b92182 headless::(anonymous namespace)::RunContentMain()
#9 0x55f266b92025 headless::HeadlessBrowserMain()
#10 0x55f264bb0fa8 main
#11 0x7f82aaf6e0ba __libc_start_main
#12 0x55f264baa3ea _start

Received signal 6
#0 0x55f266e5bd79 base::debug::CollectStackTrace()
#1 0x55f266dd9633 base::debug::StackTrace::StackTrace()
#2 0x55f266e5b95b base::debug::(anonymous namespace)::StackDumpSignalHandler()
#3 0x7f82ac4437e0 (/usr/lib64/libpthread-2.26.so+0x117df)
#4 0x7f82aaf80c20 __GI_raise
#5 0x7f82aaf820c8 __GI_abort
#6 0x55f266e5a8f5 base::debug::BreakDebugger()
#7 0x55f266de95b2 logging::LogMessage::~LogMessage()
#8 0x55f265585d85 content::ZygoteCommunication::Init()
#9 0x55f2655863c7 content::CreateUnsandboxedZygote()
#10 0x55f266b4280b content::ContentMainRunnerImpl::Initialize()
#11 0x55f266b40bbc content::RunContentProcess()
#12 0x55f266b40cfc content::ContentMain()
#13 0x55f266b92182 headless::(anonymous namespace)::RunContentMain()
#14 0x55f266b92025 headless::HeadlessBrowserMain()
#15 0x55f264bb0fa8 main
#16 0x7f82aaf6e0ba __libc_start_main
#17 0x55f264baa3ea _start
  r8: 0000000000000000  r9: 00007ffec14e5460 r10: 0000000000000008 r11: 0000000000000246
 r12: 00007ffec14e5f00 r13: 00007ffec14e67f0 r14: 00007ffec14e6800 r15: 00007ffec14e6808
  di: 0000000000000002  si: 00007ffec14e5460  bp: 00007ffec14e56b0  bx: 0000000000000006
  dx: 0000000000000000  ax: 0000000000000000  cx: 00007f82aaf80c20  sp: 00007ffec14e5460
  ip: 00007f82aaf80c20 efl: 0000000000000246 cgf: 002b000000000033 erf: 0000000000000000
 trp: 0000000000000000 msk: 0000000000000000 cr2: 0000000000000000
[end of stack trace]
Calling _exit(1). Core file will not be generated.

The version of kaleido is also 0.2.1

mikeylinton commented 2 years ago

@Yovoss please put the bug label on this issue.

rshkv commented 2 years ago

@Yovoss, I think you need to run ./gru/bin/conda-unpack on server B.

allanelder commented 1 year ago

Hi, wanted to add that I also am having the same issue

ValueError: Failed to start Kaleido subprocess. Error stream:

[0406/024334.965007:WARNING:resource_bundle.cc(431)] locale_file_path.empty() for locale 
prctl(PR_SET_NO_NEW_PRIVS) failed
[0406/024335.025482:FATAL:zygote_communication_linux.cc(255)] Cannot communicate with zygote
#0 0x55f266e5bd79 base::debug::CollectStackTrace()
#1 0x55f266dd9633 base::debug::StackTrace::StackTrace()
#2 0x55f266de915f logging::LogMessage::~LogMessage()
#3 0x55f265585d85 content::ZygoteCommunication::Init()
#4 0x55f2655863c7 content::CreateUnsandboxedZygote()
#5 0x55f266b4280b content::ContentMainRunnerImpl::Initialize()
#6 0x55f266b40bbc content::RunContentProcess()
#7 0x55f266b40cfc content::ContentMain()
#8 0x55f266b92182 headless::(anonymous namespace)::RunContentMain()
#9 0x55f266b92025 headless::HeadlessBrowserMain()
#10 0x55f264bb0fa8 main
#11 0x7f82aaf6e0ba __libc_start_main
#12 0x55f264baa3ea _start

Received signal 6
#0 0x55f266e5bd79 base::debug::CollectStackTrace()
#1 0x55f266dd9633 base::debug::StackTrace::StackTrace()
#2 0x55f266e5b95b base::debug::(anonymous namespace)::StackDumpSignalHandler()
#3 0x7f82ac4437e0 (/usr/lib64/libpthread-2.26.so+0x117df)
#4 0x7f82aaf80c20 __GI_raise
#5 0x7f82aaf820c8 __GI_abort
#6 0x55f266e5a8f5 base::debug::BreakDebugger()
#7 0x55f266de95b2 logging::LogMessage::~LogMessage()
#8 0x55f265585d85 content::ZygoteCommunication::Init()
#9 0x55f2655863c7 content::CreateUnsandboxedZygote()
#10 0x55f266b4280b content::ContentMainRunnerImpl::Initialize()
#11 0x55f266b40bbc content::RunContentProcess()
#12 0x55f266b40cfc content::ContentMain()
#13 0x55f266b92182 headless::(anonymous namespace)::RunContentMain()
#14 0x55f266b92025 headless::HeadlessBrowserMain()
#15 0x55f264bb0fa8 main
#16 0x7f82aaf6e0ba __libc_start_main
#17 0x55f264baa3ea _start
  r8: 0000000000000000  r9: 00007ffec14e5460 r10: 0000000000000008 r11: 0000000000000246
 r12: 00007ffec14e5f00 r13: 00007ffec14e67f0 r14: 00007ffec14e6800 r15: 00007ffec14e6808
  di: 0000000000000002  si: 00007ffec14e5460  bp: 00007ffec14e56b0  bx: 0000000000000006
  dx: 0000000000000000  ax: 0000000000000000  cx: 00007f82aaf80c20  sp: 00007ffec14e5460
  ip: 00007f82aaf80c20 efl: 0000000000000246 cgf: 002b000000000033 erf: 0000000000000000
 trp: 0000000000000000 msk: 0000000000000000 cr2: 0000000000000000
[end of stack trace]
Calling _exit(1). Core file will not be generated.

The version of kaleido is also 0.2.1

I'm having this same issue - running on a docker container on AWS Lambda. Just doing a write_image from a plotly figure, have tried setting --single-process that I saw suggested elsewhere as a potential fix on Lambda. stack_trace

I've been able to work around it by using code that warms up Kaleido, waits and then continues when a simple throwaway image is created. This leads me to believe its related to the time taken to startup the background processes. Lamdas, being limited in computational power, would be extremely susceptible to this. I've created a hack to wait for the warmup to complete, code is below.

` import plotly.graph_objects as go import numpy as np import plotly.io as pio

def plotly_kaleido_warmup():
    cold = True
    try:
        np.random.seed(1)
        N = 100
        x = np.random.rand(N)
        y = np.random.rand(N)
        colors = np.random.rand(N)
        sz = np.random.rand(N) * 30
        fig = go.Figure()
        fig.add_trace(go.Scatter(
            x=x,
            y=y,
            mode="markers",
            marker=go.scatter.Marker(
            size=sz,
            color=colors,
            opacity=0.6,
            colorscale="Viridis"
        )))
        fig.write_image(f"{tempfile.gettempdir()}/warmup.png")
        cold = False
    except Exception as ex:
        print(f"WARMUP EXCEPTION {ex}")
    finally:
        return cold

pio.kaleido.scope.chromium_args += ("--single-process",)
cold = True
while cold:
    cold = plotly_kaleido_warmup()
    if cold:
        log.info(f'cold; waiting 10 seconds.')
        time.sleep(10)
    else:
        log.info(f'warmup complete.')`