neulab/docprompting-conala huggingface dataset:
tf.config.experimental_connect_to_cluster     View source on GitHub    Connects to the given cluster.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.config.experimental_connect_to_cluster  
tf.config.experimental_connect_to_cluster(
    cluster_spec_or_resolver, job_name='localhost', task_index=0,
    protocol=None, make_master_device_default=True, cluster_device_filters=None
)
 Will make devices on the cluster available to use. Note that calling this more than once will work, but will invalidate any tensor handles on the old remote devices. If the given local job name is not present in the cluster specification, it will be automatically added, using an unused port on the localhost. Device filters can be specified to isolate groups of remote tasks to avoid undesired accesses between workers. Workers accessing resources or launching ops / functions on filtered remote devices will result in errors (unknown devices). For any remote task, if no device filter is present, all cluster devices will be visible; if any device filter is specified, it can only see devices matching at least one filter. Devices on the task itself are always visible. Device filters can be particially specified. For example, for a cluster set up for parameter server training, the following device filters might be specified: cdf = tf.config.experimental.ClusterDeviceFilters()
# For any worker, only the devices on PS nodes and itself are visible
for i in range(num_workers):
  cdf.set_device_filters('worker', i, ['/job:ps'])
# Similarly for any ps, only the devices on workers and itself are visible
for i in range(num_ps):
  cdf.set_device_filters('ps', i, ['/job:worker'])

tf.config.experimental_connect_to_cluster(cluster_def,
                                          cluster_device_filters=cdf)

 


 Args
  cluster_spec_or_resolver   A ClusterSpec or ClusterResolver describing the cluster.  
  job_name   The name of the local job.  
  task_index   The local task index.  
  protocol   The communication protocol, such as "grpc". If unspecified, will use the default from python/platform/remote_utils.py.  
  make_master_device_default   If True and a cluster resolver is passed, will automatically enter the master task device scope, which indicates the master becomes the default device to run ops. It won't do anything if a cluster spec is passed. Will throw an error if the caller is currently already in some device scope.  
  cluster_device_filters   an instance of tf.train.experimental/ClusterDeviceFilters that specify device filters to the remote tasks in cluster.
tf.config.experimental_connect_to_host     View source on GitHub    Connects to a single machine to enable remote execution on it.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.config.experimental_connect_to_host  
tf.config.experimental_connect_to_host(
    remote_host=None, job_name='worker'
)
 Will make devices on the remote host available to use. Note that calling this more than once will work, but will invalidate any tensor handles on the old remote devices. Using the default job_name of worker, you can schedule ops to run remotely as follows: # When eager execution is enabled, connect to the remote host.
tf.config.experimental_connect_to_host("exampleaddr.com:9876")

with ops.device("job:worker/replica:0/task:1/device:CPU:0"):
  # The following tensors should be resident on the remote device, and the op
  # will also execute remotely.
  x1 = array_ops.ones([2, 2])
  x2 = array_ops.ones([2, 2])
  y = math_ops.matmul(x1, x2)

 


 Args
  remote_host   a single or a list the remote server addr in host-port format.  
  job_name   The job name under which the new server will be accessible.   
 


 Raises
  ValueError   if remote_host is None.
tf.config.experimental_functions_run_eagerly Returns the value of the experimental_run_functions_eagerly setting. (deprecated)  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.config.experimental_functions_run_eagerly  
tf.config.experimental_functions_run_eagerly()
 Warning: THIS FUNCTION IS DEPRECATED. It will be removed in a future version. Instructions for updating: Use tf.config.functions_run_eagerly instead of the experimental version.
tf.config.experimental_run_functions_eagerly     View source on GitHub    Enables / disables eager execution of tf.functions. (deprecated)  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.config.experimental_run_functions_eagerly  
tf.config.experimental_run_functions_eagerly(
    run_eagerly
)
 Warning: THIS FUNCTION IS DEPRECATED. It will be removed in a future version. Instructions for updating: Use tf.config.run_functions_eagerly instead of the experimental version. Calling tf.config.experimental_run_functions_eagerly(True) will make all invocations of tf.function run eagerly instead of running as a traced graph function. See tf.config.run_functions_eagerly for an example. 
Note: This flag has no effect on functions passed into tf.data transformations as arguments. tf.data functions are never executed eagerly and are always executed as a compiled Tensorflow Graph.

 


 Args
  run_eagerly   Boolean. Whether to run functions eagerly.
tf.config.functions_run_eagerly Returns the value of the run_functions_eagerly setting.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.config.functions_run_eagerly  
tf.config.functions_run_eagerly()
tf.config.get_logical_device_configuration Get the virtual device configuration for a tf.config.PhysicalDevice.  View aliases  Main aliases 
tf.config.experimental.get_virtual_device_configuration Compat aliases for migration See Migration guide for more details. tf.compat.v1.config.experimental.get_virtual_device_configuration, tf.compat.v1.config.get_logical_device_configuration  
tf.config.get_logical_device_configuration(
    device
)
 Returns the list of tf.config.LogicalDeviceConfiguration objects previously configured by a call to tf.config.set_logical_device_configuration. For example: 
physical_devices = tf.config.list_physical_devices('CPU')
assert len(physical_devices) == 1, "No CPUs found"
configs = tf.config.get_logical_device_configuration(
  physical_devices[0])
try:
  assert configs is None
  tf.config.set_logical_device_configuration(
    physical_devices[0],
    [tf.config.LogicalDeviceConfiguration(),
     tf.config.LogicalDeviceConfiguration()])
  configs = tf.config.get_logical_device_configuration(
    physical_devices[0])
  assert len(configs) == 2
except:
  # Cannot modify virtual devices once initialized.
  pass

 


 Args
  device   PhysicalDevice to query   
 


 Returns   List of tf.config.LogicalDeviceConfiguration objects or None if no virtual device configuration has been set for this physical device.
tf.config.get_soft_device_placement     View source on GitHub    Get if soft device placement is enabled.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.config.get_soft_device_placement  
tf.config.get_soft_device_placement()
 If enabled, an op will be placed on CPU if any of the following are true  there's no GPU implementation for the OP no GPU devices are known or registered need to co-locate with reftype input(s) which are from CPU 
 


 Returns   If soft placement is enabled.
tf.config.get_visible_devices Get the list of visible physical devices.  View aliases  Main aliases 
tf.config.experimental.get_visible_devices Compat aliases for migration See Migration guide for more details. tf.compat.v1.config.experimental.get_visible_devices, tf.compat.v1.config.get_visible_devices  
tf.config.get_visible_devices(
    device_type=None
)
 Returns the list of PhysicalDevices currently marked as visible to the runtime. A visible device will have at least one LogicalDevice associated with it once the runtime is initialized. The following example verifies all visible GPUs have been disabled: 
physical_devices = tf.config.list_physical_devices('GPU')
try:
  # Disable all GPUS
  tf.config.set_visible_devices([], 'GPU')
  visible_devices = tf.config.get_visible_devices()
  for device in visible_devices:
    assert device.device_type != 'GPU'
except:
  # Invalid device or cannot modify virtual devices once initialized.
  pass

 


 Args
  device_type   (optional string) Only include devices matching this device type. For example "CPU" or "GPU".   
 


 Returns   List of visible PhysicalDevices
tf.config.list_logical_devices Return a list of logical devices created by runtime.  View aliases  Main aliases 
tf.config.experimental.list_logical_devices Compat aliases for migration See Migration guide for more details. tf.compat.v1.config.experimental.list_logical_devices, tf.compat.v1.config.list_logical_devices  
tf.config.list_logical_devices(
    device_type=None
)
 Logical devices may correspond to physical devices or remote devices in the cluster. Operations and tensors may be placed on these devices by using the name of the tf.config.LogicalDevice. Calling tf.config.list_logical_devices triggers the runtime to configure any tf.config.PhysicalDevice visible to the runtime, thereby preventing further configuration. To avoid runtime initialization, call tf.config.list_physical_devices instead. For example: 
logical_devices = tf.config.list_logical_devices('GPU')
if len(logical_devices) > 0:
  # Allocate on GPU:0
  with tf.device(logical_devices[0].name):
    one = tf.constant(1)
  # Allocate on GPU:1
  with tf.device(logical_devices[1].name):
    two = tf.constant(2)

 


 Args
  device_type   (optional string) Only include devices matching this device type. For example "CPU" or "GPU".   
 


 Returns   List of initialized LogicalDevices
tf.config.list_physical_devices Return a list of physical devices visible to the host runtime.  View aliases  Main aliases 
tf.config.experimental.list_physical_devices Compat aliases for migration See Migration guide for more details. tf.compat.v1.config.experimental.list_physical_devices, tf.compat.v1.config.list_physical_devices  
tf.config.list_physical_devices(
    device_type=None
)
 Physical devices are hardware devices present on the host machine. By default all discovered CPU and GPU devices are considered visible. This API allows querying the physical hardware resources prior to runtime initialization. Thus, giving an opportunity to call any additional configuration APIs. This is in contrast to tf.config.list_logical_devices, which triggers runtime initialization in order to list the configured devices. The following example lists the number of visible GPUs on the host. 
physical_devices = tf.config.list_physical_devices('GPU')
print("Num GPUs:", len(physical_devices))
Num GPUs: ...
 However, the number of GPUs available to the runtime may change during runtime initialization due to marking certain devices as not visible or configuring multiple logical devices.
 


 Args
  device_type   (optional string) Only include devices matching this device type. For example "CPU" or "GPU".   
 


 Returns   List of discovered tf.config.PhysicalDevice objects
tf.config.LogicalDevice Abstraction for a logical device initialized by the runtime.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.config.LogicalDevice  
tf.config.LogicalDevice(
    name, device_type
)
 A tf.config.LogicalDevice corresponds to an initialized logical device on a tf.config.PhysicalDevice or a remote device visible to the cluster. Tensors and operations can be placed on a specific logical device by calling tf.device with a specified tf.config.LogicalDevice. Fields:  
name: The fully qualified name of the device. Can be used for Op or function placement. 
device_type: String declaring the type of device such as "CPU" or "GPU". 
 


 Attributes
  name  
 
  device_type
tf.config.LogicalDeviceConfiguration Configuration class for a logical devices.  View aliases  Main aliases 
tf.config.experimental.VirtualDeviceConfiguration Compat aliases for migration See Migration guide for more details. tf.compat.v1.config.LogicalDeviceConfiguration, tf.compat.v1.config.experimental.VirtualDeviceConfiguration  
tf.config.LogicalDeviceConfiguration(
    memory_limit=None, experimental_priority=None
)
 The class specifies the parameters to configure a tf.config.PhysicalDevice as it is initialized to a tf.config.LogicalDevice during runtime initialization. Not all fields are valid for all device types. See tf.config.get_logical_device_configuration and tf.config.set_logical_device_configuration for usage examples. Fields:  
memory_limit: (optional) Maximum memory (in MB) to allocate on the virtual device. Currently only supported for GPUs. 
experimental_priority: (optional) Priority to assign to a virtual device. Lower values have higher priorities and 0 is the default. Within a physical GPU, the GPU scheduler will prioritize ops on virtual devices with higher priority. Currently only supported for Nvidia GPUs. 
 


 Attributes
  memory_limit  
 
  experimental_priority
Module: tf.config.optimizer Public API for tf.config.optimizer namespace. Functions get_experimental_options(...): Get experimental optimizer options. get_jit(...): Get if JIT compilation is enabled. set_experimental_options(...): Set experimental optimizer options. set_jit(...): Set if JIT compilation is enabled.
tf.config.optimizer.get_experimental_options     View source on GitHub    Get experimental optimizer options.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.config.optimizer.get_experimental_options  
tf.config.optimizer.get_experimental_options()
 Refer to tf.config.optimizer.set_experimental_options for a list of current options. Note that optimizations are only applied in graph mode, (within tf.function). In addition, as these are experimental options, the list is subject to change.
 


 Returns   Dictionary of configured experimental optimizer options
tf.config.optimizer.get_jit     View source on GitHub    Get if JIT compilation is enabled.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.config.optimizer.get_jit  
tf.config.optimizer.get_jit()
 Note that optimizations are only applied to code that is compiled into a graph. In eager mode, which is the TF2 API default, that means only code that is defined under a tf.function decorator.
 


 Returns   If JIT compilation is enabled.
tf.config.optimizer.set_experimental_options     View source on GitHub    Set experimental optimizer options.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.config.optimizer.set_experimental_options  
tf.config.optimizer.set_experimental_options(
    options
)
 Note that optimizations are only applied in graph mode, (within tf.function). In addition, as these are experimental options, the list is subject to change.
 


 Args
  options   Dictionary of experimental optimizer options to configure. Valid keys:  layout_optimizer: Optimize tensor layouts e.g. This will try to use NCHW layout on GPU which is faster. constant_folding: Fold constants Statically infer the value of tensors when possible, and materialize the result using constants. shape_optimization: Simplify computations made on shapes. remapping: Remap subgraphs onto more efficient implementations. arithmetic_optimization: Simplify arithmetic ops with common sub-expression elimination and arithmetic simplification. dependency_optimization: Control dependency optimizations. Remove redundant control dependencies, which may enable other optimization. This optimizer is also essential for pruning Identity and NoOp nodes. loop_optimization: Loop optimizations. function_optimization: Function optimizations and inlining. debug_stripper: Strips debug-related nodes from the graph. disable_model_pruning: Disable removal of unnecessary ops from the graph scoped_allocator_optimization: Try to allocate some independent Op outputs contiguously in order to merge or eliminate downstream Ops. pin_to_host_optimization: Force small ops onto the CPU. implementation_selector: Enable the swap of kernel implementations based on the device placement. auto_mixed_precision: Change certain float32 ops to float16 on Volta GPUs and above. Without the use of loss scaling, this can cause numerical underflow (see keras.mixed_precision.experimental.LossScaleOptimizer). disable_meta_optimizer: Disable the entire meta optimizer. min_graph_nodes: The minimum number of nodes in a graph to optimizer. For smaller graphs, optimization is skipped.
tf.config.optimizer.set_jit     View source on GitHub    Set if JIT compilation is enabled.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.config.optimizer.set_jit  
tf.config.optimizer.set_jit(
    enabled
)
 Note that optimizations are only applied to code that is compiled into a graph. In eager mode, which is the TF2 API default, that means only code that is defined under a tf.function decorator.
 


 Args
  enabled   Whether to enable JIT compilation.
tf.config.PhysicalDevice Abstraction for a locally visible physical device.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.config.PhysicalDevice  
tf.config.PhysicalDevice(
    name, device_type
)
 TensorFlow can utilize various devices such as the CPU or multiple GPUs for computation. Before initializing a local device for use, the user can customize certain properties of the device such as it's visibility or memory configuration. Once a visible tf.config.PhysicalDevice is initialized one or more tf.config.LogicalDevice objects are created. Use tf.config.set_visible_devices to configure the visibility of a physical device and tf.config.set_logical_device_configuration to configure multiple tf.config.LogicalDevice objects for a tf.config.PhysicalDevice. This is useful when separation between models is needed or to simulate a multi-device environment. Fields:  
name: Unique identifier for device. 
device_type: String declaring the type of device such as "CPU" or "GPU". 
 


 Attributes
  name  
 
  device_type
tf.config.run_functions_eagerly Enables / disables eager execution of tf.functions.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.config.run_functions_eagerly  
tf.config.run_functions_eagerly(
    run_eagerly
)
 Calling tf.config.run_functions_eagerly(True) will make all invocations of tf.function run eagerly instead of running as a traced graph function. This can be useful for debugging. 
def my_func(a):
 print("Python side effect")
 return a + a
a_fn = tf.function(my_func)
 
# A side effect the first time the function is traced
a_fn(tf.constant(1))
Python side effect
<tf.Tensor: shape=(), dtype=int32, numpy=2>
 
# No further side effect, as the traced function is called
a_fn(tf.constant(2))
<tf.Tensor: shape=(), dtype=int32, numpy=4>
 
# Now, switch to eager running
tf.config.run_functions_eagerly(True)
# Side effect, as the function is called directly
a_fn(tf.constant(2))
Python side effect
<tf.Tensor: shape=(), dtype=int32, numpy=4>
 
# Turn this back off
tf.config.run_functions_eagerly(False)
 
Note: This flag has no effect on functions passed into tf.data transformations as arguments. tf.data functions are never executed eagerly and are always executed as a compiled Tensorflow Graph.

 


 Args
  run_eagerly   Boolean. Whether to run functions eagerly.
tf.config.set_logical_device_configuration Set the logical device configuration for a tf.config.PhysicalDevice.  View aliases  Main aliases 
tf.config.experimental.set_virtual_device_configuration Compat aliases for migration See Migration guide for more details. tf.compat.v1.config.experimental.set_virtual_device_configuration, tf.compat.v1.config.set_logical_device_configuration  
tf.config.set_logical_device_configuration(
    device, logical_devices
)
 A visible tf.config.PhysicalDevice will by default have a single tf.config.LogicalDevice associated with it once the runtime is initialized. Specifying a list of tf.config.LogicalDeviceConfiguration objects allows multiple devices to be created on the same tf.config.PhysicalDevice. The following example splits the CPU into 2 logical devices: 
physical_devices = tf.config.list_physical_devices('CPU')
assert len(physical_devices) == 1, "No CPUs found"
# Specify 2 virtual CPUs. Note currently memory limit is not supported.
try:
  tf.config.set_logical_device_configuration(
    physical_devices[0],
    [tf.config.LogicalDeviceConfiguration(),
     tf.config.LogicalDeviceConfiguration()])
  logical_devices = tf.config.list_logical_devices('CPU')
  assert len(logical_devices) == 2

  tf.config.set_logical_device_configuration(
    physical_devices[0],
    [tf.config.LogicalDeviceConfiguration(),
     tf.config.LogicalDeviceConfiguration(),
     tf.config.LogicalDeviceConfiguration(),
     tf.config.LogicalDeviceConfiguration()])
except:
  # Cannot modify logical devices once initialized.
  pass
 The following example splits the GPU into 2 logical devices with 100 MB each: 
physical_devices = tf.config.list_physical_devices('GPU')
try:
  tf.config.set_logical_device_configuration(
    physical_devices[0],
    [tf.config.LogicalDeviceConfiguration(memory_limit=100),
     tf.config.LogicalDeviceConfiguration(memory_limit=100)])

  logical_devices = tf.config.list_logical_devices('GPU')
  assert len(logical_devices) == len(physical_devices) + 1

  tf.config.set_logical_device_configuration(
    physical_devices[0],
    [tf.config.LogicalDeviceConfiguration(memory_limit=10),
     tf.config.LogicalDeviceConfiguration(memory_limit=10)])
except:
  # Invalid device or cannot modify logical devices once initialized.
  pass

 


 Args
  device   The PhysicalDevice to configure.  
  logical_devices   (optional) List of tf.config.LogicalDeviceConfiguration objects to allocate for the specified PhysicalDevice. If None, the default configuration will be used.   
 


 Raises
  ValueError   If argument validation fails.  
  RuntimeError   Runtime is already initialized.
tf.config.set_soft_device_placement     View source on GitHub    Set if soft device placement is enabled.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.config.set_soft_device_placement  
tf.config.set_soft_device_placement(
    enabled
)
 If enabled, an op will be placed on CPU if any of the following are true  there's no GPU implementation for the OP no GPU devices are known or registered need to co-locate with reftype input(s) which are from CPU 
 


 Args
  enabled   Whether to enable soft placement.
tf.config.set_visible_devices Set the list of visible devices.  View aliases  Main aliases 
tf.config.experimental.set_visible_devices Compat aliases for migration See Migration guide for more details. tf.compat.v1.config.experimental.set_visible_devices, tf.compat.v1.config.set_visible_devices  
tf.config.set_visible_devices(
    devices, device_type=None
)
 Specifies which PhysicalDevice objects are visible to the runtime. TensorFlow will only allocate memory and place operations on visible physical devices, as otherwise no LogicalDevice will be created on them. By default all discovered devices are marked as visible. The following example demonstrates disabling the first GPU on the machine. 
physical_devices = tf.config.list_physical_devices('GPU')
try:
  # Disable first GPU
  tf.config.set_visible_devices(physical_devices[1:], 'GPU')
  logical_devices = tf.config.list_logical_devices('GPU')
  # Logical device was not created for first GPU
  assert len(logical_devices) == len(physical_devices) - 1
except:
  # Invalid device or cannot modify virtual devices once initialized.
  pass

 


 Args
  devices   List of PhysicalDevices to make visible  
  device_type   (optional) Only configure devices matching this device type. For example "CPU" or "GPU". Other devices will be left unaltered.   
 


 Raises
  ValueError   If argument validation fails.  
  RuntimeError   Runtime is already initialized.