@@ -68,15 +68,21 @@ def set_env_if_empty(key: str, value: str, verbose: bool = True) -> None:
6868 )
6969
7070
71- def set_default_nthreads () -> None :
71+ def set_default_nthreads (use_cpu : bool = False ) -> None :
7272 """Set internal number of threads to default=automatic selection.
7373
74+ Parameters
75+ ----------
76+ use_cpu : bool, optional
77+ If ``True``, suppress warnings about thread configuration,
78+ by default ``False``.
79+
7480 Notes
7581 -----
7682 `DP_INTRA_OP_PARALLELISM_THREADS` and `DP_INTER_OP_PARALLELISM_THREADS`
7783 control configuration of multithreading.
7884 """
79- if (
85+ if not use_cpu and (
8086 "OMP_NUM_THREADS" not in os .environ
8187 # for backward compatibility
8288 or (
@@ -89,10 +95,10 @@ def set_default_nthreads() -> None:
8995 )
9096 ):
9197 log .warning (
92- "To get the best performance, it is recommended to adjust "
93- "the number of threads by setting the environment variables "
94- "OMP_NUM_THREADS, DP_INTRA_OP_PARALLELISM_THREADS, and "
95- "DP_INTER_OP_PARALLELISM_THREADS . See "
98+ "To get the best CPU performance, adjust the number of threads by "
99+ "setting the environment variables OMP_NUM_THREADS, "
100+ "DP_INTRA_OP_PARALLELISM_THREADS, and DP_INTER_OP_PARALLELISM_THREADS. "
101+ "These variables are only effective when running on CPU . See "
96102 "https://deepmd.rtfd.io/parallelism/ for more information."
97103 )
98104 if "TF_INTRA_OP_PARALLELISM_THREADS" not in os .environ :
0 commit comments