From 91e2bc8aa0b280e78aac5a839c14461144cbd166 Mon Sep 17 00:00:00 2001 From: Hongyu Li <39792688+HongyuLi2018@users.noreply.github.com> Date: Wed, 3 Jul 2019 11:13:39 +0800 Subject: [PATCH] Check paddle version before using cuda (#2685) --- PaddleNLP/reading_comprehension/src/run.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/PaddleNLP/reading_comprehension/src/run.py b/PaddleNLP/reading_comprehension/src/run.py index 6f28338d..86646a92 100644 --- a/PaddleNLP/reading_comprehension/src/run.py +++ b/PaddleNLP/reading_comprehension/src/run.py @@ -640,6 +640,12 @@ if __name__ == '__main__': logger.addHandler(console_handler) args = parse_args() logger.info('Running with args : {}'.format(args)) + try: + if fluid.is_compiled_with_cuda() != True and args.use_cuda == True: + print("\nYou can not set use_cuda = True in the model because you are using paddlepaddle-cpu.\nPlease: 1. Install paddlepaddle-gpu to run your models on GPU or 2. Set use_cuda = False to run models on CPU.\n") + sys.exit(1) + except Exception as e: + pass if args.prepare: prepare(logger, args) if args.train: -- GitLab