{"record":{"id":"6a0187dd8aba874f","repo":"tensorflow/models","slug":"the-number-of-logical-devices-d-is-not-supported","errorCode":null,"errorMessage":"The number of logical devices %d is not supported. Supported numbers are 1, 2, 4, 8, 16","messagePattern":"The number of logical devices (.+?) is not supported\\. Supported numbers are 1, 2, 4, 8, 16","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/vision/train_spatial_partitioning.py","lineNumber":61,"sourceCode":"  Returns:\n    A list of integers specifying the computation shape.\n\n  Raises:\n    ValueError: If the number of logical devices is not supported.\n  \"\"\"\n  num_logical_devices = np.prod(input_partition_dims)\n  if num_logical_devices == 1:\n    return [1, 1, 1, 1]\n  elif num_logical_devices == 2:\n    return [1, 1, 1, 2]\n  elif num_logical_devices == 4:\n    return [1, 2, 1, 2]\n  elif num_logical_devices == 8:\n    return [2, 2, 1, 2]\n  elif num_logical_devices == 16:\n    return [4, 2, 1, 2]\n  else:\n    raise ValueError(\n        'The number of logical devices %d is not supported. Supported numbers '\n        'are 1, 2, 4, 8, 16' % num_logical_devices)\n\n\ndef create_distribution_strategy(distribution_strategy,\n                                 tpu_address,\n                                 input_partition_dims=None,\n                                 num_gpus=None):\n  \"\"\"Creates distribution strategy to use for computation.\"\"\"\n\n  if input_partition_dims is not None:\n    if distribution_strategy != 'tpu':\n      raise ValueError('Spatial partitioning is only supported '\n                       'for TPUStrategy.')\n\n    # When `input_partition_dims` is specified create custom TPUStrategy\n    # instance with computation shape for model parallelism.\n    resolver = tf.distribute.cluster_resolver.TPUClusterResolver(","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/vision/train_spatial_partitioning.py#L43-L79","documentation":"Error \"The number of logical devices %d is not supported. Supported numbers are 1, 2, 4, 8, 16\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/vision/train_spatial_partitioning.py:61 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set the number of logical devices to one of 1, 2, 4, 8, or 16.","Adjust the TPU topology or device partition config to a supported count."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e006f5f0d534913e49c1f1dae87364039fa607e2","analyzedAt":"2026-08-24T14:09:15.576Z","schemaVersion":2},"datasetVersion":"2026-08-24T17:17:21.512Z"}