# Example in ray.train for tensorflow distributed training?

**URL:** <https://discuss.ray.io/t/example-in-ray-train-for-tensorflow-distributed-training/20736>\
**Category:** Uncategorized\
**Created:** [November 24, 2024, 4:41pm UTC](https://discuss.ray.io/t/example-in-ray-train-for-tensorflow-distributed-training/20736 "2024-11-24T16:41:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aknw\_Fen](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/aknw_fen/32/7351_2.png) [@Aknw\_Fen](https://discuss.ray.io/u/Aknw_Fen)\
**Post date:** [November 24, 2024, 4:41pm UTC](https://discuss.ray.io/t/example-in-ray-train-for-tensorflow-distributed-training/20736/1 "2024-11-24T16:41:58Z")

</div>

I’ve been following [ray train tf](https://docs.ray.io/en/latest/ray-overview/getting-started.html). Under _Distributed Model Training_ one can choose TensorFlow or PyTorch.

For TensorFlow there is this function:

```python
# For GPU Training, set `use_gpu` to True.
use_gpu = False

trainer = TensorflowTrainer(
    train_loop_per_worker=train_func_distributed,
    scaling_config=ScalingConfig(num_workers=4, use_gpu=use_gpu),
)

```

It does not run with tf **2.18** , and ray **2.39.0** and ran on Ubuntu 24.04.

Have others ran this example successfully?

Others seem to [report the same issue here.](https://github.com/ray-project/ray/issues/47464)

---

<div class="post-metadata">

**Author:** ![Aknw\_Fen](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/aknw_fen/32/7351_2.png) [@Aknw\_Fen](https://discuss.ray.io/u/Aknw_Fen)\
**Post date:** [November 24, 2024, 5:38pm UTC](https://discuss.ray.io/t/example-in-ray-train-for-tensorflow-distributed-training/20736/2 "2024-11-24T17:38:16Z")

</div>

I suspect that it’s because of Keras 3; since users report breaking in tf==2.16 which is when the new Keras became the default.

One can pass: `os.environ["TF_USE_LEGACY_KERAS"] = "1" # For TF2.16+.`

But I’m not interested in this workaround. (and that the large amount of users won’t either, in the near future/now.)
