Skip to content

Commit 5a1d272

Browse files
authored
assert fails on requesting gpus when not available
1 parent aeb8cfc commit 5a1d272

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

tutorials/image/cifar10_estimator/cifar10_main.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,8 @@ def main(job_dir, data_dir, num_gpus, variable_strategy,
503503
help='Epsilon for batch norm.')
504504
args = parser.parse_args()
505505

506+
if args.num_gpus>0:
507+
assert tf.test.is_gpu_available(), "Requested GPUs but none found."
506508
if args.num_gpus < 0:
507509
raise ValueError(
508510
'Invalid GPU count: \"--num-gpus\" must be 0 or a positive integer.')

0 commit comments

Comments
 (0)