-
Notifications
You must be signed in to change notification settings - Fork 58
/
Copy patheval_rl.py
64 lines (50 loc) · 1.99 KB
/
eval_rl.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
import os
USED_DEVICES = "1" # if your want to use CPU in a server with GPU, change "0" to "-1"
os.environ["CUDA_DEVICE_ORDER"] = "PCI_BUS_ID"
os.environ["CUDA_VISIBLE_DEVICES"] = USED_DEVICES
os.environ["CUDA_LAUNCH_BLOCKING"] = "1"
import torch
import numpy as np
import random
seed = 0 # use the fixed seed for the full program
# must use
random.seed(seed)
np.random.seed(seed)
torch.manual_seed(seed)
torch.cuda.manual_seed(seed)
torch.cuda.manual_seed_all(seed) # if you are using multi-GPU.
# optional use
# torch.set_deterministic(True)
# torch.backends.cudnn.enabled = False
# torch.backends.cudnn.benchmark = False
# os.environ['CUBLAS_WORKSPACE_CONFIG'] = ':4096:8'
os.environ['PYTHONHASHSEED'] = str(seed)
import alphastarmini
from alphastarmini.core.arch import entity_encoder
from alphastarmini.core.arch import scalar_encoder
from alphastarmini.core.arch import spatial_encoder
from alphastarmini.core.arch import arch_model
from alphastarmini.core.arch import action_type_head
from alphastarmini.core.arch import selected_units_head
from alphastarmini.core.arch import target_unit_head
from alphastarmini.core.arch import delay_head
from alphastarmini.core.arch import queue_head
from alphastarmini.core.arch import location_head
from alphastarmini.core.arch import agent
from alphastarmini.core.arch import baseline
from alphastarmini.core.sl import load_pickle
from alphastarmini.core.rl import action
from alphastarmini.core.rl import env_utils
from alphastarmini.core.rl import actor
from alphastarmini.core.rl import against_computer
from alphastarmini.core.rl import pseudo_reward
import param as P
if __name__ == '__main__':
# if we don't add this line, it may cause running time error while in Windows
# torch.multiprocessing.freeze_support()
print("run init")
# ------------------------
# 3. we use RL environment to multi-process (thread) evaluate SL model
from alphastarmini.core.rl import mp_rl_eval_rl
mp_rl_eval_rl.test(on_server=P.on_server)
print('run over')