(argv: Sequence[str])
| 366 | |
| 367 | |
| 368 | def main(argv: Sequence[str]) -> None: |
| 369 | pathwaysutils.initialize() |
| 370 | jax.config.update("jax_default_prng_impl", "unsafe_rbg") |
| 371 | # TF allocates extraneous GPU memory when using TFDS data |
| 372 | # this leads to CUDA OOMs. WAR for now is to hide GPUs from TF |
| 373 | tf.config.set_visible_devices([], "GPU") |
| 374 | os.environ["TF_CPP_MIN_LOG_LEVEL"] = "0" |
| 375 | if "xla_tpu_spmd_rng_bit_generator_unsafe" not in os.environ.get("LIBTPU_INIT_ARGS", ""): |
| 376 | os.environ["LIBTPU_INIT_ARGS"] = ( |
| 377 | os.environ.get("LIBTPU_INIT_ARGS", "") + " --xla_tpu_spmd_rng_bit_generator_unsafe=true" |
| 378 | ) |
| 379 | |
| 380 | elastic_manager = elastic_initialize(jax.devices()) |
| 381 | |
| 382 | config = pyconfig.initialize(argv) |
| 383 | jax.config.update("jax_use_shardy_partitioner", config.shardy) |
| 384 | max_utils.print_system_information() |
| 385 | validate_train_config(config) |
| 386 | os.environ["TFDS_DATA_DIR"] = config.dataset_path or "" |
| 387 | vertex_tensorboard_manager = VertexTensorboardManager() |
| 388 | if config.use_vertex_tensorboard or os.environ.get("UPLOAD_DATA_TO_TENSORBOARD"): |
| 389 | vertex_tensorboard_manager.configure_vertex_tensorboard(config) |
| 390 | |
| 391 | # Create the Goodput recorder |
| 392 | recorder = create_goodput_recorder(config) |
| 393 | |
| 394 | # Stack traces configurations |
| 395 | debug_config = debug_configuration.DebugConfig( |
| 396 | stack_trace_config=stack_trace_configuration.StackTraceConfig( |
| 397 | collect_stack_trace=config.collect_stack_trace, |
| 398 | stack_trace_to_cloud=config.stack_trace_to_cloud, |
| 399 | stack_trace_interval_seconds=config.stack_trace_interval_seconds, |
| 400 | ) |
| 401 | ) |
| 402 | diagnostic_config = diagnostic_configuration.DiagnosticConfig(debug_config) |
| 403 | |
| 404 | with diagnostic.diagnose(diagnostic_config): |
| 405 | with maybe_record_goodput(recorder, GoodputEvent.JOB), maybe_monitor_goodput(config): |
| 406 | train_loop(config, elastic_manager, recorder) |
| 407 | |
| 408 | |
| 409 | if __name__ == "__main__": |
nothing calls this directly
no test coverage detected