{"record":{"id":"365eb8083f9c1d35","repo":"tensorflow/models","slug":"custom-training-loop-on-gpus-is-not-implemented","errorCode":null,"errorMessage":"Custom training loop on GPUs is not implemented.","messagePattern":"Custom training loop on GPUs is not implemented\\.","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"official/legacy/transformer/transformer_main.py","lineNumber":297,"sourceCode":"        train_loss_metric.reset_states()\n        self.distribution_strategy.run(\n            _step_fn, args=(next(iterator),))\n\n    cased_score, uncased_score = None, None\n    cased_score_history, uncased_score_history = [], []\n    while current_step < flags_obj.train_steps:\n      remaining_steps = flags_obj.train_steps - current_step\n      train_steps_per_eval = (\n          remaining_steps if remaining_steps < flags_obj.steps_between_evals\n          else flags_obj.steps_between_evals)\n      current_iteration = current_step // flags_obj.steps_between_evals\n\n      logging.info(\n          \"Start train iteration at global step:{}\".format(current_step))\n      history = None\n      if params[\"use_ctl\"]:\n        if not self.use_tpu:\n          raise NotImplementedError(\n              \"Custom training loop on GPUs is not implemented.\")\n\n        # Runs training steps.\n        with summary_writer.as_default():\n          for cb in callbacks:\n            cb.on_epoch_begin(current_iteration)\n            cb.on_batch_begin(0)\n\n          train_steps(\n              train_ds_iterator,\n              tf.convert_to_tensor(train_steps_per_eval, dtype=tf.int32))\n          current_step += train_steps_per_eval\n          train_loss = train_loss_metric.result().numpy().astype(float)\n          logging.info(\"Train Step: %d/%d / loss = %s\", current_step,\n                       flags_obj.train_steps, train_loss)\n\n          for cb in callbacks:\n            cb.on_batch_end(train_steps_per_eval - 1)","sourceCodeStart":279,"sourceCodeEnd":315,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/legacy/transformer/transformer_main.py#L279-L315","documentation":"Error \"Custom training loop on GPUs is not implemented.\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/legacy/transformer/transformer_main.py:297 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"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"}