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

Kernel crashing on Windows #30

Open
pmenczel opened this issue Dec 12, 2024 · 0 comments
Open

Kernel crashing on Windows #30

pmenczel opened this issue Dec 12, 2024 · 0 comments

Comments

@pmenczel
Copy link
Member

There is an issue where Python crashes when using QuTiP-QOC. We noticed the crash today on one Windows laptop and were able to reproduce on another Windows laptop. I set up a conda environment as follows (using Miniforge due to RIKEN licensing stuff, but I think that shouldn't matter)

conda create --name qutip-windows-test qutip jupyter
conda activate qutip-windows-test
pip install qutip-qoc

Then I run the following code (simplified from the tutorial notebook in qutip/qutip-tutorials#112)

import numpy as np
from qutip import gates, liouvillian, qeye, sigmam, sigmax, sigmay, sigmaz
from qutip_qoc import Objective, optimize_pulses


Hc = [sigmax(), sigmay(), sigmaz()]
Hc = [liouvillian(H) for H in Hc]

Hd = 1 / 2 * sigmaz()
Hd = liouvillian(H=Hd, c_ops=[sigmam()])

H = [Hd, Hc[0], Hc[1], Hc[2]]


# objective for optimization
initial = qeye(2)
target = gates.hadamard_transform()


# pulse time interval
times = np.linspace(0, np.pi / 2, 100)


optimize_pulses(
    objectives=Objective(initial, H, target),
    control_parameters={
        "ctrl_x": {"guess": np.sin(times), "bounds": [-1, 1]},
        "ctrl_y": {"guess": np.cos(times), "bounds": [-1, 1]},
        "ctrl_z": {"guess": np.tanh(times), "bounds": [-1, 1]},
    },
    tlist=times,
    algorithm_kwargs={"alg": "GRAPE", "fid_err_targ": 0.01},
)

The notebook kernel crashes with the error message

OMP: Error #15: Initializing libiomp5md.dll, but found libiomp5md.dll already initialized.
OMP: Hint This means that multiple copies of the OpenMP runtime have been linked into the program. That is dangerous, since it can degrade performance or cause incorrect results. The best thing to do is to ensure that only a single OpenMP runtime is linked into the process, e.g. by avoiding static linking of the OpenMP runtime in any library. As an unsafe, unsupported, undocumented workaround you can set the environment variable KMP_DUPLICATE_LIB_OK=TRUE to allow the program to continue to execute, but that may cause crashes or silently produce incorrect results. For more information, please see http://www.intel.com/software/products/support/.

The fix in the top answer of this stackexchange post solves the problem, but there should not be a crash in the first place...

Note: everything seems to work if I try the same on Linux (WSL). I'll try to debug if I can find time, but perhaps this error is familiar to someone?

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

1 participant