diff --git a/python/paddle/fluid/tests/unittests/seresnext_net.py b/python/paddle/fluid/tests/unittests/seresnext_net.py index c31471efbde84da1ea1b3141f344bbefda8134c2..252ffe2c22ad2e9d0b48e89d9dc0a7d695e1c0a4 100644 --- a/python/paddle/fluid/tests/unittests/seresnext_net.py +++ b/python/paddle/fluid/tests/unittests/seresnext_net.py @@ -172,8 +172,11 @@ def optimizer(learning_rate=0.01): model = SE_ResNeXt50Small -def batch_size(): - return 8 +def batch_size(use_cuda): + if use_cuda: + # Paddle uses 8GB P4 GPU for unittest so we decreased the batch size. + return 8 + return 12 def iter(use_cuda): @@ -183,9 +186,9 @@ def iter(use_cuda): gpu_img, gpu_label = init_data( - batch_size=batch_size(), img_shape=img_shape, label_range=999) + batch_size=batch_size(use_cuda=True), img_shape=img_shape, label_range=999) cpu_img, cpu_label = init_data( - batch_size=batch_size(), img_shape=img_shape, label_range=999) + batch_size=batch_size(use_cuda=False), img_shape=img_shape, label_range=999) feed_dict_gpu = {"image": gpu_img, "label": gpu_label} feed_dict_cpu = {"image": cpu_img, "label": cpu_label} diff --git a/python/paddle/fluid/tests/unittests/seresnext_test_base.py b/python/paddle/fluid/tests/unittests/seresnext_test_base.py index 65879d39d91145b2403ac1b0c29e51df1960c8d1..9f055191b11a5c3708d19f984996149db37e798a 100644 --- a/python/paddle/fluid/tests/unittests/seresnext_test_base.py +++ b/python/paddle/fluid/tests/unittests/seresnext_test_base.py @@ -32,7 +32,7 @@ class TestResnetBase(TestParallelExecutorBase): seresnext_net.model, feed_dict=seresnext_net.feed_dict(use_cuda), iter=seresnext_net.iter(use_cuda), - batch_size=seresnext_net.batch_size(), + batch_size=seresnext_net.batch_size(use_cuda), use_cuda=use_cuda, use_reduce=False, optimizer=seresnext_net.optimizer) @@ -41,7 +41,7 @@ class TestResnetBase(TestParallelExecutorBase): seresnext_net.model, feed_dict=seresnext_net.feed_dict(use_cuda), iter=seresnext_net.iter(use_cuda), - batch_size=seresnext_net.batch_size(), + batch_size=seresnext_net.batch_size(use_cuda), use_cuda=use_cuda) if compare_seperately: diff --git a/python/paddle/fluid/tests/unittests/test_parallel_executor_seresnext_with_reduce_cpu.py b/python/paddle/fluid/tests/unittests/test_parallel_executor_seresnext_with_reduce_cpu.py index 74c5999c4fd3e4be82e9a5b2484efe69a0271baf..62eb7e1155e6f2ffa6e4e7b32ff1cfcf8eeb6ea3 100644 --- a/python/paddle/fluid/tests/unittests/test_parallel_executor_seresnext_with_reduce_cpu.py +++ b/python/paddle/fluid/tests/unittests/test_parallel_executor_seresnext_with_reduce_cpu.py @@ -28,7 +28,7 @@ class TestResnetWithReduceBase(TestParallelExecutorBase): seresnext_net.model, feed_dict=seresnext_net.feed_dict(use_cuda), iter=seresnext_net.iter(use_cuda), - batch_size=seresnext_net.batch_size(), + batch_size=seresnext_net.batch_size(use_cuda), use_cuda=use_cuda, use_reduce=False, optimizer=seresnext_net.optimizer) @@ -36,7 +36,7 @@ class TestResnetWithReduceBase(TestParallelExecutorBase): seresnext_net.model, feed_dict=seresnext_net.feed_dict(use_cuda), iter=seresnext_net.iter(use_cuda), - batch_size=seresnext_net.batch_size(), + batch_size=seresnext_net.batch_size(use_cuda), use_cuda=use_cuda, use_reduce=True, optimizer=seresnext_net.optimizer) @@ -53,7 +53,7 @@ class TestResnetWithReduceBase(TestParallelExecutorBase): seresnext_net.model, feed_dict=seresnext_net.feed_dict(use_cuda), iter=seresnext_net.iter(use_cuda), - batch_size=seresnext_net.batch_size(), + batch_size=seresnext_net.batch_size(use_cuda), use_cuda=use_cuda, use_reduce=False, optimizer=seresnext_net.optimizer, @@ -63,7 +63,7 @@ class TestResnetWithReduceBase(TestParallelExecutorBase): seresnext_net.model, feed_dict=seresnext_net.feed_dict(use_cuda), iter=seresnext_net.iter(use_cuda), - batch_size=seresnext_net.batch_size(), + batch_size=seresnext_net.batch_size(use_cuda), use_cuda=use_cuda, use_reduce=True, optimizer=seresnext_net.optimizer,