Skip to content

Kernel crashing on Windows #30

@pmenczel

Description

@pmenczel

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions