test_dist_fleet_ctr2.py 3.4 KB
Newer Older
T
tangwei12 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
# Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import print_function

import os
import unittest
import tempfile
from test_dist_fleet_base import TestFleetBase


T
tangwei12 已提交
23
@unittest.skip(reason="Skip unstable ut, need paddle sync mode fix")
T
tangwei12 已提交
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
class TestDistMnistSync2x2(TestFleetBase):
    def _setup_config(self):
        self._mode = "sync"
        self._reader = "pyreader"
        self._need_test = 1

    def check_with_place(self,
                         model_file,
                         delta=1e-3,
                         check_error_log=False,
                         need_envs={}):
        required_envs = {
            "PATH": os.getenv("PATH", ""),
            "PYTHONPATH": os.getenv("PYTHONPATH", ""),
            "LD_LIBRARY_PATH": os.getenv("LD_LIBRARY_PATH", ""),
            "FLAGS_rpc_deadline": "5000",  # 5sec to fail fast
            "http_proxy": "",
T
tangwei12 已提交
41 42 43
            "CPU_NUM": "2",
            "LOG_DIRNAME": "/tmp",
            "LOG_PREFIX": self.__class__.__name__,
T
tangwei12 已提交
44 45 46 47 48 49 50 51 52 53 54
        }

        required_envs.update(need_envs)

        if check_error_log:
            required_envs["GLOG_v"] = "3"
            required_envs["GLOG_logtostderr"] = "1"

        tr0_losses, tr1_losses = self._run_cluster(model_file, required_envs)

    def test_dist_train(self):
55 56 57
        #        self.check_with_place(
        #            "dist_fleet_ctr.py", delta=1e-5, check_error_log=False)
        print('recover later')
T
tangwei12 已提交
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80


# @unittest.skip(reason="Skip unstable ut, reader need to be rewrite")
class TestDistMnistAsyncDataset2x2(TestFleetBase):
    def _setup_config(self):
        self._mode = "async"
        self._reader = "dataset"

    def check_with_place(self,
                         model_file,
                         delta=1e-3,
                         check_error_log=False,
                         need_envs={}):
        required_envs = {
            "PATH": os.getenv("PATH", ""),
            "PYTHONPATH": os.getenv("PYTHONPATH", ""),
            "LD_LIBRARY_PATH": os.getenv("LD_LIBRARY_PATH", ""),
            "FLAGS_rpc_deadline": "5000",  # 5sec to fail fast
            "http_proxy": "",
            "SAVE_MODEL": "1",
            "dump_param": "concat_0.tmp_0",
            "dump_fields": "dnn-fc-3.tmp_0,dnn-fc-3.tmp_0@GRAD",
            "dump_fields_path": tempfile.mkdtemp(),
T
tangwei12 已提交
81 82 83
            "Debug": "1",
            "LOG_DIRNAME": "/tmp",
            "LOG_PREFIX": self.__class__.__name__,
T
tangwei12 已提交
84 85 86 87 88 89 90 91 92 93 94
        }

        required_envs.update(need_envs)

        if check_error_log:
            required_envs["GLOG_v"] = "3"
            required_envs["GLOG_logtostderr"] = "1"

        tr0_losses, tr1_losses = self._run_cluster(model_file, required_envs)

    def test_dist_train(self):
95 96 97
        #        self.check_with_place(
        #            "dist_fleet_ctr.py", delta=1e-5, check_error_log=False)
        print('recover later')
T
tangwei12 已提交
98 99 100 101


if __name__ == "__main__":
    unittest.main()