Skip to content

Cannot run qrack on platform without OpenCL #1770

Open
@yorgossot

Description

@yorgossot

While trying to run qrack on a device without OpenCL (and without a GPU as it is on the cloud), this error shows up.

Note that the flag isOpenCL was set to False while initializing the qrack device.

Is this expected? Is it possible to use qrack with this setup?

IMPORTANT: Did you remember to install OpenCL, if your Qrack version was built with OpenCL?
---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
File ~/.local/lib/python3.10/site-packages/pyqrack/qrack_system/qrack_system.py:36, in QrackSystem.__init__(self)
     35 try:
---> 36     self.qrack_lib = CDLL(shared_lib_path)
     37 except Exception as e:

File ~/miniconda3/envs/qrack_env/lib/python3.10/ctypes/__init__.py:374, in CDLL.__init__(self, name, mode, handle, use_errno, use_last_error, winmode)
    373 if handle is None:
--> 374     self._handle = _dlopen(self._name, mode)
    375 else:

OSError: libOpenCL.so.1: cannot open shared object file: No such file or directory

During handling of the above exception, another exception occurred:

OSError                                   Traceback (most recent call last)
File ~/.local/lib/python3.10/site-packages/pyqrack/qrack_system/qrack_system.py:46, in QrackSystem.__init__(self)
     45 try:
---> 46     self.qrack_lib = CDLL(shared_lib_path)
     47 except Exception as e:

File ~/miniconda3/envs/qrack_env/lib/python3.10/ctypes/__init__.py:374, in CDLL.__init__(self, name, mode, handle, use_errno, use_last_error, winmode)
    373 if handle is None:
--> 374     self._handle = _dlopen(self._name, mode)
    375 else:

OSError: /usr/local/lib/qrack/libqrack_pinvoke.so: cannot open shared object file: No such file or directory

During handling of the above exception, another exception occurred:

OSError                                   Traceback (most recent call last)
Cell In[2], line 3
      1 import pennylane as qml
----> 3 dev = qml.device("qrack.simulator", wires=1, shots=1, noise=0.5, isTensorNetwork=False, isStabilizerHybrid=True, isOpenCL=False)

File ~/miniconda3/envs/qrack_env/lib/python3.10/site-packages/pennylane/devices/device_constructor.py:246, in device(name, *args, **kwargs)
    243 options.update(kwargs)
    245 # loads the device class
--> 246 plugin_device_class = plugin_devices[name].load()
    248 def _safe_specifier_set(version_str):
    249     """Safely create a SpecifierSet from a version string."""

File ~/miniconda3/envs/qrack_env/lib/python3.10/importlib/metadata/__init__.py:171, in EntryPoint.load(self)
    166 """Load the entry point from its definition. If only a module
    167 is indicated by the value, return that module. Otherwise,
    168 return the named object.
    169 """
    170 match = self.pattern.match(self.value)
--> 171 module = import_module(match.group('module'))
    172 attrs = filter(None, (match.group('attr') or '').split('.'))
    173 return functools.reduce(getattr, attrs, module)

File ~/miniconda3/envs/qrack_env/lib/python3.10/importlib/__init__.py:126, in import_module(name, package)
    124             break
    125         level += 1
--> 126 return _bootstrap._gcd_import(name[level:], package, level)

File <frozen importlib._bootstrap>:1050, in _gcd_import(name, package, level)

File <frozen importlib._bootstrap>:1027, in _find_and_load(name, import_)

File <frozen importlib._bootstrap>:1006, in _find_and_load_unlocked(name, import_)

File <frozen importlib._bootstrap>:688, in _load_unlocked(spec)

File <frozen importlib._bootstrap_external>:883, in exec_module(self, module)

File <frozen importlib._bootstrap>:241, in _call_with_frames_removed(f, *args, **kwds)

File ~/miniconda3/envs/qrack_env/lib/python3.10/site-packages/pennylane_qrack/qrack_device.py:36
     28 from pennylane.ops import (
     29     StatePrep,
     30     BasisState,
     31     QubitUnitary,
     32     Adjoint,
     33 )
     34 from pennylane.wires import Wires
---> 36 from pyqrack import QrackSimulator, Pauli
     38 from ._version import __version__
     39 from sys import platform as _platform

File ~/.local/lib/python3.10/site-packages/pyqrack/__init__.py:9
      7 from .neuron_activation_fn import NeuronActivationFn
      8 from .quimb_circuit_type import QuimbCircuitType
----> 9 from .qrack_circuit import QrackCircuit
     10 from .qrack_neuron import QrackNeuron
     11 from .qrack_neuron_torch_layer import QrackTorchNeuron, QrackNeuronFunction, QrackNeuronTorchLayer

File ~/.local/lib/python3.10/site-packages/pyqrack/qrack_circuit.py:8
      1 # (C) Daniel Strano and the Qrack contributors 2017-2025. All rights reserved.
      2 #
      3 # Use of this source code is governed by an MIT-style license that can be
      4 # found in the LICENSE file or at https://opensource.org/licenses/MIT.
      6 import ctypes
----> 8 from .qrack_system import Qrack
      9 from .quimb_circuit_type import QuimbCircuitType
     11 _IS_QISKIT_AVAILABLE = True

File ~/.local/lib/python3.10/site-packages/pyqrack/qrack_system/__init__.py:9
      6 from .qrack_system import QrackSystem
      8 # Global entry-point for Qrack shared library
----> 9 Qrack = QrackSystem()

File ~/.local/lib/python3.10/site-packages/pyqrack/qrack_system/qrack_system.py:59, in QrackSystem.__init__(self)
     57         except Exception as e:
     58             print("IMPORTANT: Did you remember to install OpenCL, if your Qrack version was built with OpenCL?")
---> 59             raise e
     61 self.fppow = 5
     62 if "QRACK_FPPOW" in os.environ:

File ~/.local/lib/python3.10/site-packages/pyqrack/qrack_system/qrack_system.py:56, in QrackSystem.__init__(self)
     53     shared_lib_path = "/usr/lib/qrack/libqrack_pinvoke.so"
     55 try:
---> 56     self.qrack_lib = CDLL(shared_lib_path)
     57 except Exception as e:
     58     print("IMPORTANT: Did you remember to install OpenCL, if your Qrack version was built with OpenCL?")

File ~/miniconda3/envs/qrack_env/lib/python3.10/ctypes/__init__.py:374, in CDLL.__init__(self, name, mode, handle, use_errno, use_last_error, winmode)
    371 self._FuncPtr = _FuncPtr
    373 if handle is None:
--> 374     self._handle = _dlopen(self._name, mode)
    375 else:
    376     self._handle = handle

OSError: /usr/lib/qrack/libqrack_pinvoke.so: cannot open shared object file: No such file or directory

@dime10
@WrathfulSpatula
@Swastikmajumdar10

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