tensorflow / hub

A library for transfer learning by reusing parts of TensorFlow models.
https://tensorflow.org/hub
Apache License 2.0
3.48k stars 1.66k forks source link

BERT preprocess layer runs on CPU #730

Closed ydennisy closed 3 years ago

ydennisy commented 3 years ago

Hi,

When running a BERT model as part of a larger model the preprocess layer seems to run on CPU and then the main BERT component on GPU - this involves lots of ops moving data back and forth and is prohibitively slow.

Is there a way to force all the ops to run on GPU?

Thanks!

arnoegw commented 3 years ago

While I can't comment on the details of performance in your case, here are some general observations:

For a complete example of the Dataset.map() approach, see https://www.tensorflow.org/tutorials/text/solve_glue_tasks_using_bert_on_tpu and ignore the TPU specifics if you are targeting GPUs.

All that said, is there a concrete, actionable defect with the TensorFlow Hub models, library or documentation that needs tracking here? If yes, please provide a compete reproduction and an explanation of what goes wrong. If not, let's close this issue. We recommend StackOverflow (specifically, tag tensorflow-hub) for general how-to and support questions.

ydennisy commented 3 years ago

@arnoegw thanks for that - makes perfect sense.

I will close!