Skip to content

Commit 6ea965b

Browse files
author
Han Wang
committed
fix issue of ncpu may be None
1 parent 249627a commit 6ea965b

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

deepmd/pt/utils/env.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
# only linux
3535
ncpus = len(os.sched_getaffinity(0))
3636
except AttributeError:
37-
ncpus = os.cpu_count()
37+
ncpus = os.cpu_count() or 1
3838
NUM_WORKERS = int(os.environ.get("NUM_WORKERS", min(4, ncpus)))
3939
if multiprocessing.get_start_method() != "fork":
4040
# spawn or forkserver does not support NUM_WORKERS > 0 for DataLoader

deepmd/pt_expt/utils/env.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
# only linux
3535
ncpus = len(os.sched_getaffinity(0))
3636
except AttributeError:
37-
ncpus = os.cpu_count()
37+
ncpus = os.cpu_count() or 1
3838
NUM_WORKERS = int(os.environ.get("NUM_WORKERS", min(4, ncpus)))
3939
if multiprocessing.get_start_method() != "fork":
4040
# spawn or forkserver does not support NUM_WORKERS > 0 for DataLoader

0 commit comments

Comments
 (0)