Skip to content

Commit

Permalink
[Enhancement] Set Num thread to 0 (#36)
Browse files Browse the repository at this point in the history
* [Docs] update batch size

* [Enhancement] Set Num thread to 0

* set omp mkl threads numbers

* set cls omp mkl threads numbers

* add comments
  • Loading branch information
linyq17 committed Jan 27, 2022
1 parent 555a348 commit 66d92a5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ line_length = 79
multi_line_output = 0
known_standard_library = setuptools
known_first_party = mmfewshot
known_third_party = mmcls,mmcv,mmdet,numpy,pytest,pytorch_sphinx_theme,terminaltables,torch,typing_extensions
known_third_party = cv2,mmcls,mmcv,mmdet,numpy,pytest,pytorch_sphinx_theme,terminaltables,torch,typing_extensions

no_lines_before = STDLIB,LOCALFOLDER
default_section = THIRDPARTY
Expand Down
6 changes: 6 additions & 0 deletions tools/classification/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import os.path as osp
import time

import cv2
import mmcv
import torch
from mmcls import __version__
Expand All @@ -17,6 +18,11 @@
from mmfewshot.classification.datasets import build_dataset
from mmfewshot.utils import get_root_logger

# disable multithreading to avoid system being overloaded
cv2.setNumThreads(0)
os.environ['OMP_NUM_THREADS'] = '1'
os.environ['MKL_NUM_THREADS'] = '1'


def parse_args():
parser = argparse.ArgumentParser(description='Train a model')
Expand Down
6 changes: 6 additions & 0 deletions tools/detection/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import time
import warnings

import cv2
import mmcv
import torch
from mmcv import Config, DictAction
Expand All @@ -20,6 +21,11 @@
from mmfewshot.detection.models import build_detector
from mmfewshot.utils import get_root_logger

# disable multithreading to avoid system being overloaded
cv2.setNumThreads(0)
os.environ['OMP_NUM_THREADS'] = '1'
os.environ['MKL_NUM_THREADS'] = '1'


def parse_args():
parser = argparse.ArgumentParser(description='Train a FewShot model')
Expand Down

0 comments on commit 66d92a5

Please sign in to comment.