forked from RUCAIBox/RecBole
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_recbole.py
69 lines (61 loc) · 2.03 KB
/
run_recbole.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# @Time : 2020/7/20
# @Author : Shanlei Mu
# @Email : [email protected]
# UPDATE
# @Time : 2022/7/8, 2020/10/3, 2020/10/1
# @Author : Zhen Tian, Yupeng Hou, Zihan Lin
import argparse
from ast import arg
from recbole.quick_start import run_recbole, run_recboles
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--model", "-m", type=str, default="BPR", help="name of models")
parser.add_argument(
"--dataset", "-d", type=str, default="ml-100k", help="name of datasets"
)
parser.add_argument("--config_files", type=str, default=None, help="config files")
parser.add_argument(
"--nproc", type=int, default=1, help="the number of process in this group"
)
parser.add_argument(
"--ip", type=str, default="localhost", help="the ip of master node"
)
parser.add_argument(
"--port", type=str, default="5678", help="the port of master node"
)
parser.add_argument(
"--world_size", type=int, default=-1, help="total number of jobs"
)
parser.add_argument(
"--group_offset",
type=int,
default=0,
help="the global rank offset of this group",
)
args, _ = parser.parse_known_args()
config_file_list = (
args.config_files.strip().split(" ") if args.config_files else None
)
if args.nproc == 1 and args.world_size <= 0:
run_recbole(
model=args.model, dataset=args.dataset, config_file_list=config_file_list
)
else:
if args.world_size == -1:
args.world_size = args.nproc
import torch.multiprocessing as mp
mp.spawn(
run_recboles,
args=(
args.model,
args.dataset,
config_file_list,
args.ip,
args.port,
args.world_size,
args.nproc,
args.group_offset,
),
nprocs=args.nproc,
)