未验证 提交 8a6931df 编写于 作者: L lvmengsi 提交者: GitHub

Check gpu in gan (#2734)

* update checkgpu
上级 196a75cd
......@@ -27,7 +27,7 @@ import imageio
import glob
from util.config import add_arguments, print_arguments
from data_reader import celeba_reader_creator
from util.utility import check_attribute_conflict
from util.utility import check_attribute_conflict, check_gpu
import copy
parser = argparse.ArgumentParser(description=__doc__)
......@@ -235,4 +235,5 @@ def infer(args):
if __name__ == "__main__":
args = parser.parse_args()
print_arguments(args)
check_gpu(args.use_gpu)
infer(args)
......@@ -76,6 +76,7 @@ def train(cfg):
if __name__ == "__main__":
cfg = config.parse_args()
config.print_arguments(cfg)
utility.check_gpu(cfg.use_gpu)
#assert cfg.load_size >= cfg.crop_size, "Load Size CANNOT less than Crop Size!"
if cfg.profile:
if cfg.use_gpu:
......
......@@ -264,3 +264,22 @@ def check_attribute_conflict(label_batch, attr, attrs):
if a != attr:
_set(label, 0, a)
return label_batch
def check_gpu(use_gpu):
"""
Log error and exit when set use_gpu=true in paddlepaddle
cpu version.
"""
err = "Config use_gpu cannot be set as true while you are " \
"using paddlepaddle cpu version ! \nPlease try: \n" \
"\t1. Install paddlepaddle-gpu to run model on GPU \n" \
"\t2. Set use_gpu as false in config file to run " \
"model on CPU"
try:
if use_gpu and not fluid.is_compiled_with_cuda():
logger.error(err)
sys.exit(1)
except Exception as e:
pass
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册