diff --git a/qiskit_aer/backends/backend_utils.py b/qiskit_aer/backends/backend_utils.py index d472b924f4..eb99050486 100644 --- a/qiskit_aer/backends/backend_utils.py +++ b/qiskit_aer/backends/backend_utils.py @@ -16,16 +16,18 @@ """ import os from math import log2 -from qiskit.utils import local_hardware_info + +import psutil from qiskit.circuit import QuantumCircuit from qiskit.compiler import assemble from qiskit.qobj import QasmQobjInstruction from qiskit.result import ProbDistribution from qiskit.quantum_info import Clifford + from .compatibility import Statevector, DensityMatrix, StabilizerState, Operator, SuperOp # Available system memory -SYSTEM_MEMORY_GB = local_hardware_info()["memory"] +SYSTEM_MEMORY_GB = psutil.virtual_memory().total / (1024**3) # Max number of qubits for complex double statevector # given available system memory diff --git a/qiskit_aer/backends/statevector_simulator.py b/qiskit_aer/backends/statevector_simulator.py index 342997c49f..da653bac6c 100644 --- a/qiskit_aer/backends/statevector_simulator.py +++ b/qiskit_aer/backends/statevector_simulator.py @@ -16,7 +16,8 @@ import copy import logging from warnings import warn -from qiskit.utils import local_hardware_info + +import psutil from qiskit.providers.options import Options from qiskit.providers.models import QasmBackendConfiguration @@ -364,7 +365,7 @@ def _validate(self, qobj): if n_qubits > max_qubits: raise AerError( f"Number of qubits ({n_qubits}) is greater than max ({max_qubits}) " - f'for "{name}" with {int(local_hardware_info()["memory"])} GB system memory.' + f'for "{name}" with {int(psutil.virtual_memory().total / (1024**3))} GB system memory.' ) if qobj.config.shots != 1: diff --git a/qiskit_aer/backends/unitary_simulator.py b/qiskit_aer/backends/unitary_simulator.py index ca28204a9a..1cb477e67b 100644 --- a/qiskit_aer/backends/unitary_simulator.py +++ b/qiskit_aer/backends/unitary_simulator.py @@ -17,7 +17,8 @@ import copy import logging from warnings import warn -from qiskit.utils import local_hardware_info + +import psutil from qiskit.providers.options import Options from qiskit.providers.models import QasmBackendConfiguration @@ -351,7 +352,7 @@ def _validate(self, qobj): raise AerError( f"Number of qubits ({n_qubits}) is greater than " f'max ({max_qubits}) for "{name}" with ' - f"{int(local_hardware_info()['memory'])} GB system memory." + f"{int(psutil.virtual_memory().total / (1024**3))} GB system memory." ) if qobj.config.shots != 1: logger.info('"%s" only supports 1 shot. Setting shots=1.', name) diff --git a/releasenotes/notes/psutil-added-ffb2a4b5956fa03d.yaml b/releasenotes/notes/psutil-added-ffb2a4b5956fa03d.yaml new file mode 100644 index 0000000000..34939eafd2 --- /dev/null +++ b/releasenotes/notes/psutil-added-ffb2a4b5956fa03d.yaml @@ -0,0 +1,9 @@ +--- +upgrade: + - | + Added `psutil `__ as a dependency for + Qiskit Aer. This is used to determine the amount of physical resources + available. ``psutil`` is currently a dependency of Qiskit, which is a + requirement for Qiskit Aer, so ``psutil`` was effectively already required + for any ``qiskit-aer`` installation. But, as qiskit-aer is now using it + directly is now a direct dependency for ``qiskit-aer``. diff --git a/setup.py b/setup.py index d2a67e87f3..fc35929a17 100644 --- a/setup.py +++ b/setup.py @@ -25,6 +25,7 @@ "qiskit>=0.44.0", "numpy>=1.16.3", "scipy>=1.0", + "psutil>=5", ] classifiers = [