Browse Source

Place control of the pThread into the Summary process

tags/v1.1.0
ougongchang 5 years ago
parent
commit
4f46adf702
1 changed files with 9 additions and 10 deletions
  1. +9
    -10
      mindspore/train/summary/_writer_pool.py

+ 9
- 10
mindspore/train/summary/_writer_pool.py View File

@@ -31,16 +31,6 @@ except ValueError:
import multiprocessing as ctx


# Environment variables are used to specify a maximum number of OpenBLAS threads:
# In ubuntu(GPU) environment, numpy will use too many threads for computing,
# it may affect the start of the summary process.
# Notice: At present, the performance of setting the thread to 2 has been tested to be more suitable.
# If it is to be adjusted, it is recommended to test according to the scenario first
os.environ['OPENBLAS_NUM_THREADS'] = '2'
os.environ['GOTO_NUM_THREADS'] = '2'
os.environ['OMP_NUM_THREADS'] = '2'


def _pack_data(datadict, wall_time):
"""Pack data according to which plugin."""
result, summaries, step = [], [], None
@@ -78,6 +68,15 @@ class WriterPool(ctx.Process):
self.start()

def run(self):
# Environment variables are used to specify a maximum number of OpenBLAS threads:
# In ubuntu(GPU) environment, numpy will use too many threads for computing,
# it may affect the start of the summary process.
# Notice: At present, the performance of setting the thread to 2 has been tested to be more suitable.
# If it is to be adjusted, it is recommended to test according to the scenario first
os.environ['OPENBLAS_NUM_THREADS'] = '2'
os.environ['GOTO_NUM_THREADS'] = '2'
os.environ['OMP_NUM_THREADS'] = '2'

with ctx.Pool(min(ctx.cpu_count(), 32)) as pool:
deq = deque()
while True:


Loading…
Cancel
Save