Minor Bug: HF (run_text_classification) attempts to use XLA on CUDA device

A minor inconsistency: on a GPU runtime, when I execute:

!pip install -q cloud-tpu-client==0.10 https://storage.googleapis.com/tpu-pytorch/wheels/torch_xla-1.9-cp37-cp37m-linux_x86_64.whl

to install the TPU client, HuggingFace will try to use XLA even if a CUDA device is present.

RuntimeError: tensorflow/compiler/xla/xla_client/computation_client.cc:273 : Missing XLA configuration

Shouldn’t there be checks to verify if XLA/TPU cores flag is not passed, it should fall back to CUDA->CPU rather than trying to run via XLA?

Good point, which flags were you thinking of? If you feel up to it, don’t hesitate to open a PR with those changes!

These were the flags in my mind:-

--xla [XLA]           Whether to activate the XLA compilation or not
--tpu_name TPU_NAME   Name of TPU
--tpu_zone TPU_ZONE   Zone of TPU
--tpu_num_cores TPU_NUM_CORES
                        TPU: Number of TPU cores (automatically passed by
                        launcher script)

which indicates TPU/XLA is being used.
I don’t think I am ready to open PR’s yet :sweat_smile: though I am happy to assist in other ways :slight_smile:

1 Like

Ok, will add it then.