Skip to content

Commit 140762f

Browse files
author
Han Wang
committed
document the enviromental variables controling multithreading
1 parent 9682111 commit 140762f

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -437,8 +437,6 @@ positional arguments:
437437
438438
optional arguments:
439439
-h, --help show this help message and exit
440-
-t INTER_THREADS, --inter-threads INTER_THREADS
441-
With default value 0. Setting the "inter_op_parallelism_threads" key for the tensorflow, the "intra_op_parallelism_threads" will be set by the env variable OMP_NUM_THREADS
442440
--init-model INIT_MODEL
443441
Initialize a model by the provided checkpoint
444442
--restart RESTART Restart the training from the provided checkpoint
@@ -449,6 +447,15 @@ The keys `intra_op_parallelism_threads` and `inter_op_parallelism_threads` are T
449447

450448
**`--restart model.ckpt`**, continues the training from the checkpoint `model.ckpt`.
451449

450+
On some resources limited machines, one may want to control the number of threads used by DeePMD-kit. This is achieved by three environmental variables: `OMP_NUM_THREADS`, `TF_INTRA_OP_PARALLELISM_THREADS` and `TF_INTER_OP_PARALLELISM_THREADS`. `OMP_NUM_THREADS` controls the multithreading of DeePMD-kit implemented operations. `TF_INTRA_OP_PARALLELISM_THREADS` and `TF_INTER_OP_PARALLELISM_THREADS` controls `intra_op_parallelism_threads` and `inter_op_parallelism_threads`, which are Tensorflow configurations for multithreading. An explanation is found [here](https://stackoverflow.com/questions/41233635/meaning-of-inter-op-parallelism-threads-and-intra-op-parallelism-threads).
451+
452+
For example if you wish to use 3 cores of 2 CPUs on one node, you may set the environmental variables and run DeePMD-kit as follows:
453+
```bash
454+
export OMP_NUM_THREADS=6
455+
export TF_INTRA_OP_PARALLELISM_THREADS=3
456+
export TF_INTER_OP_PARALLELISM_THREADS=2
457+
dp train input.json
458+
```
452459

453460
## Freeze a model
454461

source/train/main.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,6 @@ def main () :
1818
parser_train = subparsers.add_parser('train', help='train a model')
1919
parser_train.add_argument('INPUT',
2020
help='the input parameter file in json format')
21-
parser_train.add_argument('-t','--inter-threads', type = int, default = default_num_inter_threads,
22-
help=
23-
'With default value %d. ' % default_num_inter_threads +
24-
'Setting the "inter_op_parallelism_threads" key for the tensorflow, ' +
25-
'the "intra_op_parallelism_threads" will be set by the env variable OMP_NUM_THREADS')
2621
parser_train.add_argument('--init-model', type = str,
2722
help=
2823
'Initialize the model by the provided checkpoint.')

0 commit comments

Comments
 (0)