-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.py
34 lines (27 loc) · 927 Bytes
/
test.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
import os
import torch
import hydra
from omegaconf import OmegaConf
from importlib import import_module
# config: infwide_test
@hydra.main(config_path='conf', config_name='infwide_test')
def main(config):
# GPU setting
if not config.gpus or config.gpus == -1:
gpus = list(range(torch.cuda.device_count()))
else:
gpus = config.gpus
os.environ["CUDA_VISIBLE_DEVICES"] = ','.join(map(str, gpus))
n_gpu = len(gpus)
assert n_gpu <= torch.cuda.device_count(
), 'Can\'t find %d GPU device on this machine.' % (n_gpu)
# show config
config_v = OmegaConf.to_yaml(config, resolve=True)
print('='*40+'\n', config_v, '\n'+'='*40+'\n')
# testing
tester_name = 'srcs.tester.%s' % config.tester_name
testing_module = import_module(tester_name)
testing_module.testing(gpus, config)
if __name__ == '__main__':
# pylint: disable=no-value-for-parameter
main()