Explorar el Código

support benchmark for paddlepaddle3.0

zhouchangda hace 1 año
padre
commit
aaa1e5ca00

+ 3 - 1
paddlex/modules/base/trainer/trainer.py

@@ -12,7 +12,6 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-
 import os
 from abc import ABC, abstractmethod
 from pathlib import Path
@@ -51,6 +50,9 @@ class BaseTrainer(ABC, metaclass=AutoRegisterABCMetaClass):
 
         self.deamon = self.build_deamon(self.global_config)
         self.pdx_config, self.pdx_model = build_model(self.global_config.model)
+        #TODO: Control by configuration to support benchmark
+        self.pdx_config.update_log_ranks(self.get_device())
+        self.pdx_config.disable_print_mem_info()
 
     def train(self, *args, **kwargs):
         """execute model training

+ 0 - 2
paddlex/repo_apis/PaddleClas_api/cls/model.py

@@ -66,8 +66,6 @@ class ClsModel(BaseModel):
             config.update_device(device)
             config._update_to_static(dy2st)
             config._update_use_vdl(use_vdl)
-            config.update_log_ranks(device)
-            config.enable_print_mem_info()
 
             if batch_size is not None:
                 config.update_batch_size(batch_size)

+ 17 - 1
paddlex/repo_apis/PaddleDetection_api/instance_seg/config.py

@@ -12,7 +12,6 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-
 from ...base import BaseConfig
 from ....utils.misc import abspath
 from ..config_helper import PPDetConfigMixin
@@ -279,6 +278,23 @@ class InstanceSegConfig(BaseConfig, PPDetConfigMixin):
         """
         self.update({'snapshot_epoch': save_interval})
 
+    def update_log_ranks(self, device):
+        """update log ranks
+
+        Args:
+            device (str): the running device to set
+        """
+        log_ranks = device.split(':')[1]
+        self.update({'log_ranks': log_ranks})
+
+    def enable_print_mem_info(self):
+        """print memory info"""
+        self.update({'print_mem_info': True})
+
+    def disable_print_mem_info(self):
+        """do not print memory info"""
+        self.update({'print_mem_info': False})
+
     def update_weights(self, weight_path: str):
         """update model weight
 

+ 0 - 1
paddlex/repo_apis/PaddleDetection_api/instance_seg/model.py

@@ -12,7 +12,6 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-
 import os
 
 from ...base import BaseModel

+ 17 - 1
paddlex/repo_apis/PaddleDetection_api/object_det/config.py

@@ -12,7 +12,6 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-
 from ...base import BaseConfig
 from ....utils.misc import abspath
 from ....utils import logging
@@ -290,6 +289,23 @@ class DetConfig(BaseConfig, PPDetConfigMixin):
         """
         self.update({'snapshot_epoch': save_interval})
 
+    def update_log_ranks(self, device):
+        """update log ranks
+
+        Args:
+            device (str): the running device to set
+        """
+        log_ranks = device.split(':')[1]
+        self.update({'log_ranks': log_ranks})
+
+    def enable_print_mem_info(self):
+        """print memory info"""
+        self.update({'print_mem_info': True})
+
+    def disable_print_mem_info(self):
+        """do not print memory info"""
+        self.update({'print_mem_info': False})
+
     def update_weights(self, weight_path: str):
         """update model weight
 

+ 0 - 2
paddlex/repo_apis/PaddleDetection_api/object_det/model.py

@@ -12,8 +12,6 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-
-
 import os
 
 from ...base import BaseModel

+ 17 - 1
paddlex/repo_apis/PaddleOCR_api/text_rec/config.py

@@ -12,7 +12,6 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-
 import os
 
 import yaml
@@ -271,6 +270,23 @@ class TextRecConfig(BaseConfig):
     #         'Global.eval_batch_step': [eval_start_step, eval_interval]
     #     })
 
+    def update_log_ranks(self, device):
+        """update log ranks
+
+        Args:
+            device (str): the running device to set
+        """
+        log_ranks = device.split(':')[1]
+        self.update({'Global.log_ranks': log_ranks})
+
+    def enable_print_mem_info(self):
+        """print memory info"""
+        self.update({'Global.print_mem_info': True})
+
+    def disable_print_mem_info(self):
+        """do not print memory info"""
+        self.update({'Global.print_mem_info': False})
+
     def _update_eval_interval_by_epoch(self, eval_interval):
         """update eval interval(by epoch)
 

+ 17 - 1
paddlex/repo_apis/PaddleSeg_api/base_seg_config.py

@@ -12,7 +12,6 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-
 from urllib.parse import urlparse
 
 import yaml
@@ -59,6 +58,23 @@ class BaseSegConfig(BaseConfig):
             raise ValueError(
                 f"Setting `batch_size` in {repr(mode)} mode is not supported.")
 
+    def update_log_ranks(self, device):
+        """update log ranks
+
+        Args:
+            device (str): the running device to set
+        """
+        log_ranks = device.split(':')[1]
+        self.set_val('log_ranks', log_ranks)
+
+    def enable_print_mem_info(self):
+        """print memory info"""
+        self.set_val('print_mem_info', True)
+
+    def disable_print_mem_info(self):
+        """do not print memory info"""
+        self.set_val('print_mem_info', False)
+
     def update_pretrained_weights(self, weight_path, is_backbone=False):
         """ update_pretrained_weights """
         if 'model' not in self:

+ 17 - 1
paddlex/repo_apis/PaddleTS_api/ts_base/config.py

@@ -12,7 +12,6 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-
 import os
 from urllib.parse import urlparse
 
@@ -133,6 +132,23 @@ class BaseTSConfig(BaseConfig):
 
         self.model['pretrain'] = weight_path
 
+    def update_log_ranks(self, device):
+        """update log ranks
+
+        Args:
+            device (str): the running device to set
+        """
+        # PaddleTS does not support multi-device training currently.
+        pass
+
+    def enable_print_mem_info(self):
+        """print memory info"""
+        self.update({'print_mem_info': True})
+
+    def disable_print_mem_info(self):
+        """do not print memory info"""
+        self.update({'print_mem_info': False})
+
     def update_dataset(self, dataset_dir: str, dataset_type: str=None):
         """update dataset settings
         """

+ 3 - 3
requirements.txt

@@ -3,9 +3,9 @@ PyYAML
 filelock
 ruamel.yaml
 chardet
-numpy
-matplotlib
-opencv-python
+numpy==1.24.4
+matplotlib==3.5.2
+opencv-python==4.5.5.64
 pycocotools
 tqdm
 pyclipper