tensorflow_serving/model_servers/test_util/tensorflow_model_server_test_base.py
def SetVirtualCpus(num_virtual_cpus):
  """Create virtual CPU devices if they haven't yet been created."""
  if num_virtual_cpus < 1:
    raise ValueError('`num_virtual_cpus` must be at least 1 not %r' %
                     (num_virtual_cpus,))
  physical_devices = tf.config.experimental.list_physical_devices('CPU')
  if not physical_devices:
    raise RuntimeError('No CPUs found')
  configs = tf.config.experimental.get_virtual_device_configuration(
      physical_devices[0])
  if configs is None:
    virtual_devices = [tf.config.experimental.VirtualDeviceConfiguration()
                       for _ in range(num_virtual_cpus)]
    tf.config.experimental.set_virtual_device_configuration(
        physical_devices[0], virtual_devices)
  else:
    if len(configs) < num_virtual_cpus:
      raise RuntimeError('Already configured with %d < %d virtual CPUs' %
                         (len(configs), num_virtual_cpus))
Create virtual CPU devices if they haven't yet been created.
Create virtual CPU devices if they haven't yet been created.
Create virtual CPU devices if they haven ' t yet been created .
def SetVirtualCpus(num_virtual_cpus):
  if num_virtual_cpus < 1:
    raise ValueError('`num_virtual_cpus` must be at least 1 not %r' %
                     (num_virtual_cpus,))
  physical_devices = tf.config.experimental.list_physical_devices('CPU')
  if not physical_devices:
    raise RuntimeError('No CPUs found')
  configs = tf.config.experimental.get_virtual_device_configuration(
      physical_devices[0])
  if configs is None:
    virtual_devices = [tf.config.experimental.VirtualDeviceConfiguration()
                       for _ in range(num_virtual_cpus)]
    tf.config.experimental.set_virtual_device_configuration(
        physical_devices[0], virtual_devices)
  else:
    if len(configs) < num_virtual_cpus:
      raise RuntimeError('Already configured with %d < %d virtual CPUs' %
                         (len(configs), num_virtual_cpus))
def SetVirtualCpus ( num_virtual_cpus ) : if num_virtual_cpus < 1 : raise ValueError ( '`num_virtual_cpus` must be at least 1 not %r' % ( num_virtual_cpus , ) ) physical_devices = tf . config . experimental . list_physical_devices ( 'CPU' ) if not physical_devices : raise RuntimeError ( 'No CPUs found' ) configs = tf . config . experimental . get_virtual_device_configuration ( physical_devices [ 0 ] ) if configs is None : virtual_devices = [ tf . config . experimental . VirtualDeviceConfiguration ( ) for _ in range ( num_virtual_cpus ) ] tf . config . experimental . set_virtual_device_configuration ( physical_devices [ 0 ] , virtual_devices ) else : if len ( configs ) < num_virtual_cpus : raise RuntimeError ( 'Already configured with %d < %d virtual CPUs' % ( len ( configs ) , num_virtual_cpus ) )
Create virtual CPU devices if they haven't yet been created.
Create virtual CPU devices if they haven ' t yet been created .
"""Create virtual CPU devices if they haven't yet been created."""
num_virtual_cpus