tensorflow/models · error · ValueError

The tf_data_service flag requires Tensorflow version >=…

Error message

The tf_data_service flag requires Tensorflow version >= 2.3.0, but the version is {}

What it means

Version guard in the dataset pipeline: the tf_data_service flag was enabled, but the installed TensorFlow is older than 2.3.0, which first introduced tf.data service support. The environment, not the config values, fails the check.

Solutions

  1. Upgrade TensorFlow to >= 2.3.0
  2. Disable the tf_data_service flag to use the standard input pipeline
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at official/legacy/image_classification/dataset_factory.py:464 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of tensorflow/models@e006f5f0d5 (2026-08-24). Data as JSON: /api/errors/ac6681e33322c1ce. Report an issue: GitHub.

Appendix: source

Thrown at official/legacy/image_classification/dataset_factory.py:464

            '`per_replica_batch_size` and enable '
            '`use_per_replica_batch_size=True`.'.format(
                self.config.num_devices))

      # The batch size of the dataset will be multiplied by the number of
      # replicas automatically when strategy.distribute_datasets_from_function
      # is called, so we use local batch size here.
      dataset = dataset.batch(
          self.local_batch_size, drop_remainder=self.is_training)
    else:
      dataset = dataset.batch(
          self.global_batch_size, drop_remainder=self.is_training)

    # Prefetch overlaps in-feed with training
    dataset = dataset.prefetch(tf.data.experimental.AUTOTUNE)

    if self.config.tf_data_service:
      if not hasattr(tf.data.experimental, 'service'):
        raise ValueError('The tf_data_service flag requires Tensorflow version '
                         '>= 2.3.0, but the version is {}'.format(
                             tf.__version__))
      dataset = dataset.apply(
          tf.data.experimental.service.distribute(
              processing_mode='parallel_epochs',
              service=self.config.tf_data_service,
              job_name='resnet_train'))
      dataset = dataset.prefetch(buffer_size=tf.data.experimental.AUTOTUNE)

    return dataset

  def parse_record(self, record: tf.Tensor) -> Tuple[tf.Tensor, tf.Tensor]:
    """Parse an ImageNet record from a serialized string Tensor."""
    keys_to_features = {
        'image/encoded': tf.io.FixedLenFeature((), tf.string, ''),
        'image/format': tf.io.FixedLenFeature((), tf.string, 'jpeg'),
        'image/class/label': tf.io.FixedLenFeature([], tf.int64, -1),
        'image/class/text': tf.io.FixedLenFeature([], tf.string, ''),

View on GitHub (pinned to e006f5f0d5)