Skip to content

Commit 5749a52

Browse files
authored
Merge pull request #31 from numericalEFT/cyfan
add multicpu test
2 parents 552633c + 072901e commit 5749a52

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

.github/workflows/CI.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ jobs:
2323
os:
2424
- ubuntu-latest
2525
arch:
26-
- x64
2726
- x86
27+
- x64
2828

2929
steps:
3030
- uses: actions/checkout@v2
@@ -43,6 +43,11 @@ jobs:
4343
4444
- name: Run tests
4545
run: |
46+
export RANK=0
47+
export LOCAL_RANK=0
48+
export WORLD_SIZE=1
49+
export MASTER_ADDR=localhost
50+
export MASTER_PORT=12345
4651
export PYTHONPATH=MCintegration
4752
pytest --cov --cov-report=xml --ignore=examples
4853

examples/mc_multicpu_test.py renamed to MCintegration/mc_multicpu_test.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
import torch.distributed as dist
33
import torch.multiprocessing as mp
44
import os
5-
import MCintegration
6-
from MCintegration import MonteCarlo, MarkovChainMonteCarlo
5+
from integrators import MonteCarlo, MarkovChainMonteCarlo
76

87

98
def init_process(rank, world_size, fn, backend="gloo"):
@@ -53,7 +52,6 @@ def two_integrands(x, f):
5352
# Only rank 0 prints the result
5453
print("MarkovChainMonteCarlo Result:", mcmc_result)
5554

56-
57-
if __name__ == "__main__":
55+
def test_mcmc():
5856
world_size = 8 # Number of processes to launch
5957
mp.spawn(init_process, args=(world_size, run_mcmc), nprocs=world_size, join=True)

examples/mc_multigpu_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
)
1111

1212

13-
backend = "nccl"
14-
# backend = "gloo"
13+
# backend = "nccl"
14+
backend = "gloo"
1515
# set_seed(42)
1616
setup(backend=backend)
1717
device = get_device()

0 commit comments

Comments
 (0)