Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running BicleanerAI with TPUs #32

Open
charliekocsis opened this issue May 22, 2024 · 1 comment
Open

Running BicleanerAI with TPUs #32

charliekocsis opened this issue May 22, 2024 · 1 comment

Comments

@charliekocsis
Copy link

Hi Bitextor team,

I'm using Bicleaner AI to clean up Opus corpora. As part of that I was looking at using TPUs for the clean up process.

On Kaggle, there is documentation on using TPUs with TF and Keras as follows:

# detect and init the TPU
tpu = tf.distribute.cluster_resolver.TPUClusterResolver()

# instantiate a distribution strategy
tf.tpu.experimental.initialize_tpu_system(tpu)
tpu_strategy = tf.distribute.TPUStrategy(tpu)

# instantiating the model in the strategy scope creates the model on the TPU
with tpu_strategy.scope():
    model = tf.keras.Sequential( … ) # define your model normally
    model.compile( … )

# train model normally
model.fit(training_dataset, epochs=EPOCHS, steps_per_epoch=…)

But I am not sure how I would compile and run a bicleaner-ai model with TPUs. Is there a simple way to integrate Bicleaner AI with TPU support?

Thanks for your help in advance.

@ZJaume
Copy link
Member

ZJaume commented May 23, 2024

I guess that if you need to set the TPU scope during model loading (not exactly as the example, because that is for training, though), you will need to do it here:

try:
self.model = load_model(self.dir+'/'+self.settings["model_file"],
custom_objects=deps, compile=False)
except ValueError:
self.model = self.build_model(compile=False)
self.model.load_weights(self.dir+'/'+self.settings["model_file"])

But never tried using TPUs with Bicleaner AI, not sure if it will work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants