Closed wangkuiyi closed 7 years ago
Each unit test shouldn't consume too much GPU memory.
I checked test_sigmoid.py
class TestSigmoidOp(unittest.TestCase):
__metaclass__ = OpTestMeta
def setUp(self):
self.type = "sigmoid"
self.inputs = {'X': np.random.random((32, 100)).astype("float32")}
self.outputs = {'Y': 1 / (1 + np.exp(-self.inputs['X']))}
It seems that np.random.random((32,100))
generates a 32x100-matrix. Why do we need this big matrix? What is the difference than using a smaller, say, 3x2
matrix?
Similarly, in test_add_two_op.py
, we have
'X': numpy.random.random((102, 105)).astype("float32"),
'Y': numpy.random.random((102, 105)).astype("float32")
Why big matrices of 102x105? What's the difference if we change to 2x5?
Got it! I will reduce the tensor size in framework/op test @wangkuiyi
matrix sizes of 102105, 32100 are really not that big. There must be some other cause.
@emailweixu Created an issue https://github.com/PaddlePaddle/Paddle/issues/3482
Thanks, I will check it. @wangkuiyi @emailweixu
Currently, our new memory management is occupied exclusively by one process.
When we execute unit tests in parallel, one of the processes will occupy 95% GPU memory, when another process allocates GPU memory, if the former process has yet released, then others might get a nullptr
from paddle::memory::Alloc
. That's the reason why parallel unit test jobs frequently failed.
There are two optional stratagems to suppress this issue:
optional 1. set fraction_of_gpu_memory_to_use
in cc_test
, nv_test
of generic.cmake
, but how to make python receive gflags
in py_test
.
optional 2. Add system environment usingstd::getenv
so that we can export FRACTION_GPU_MEMORY_TO_USE=0.2
@wangkuiyi @emailweixu
@emailweixu found that tests can fail for memory allocation if running them in parallel
ctest -I 121,123 -j
: