Skip to content

Commit ad81c5a

Browse files
committed
change default TF_NUM_THREADS to '0', i.e. use all available CPU resources
1 parent 735e0e0 commit ad81c5a

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

batchglm/pkg_constants.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import os
2+
import multiprocessing
23

34
import tensorflow as tf
45

5-
TF_NUM_THREADS = int(os.environ.get('TF_NUM_THREADS', 1))
6+
TF_NUM_THREADS = int(os.environ.get('TF_NUM_THREADS', 0))
67
TF_LOOP_PARALLEL_ITERATIONS = int(os.environ.get('TF_LOOP_PARALLEL_ITERATIONS', 10))
78

89
XARRAY_NETCDF_ENGINE = "h5netcdf"
@@ -14,3 +15,6 @@
1415

1516
TF_CONFIG_PROTO.inter_op_parallelism_threads = 0 if TF_NUM_THREADS == 0 else 1
1617
TF_CONFIG_PROTO.intra_op_parallelism_threads = TF_NUM_THREADS
18+
19+
if TF_NUM_THREADS == 0:
20+
TF_NUM_THREADS = multiprocessing.cpu_count()

0 commit comments

Comments
 (0)