Change Terra CPU_COUNT when global num_processes is set
import numpy as np
from .aqua_error import AquaError
from qiskit._util import local_hardware_info
+import qiskit
+import logging
+
+logger = logging.getLogger(__name__)
class QiskitAquaGlobals(object):
@@ -54,6 +58,11 @@ class QiskitAquaGlobals(object):
if num_processes > QiskitAquaGlobals.CPU_COUNT:
raise AquaError('Number of Processes {} cannot be greater than cpu count {}.'.format(num_processes, QiskitAquaGlobals._CPU_COUNT))
self._num_processes = num_processes
+ # TODO: change Terra CPU_COUNT until issue gets resolved: https://github.com/Qiskit/qiskit-terra/issues/1963
+ try:
+ qiskit.tools.parallel.CPU_COUNT = self.num_processes
+ except Exception as e:
+ logger.warning("Failed to set qiskit.tools.parallel.CPU_COUNT to value: '{}': Error: '{}'".format(self.num_processes, str(e)))
@property
def random(self):
