Running BERT on CPU instead of GPU

Viewed 3134

I am trying to execute BERT's run_clasifier.py script using terminal as below:

python run_classifier.py --task_name=cola --do_predict=true --data_dir=<data-dir> --vocab_file=$BERT_BASE_DIR/vocab.txt --bert_config_file=$BERT_BASE_DIR/bert_config.json --init_checkpoint=<output_dir>/model.ckpt-1603 --max_seq_length=512 --output_dir=<output_dir>

This by default executes on GPU. Instead, I want to execute it on the CPU. Is there a way to do it for only a single trial of execution than for all the subsequent trials.?

1 Answers

Try use: os.environ['CUDA_VISIBLE_DEVICES'] = '-1'

Related