This repository has been archived by the owner on Feb 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathrun_test.py
executable file
·407 lines (364 loc) · 13.9 KB
/
run_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
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
#!/usr/bin/env python
import argparse
import os
import argconfig
import docker
import version
# Simulate the build environment of ReadTheDocs (conda).
# Some packages are omitted as we have our own requirements.
# https://github.com/rtfd/readthedocs.org/blob/a992ad1a2695d6d6f2396f67af2163abac2a22d0/readthedocs/doc_builder/python_environments.py#L418
SPHINX_REQUIREMENTS_CONDA = [
# 'mock',
# 'pillow',
'recommonmark',
'sphinx',
'sphinx-rtd-theme',
]
# Simulate the build environment of ReadTheDocs (pip).
# Some packages are omitted as we have our own requirements.
# https://github.com/rtfd/readthedocs.org/blob/a992ad1a2695d6d6f2396f67af2163abac2a22d0/readthedocs/doc_builder/python_environments.py#L257
SPHINX_REQUIREMENTS_PIP = [
'Pygments==2.3.1',
'docutils==0.14',
# 'mock==1.0.1',
# 'pillow==5.4.1',
'alabaster>=0.7,<0.8,!=0.7.5',
'commonmark==0.8.1',
'recommonmark==0.5.0',
'sphinx<2',
'sphinx-rtd-theme<2',
]
def _get_job_name():
# Returns Jenkins job name. None if the test is not running inside Jenkins.
# e.g., `chainer/cupy_pr/TEST=cupy-py3,label=mn1-p100`
return os.getenv('JOB_NAME')
def main():
parser = argparse.ArgumentParser(
description='Test script for multi-environment')
parser.add_argument('--test', choices=[
'chainer-py3', 'chainer-py35', 'chainer-slow',
'chainer-example', 'chainer-prev_example', 'chainer-doc',
'chainer-head',
'cupy-py3', 'cupy-py36', 'cupy-slow', 'cupy-py3-cub', 'cupy-py3-cutensor',
'cupy-example', 'cupy-doc',
'cupy-head',
], required=True)
parser.add_argument('--no-cache', action='store_true')
parser.add_argument('--timeout', default='3h')
parser.add_argument('-i', '--interactive', action='store_true')
parser.add_argument(
'--clone-cupy', action='store_true',
help='clone cupy repository based on chainer version. '
'this option is used for testing chainer.')
parser.add_argument(
'--clone-chainer', action='store_true',
help='clone chainer repository based on cupy version. '
'this option is used for testing cupy.')
parser.add_argument(
'--env', action='append', default=[],
help='inherit environment variable (like `docker run --env`)')
argconfig.setup_argument_parser(parser)
args = parser.parse_args()
if args.clone_cupy:
version.clone_cupy()
if args.clone_chainer:
version.clone_chainer()
is_cupy_master = version.is_master_branch('cupy')
use_gcc6_or_later = True
ideep_min_version = version.get_ideep_version_from_chainer_docs()
if ideep_min_version is None:
ideep_req = None # could not determine
elif ideep_min_version.startswith('1.'):
ideep_req = '<1.1'
elif ideep_min_version.startswith('2.'):
ideep_req = '<2.1'
else:
raise RuntimeError('bad ideep version: {}'.format(ideep_min_version))
build_chainerx = False
cupy_accelerators = []
if args.test == 'chainer-py3':
conf = {
'base': 'ubuntu18_py38-pyenv',
'cuda': 'cuda101',
'cudnn': 'cudnn76-cuda101',
'nccl': 'nccl2.4-cuda101',
'cutensor': 'none',
'cusparselt': 'none',
'requires': [
# TODO(kmaehashi): Remove setuptools version restrictions
# https://github.com/chainer/chainer-test/issues/565
'setuptools<42', 'pip', 'cython==0.29.22',
'numpy==1.19.*', 'pillow',
],
}
script = './test.sh'
elif args.test == 'chainer-py35':
assert ideep_req is not None
conf = {
'base': 'ubuntu16_py35',
'cuda': 'cuda92',
'cudnn': 'cudnn71-cuda92',
'nccl': 'nccl2.2-cuda92',
'cutensor': 'none',
'cusparselt': 'none',
'requires': [
# TODO(kmaehashi): Remove setuptools version restrictions
# https://github.com/pypa/setuptools/issues/2352
'setuptools<50', 'cython==0.29.22',
'numpy==1.18.*', 'scipy==1.4.*',
'h5py', 'theano', 'protobuf<3',
'ideep4py{}'.format(ideep_req),
],
}
script = './test.sh'
elif args.test == 'chainer-head' or args.test == 'cupy-head':
assert ideep_req is not None
base = 'ubuntu16_py36-pyenv'
if is_cupy_master:
base = 'ubuntu16_py37-pyenv'
conf = {
'base': base,
'cuda': 'cuda101',
'cudnn': 'cudnn76-cuda101',
'nccl': 'nccl2.4-cuda101',
'cutensor': 'none',
'cusparselt': 'none',
'requires': [
# Use '>=0.0.dev0' to install the latest pre-release version
# available on PyPI.
# https://pip.pypa.io/en/stable/reference/pip_install/#pre-release-versions
# TODO(kmaehashi) rewrite iDeep constraints after v2.0 support
'setuptools>=0.0.dev0', 'cython>=0.0.dev0,<3', 'numpy>=0.0.dev0',
'scipy>=0.0.dev0', 'h5py>=0.0.dev0', 'theano>=0.0.dev0',
'protobuf>=0.0.dev0',
'ideep4py>=0.0.dev0, {}'.format(ideep_req),
],
}
if args.test == 'chainer-head':
script = './test.sh'
elif args.test == 'cupy-head':
script = './test_cupy.sh'
else:
assert False # should not reach
elif args.test == 'chainer-slow':
assert ideep_req is not None
conf = {
'base': 'ubuntu16_py35',
'cuda': 'cuda92',
'cudnn': 'cudnn76-cuda92',
'nccl': 'nccl2.4-cuda92',
'cutensor': 'none',
'cusparselt': 'none',
'requires': [
# TODO(kmaehashi): Remove setuptools version restrictions
# https://github.com/pypa/setuptools/issues/2352
'setuptools<50', 'cython==0.29.22',
'numpy==1.18.*', 'scipy==1.4.*',
'scipy<1.1', 'h5py', 'theano', 'protobuf<3', 'pillow',
'ideep4py{}'.format(ideep_req),
],
}
script = './test_slow.sh'
elif args.test == 'chainer-example':
base = 'ubuntu16_py36-pyenv'
conf = {
'base': base,
'cuda': 'cuda102',
'cudnn': 'cudnn76-cuda102',
'nccl': 'nccl2.5-cuda102',
'cutensor': 'none',
'cusparselt': 'none',
'requires': [
# TODO(kmaehashi): Remove setuptools version restrictions
# https://github.com/pypa/setuptools/issues/2352
'setuptools<50', 'cython==0.29.22', 'numpy==1.18.*',
],
}
script = './test_example.sh'
elif args.test == 'chainer-prev_example':
base = 'ubuntu16_py36-pyenv'
conf = {
'base': base,
'cuda': 'cuda92',
'cudnn': 'cudnn72-cuda92',
'nccl': 'none',
'cutensor': 'none',
'cusparselt': 'none',
'requires': [
# TODO(kmaehashi): Remove setuptools version restrictions
# https://github.com/pypa/setuptools/issues/2352
'setuptools<50', 'pip', 'cython==0.29.22', 'numpy==1.18.*',
],
}
script = './test_prev_example.sh'
elif args.test == 'chainer-doc':
# Note that NumPy 1.14 or later is required to run doctest, as
# the document uses new textual representation of arrays introduced in
# NumPy 1.14.
conf = {
'base': 'ubuntu16_py36-pyenv',
'cuda': 'cuda92',
'cudnn': 'cudnn76-cuda92',
'nccl': 'none',
'cutensor': 'none',
'cusparselt': 'none',
'requires': [
# TODO(kmaehashi): Remove setuptools version restrictions
# https://github.com/pypa/setuptools/issues/2352
'pip==9.0.1', 'setuptools<50', 'cython==0.29.22', 'matplotlib',
'numpy==1.18.*', 'scipy==1.4.*', 'theano', 'wheel', 'pytest',
] + SPHINX_REQUIREMENTS_CONDA
}
script = './test_doc.sh'
build_chainerx = True
elif args.test == 'cupy-py3':
requires = ['optuna']
conf = {
'base': 'ubuntu18_py39-pyenv',
'cuda': 'cuda102',
'cudnn': 'cudnn76-cuda102',
'nccl': 'nccl2.5-cuda102',
'cutensor': 'none',
'cusparselt': 'none',
'requires': [
'setuptools<42', 'pip', 'cython==0.29.22',
'numpy==1.21.*', 'scipy==1.7.*',
] + requires,
}
script = './test_cupy.sh'
elif args.test == 'cupy-py3-cutensor':
conf = {
'base': 'ubuntu18_py38-pyenv',
'cuda': 'cuda102',
'cudnn': 'cudnn76-cuda102',
'nccl': 'nccl2.5-cuda102',
'cutensor': 'cutensor1.3-cuda102',
'cusparselt': 'none',
'requires': [
# TODO(kmaehashi): Remove setuptools version restrictions
# https://github.com/chainer/chainer-test/issues/565
'setuptools<42', 'pip', 'cython==0.29.22', 'numpy==1.21.*',
],
}
script = './test_cupy.sh'
cupy_accelerators += ['cutensor']
elif args.test == 'cupy-py3-cub':
conf = {
'base': 'ubuntu18_py38-pyenv',
'cuda': 'cuda102',
'cudnn': 'cudnn76-cuda102',
'nccl': 'nccl2.5-cuda100',
'cutensor': 'none',
'cusparselt': 'none',
'requires': [
# TODO(kmaehashi): Remove setuptools version restrictions
# https://github.com/chainer/chainer-test/issues/565
'setuptools<42', 'pip', 'cython==0.29.22', 'numpy==1.21.*',
],
}
script = './test_cupy.sh'
cupy_accelerators += ['cub']
elif args.test == 'cupy-py36':
numpy_requires = 'numpy==1.17.*'
scipy_requires = 'scipy==1.4.*'
conf = {
'base': 'ubuntu18_py36',
'cuda': 'cuda113',
'cudnn': 'cudnn82-cuda113',
'nccl': 'nccl2.9-cuda113',
'cutensor': 'none',
'cusparselt': 'cusparselt0.1.0-cuda112',
'requires': [
# TODO(kmaehashi): Remove setuptools version restrictions
# https://github.com/pypa/setuptools/issues/2352
'setuptools<50', 'cython==0.29.22',
numpy_requires, scipy_requires,
],
}
script = './test_cupy.sh'
use_gcc6_or_later = True
elif args.test == 'cupy-slow':
numpy_requires = 'numpy==1.18.*'
scipy_requires = 'scipy==1.7.*'
base = 'ubuntu18_py36'
if is_cupy_master:
base = 'ubuntu18_py37-pyenv'
conf = {
'base': base,
'cuda': 'cuda112',
'cudnn': 'cudnn81-cuda112',
'nccl': 'none',
'cutensor': 'none',
'cusparselt': 'none',
'requires': [
# TODO(kmaehashi): Remove setuptools version restrictions
# https://github.com/pypa/setuptools/issues/2352
'setuptools<50', 'cython==0.29.22',
numpy_requires, scipy_requires,
],
}
script = './test_cupy_slow.sh'
elif args.test == 'cupy-example':
conf = {
'base': 'ubuntu18_py38-pyenv',
'cuda': 'cuda102',
'cudnn': 'cudnn76-cuda102',
'nccl': 'nccl2.5-cuda102',
'cutensor': 'cutensor1.2.0-cuda102',
'cusparselt': 'none',
'requires': [
# TODO(kmaehashi): Remove setuptools version restrictions
# https://github.com/pypa/setuptools/issues/2352
'setuptools<50', 'cython==0.29.22',
'numpy==1.19.*', 'scipy==1.6.*',
],
}
script = './test_cupy_example.sh'
elif args.test == 'cupy-doc':
requires = ['optuna<2']
# Note that NumPy 1.14 or later is required to run doctest, as
# the document uses new textual representation of arrays introduced in
# NumPy 1.14.
conf = {
'base': 'ubuntu18_py38-pyenv',
'cuda': 'cuda102',
'cudnn': 'cudnn76-cuda102',
'nccl': 'nccl2.5-cuda100',
'cutensor': 'none',
'cusparselt': 'none',
'requires': [
# TODO(kmaehashi): Remove setuptools version restrictions
# https://github.com/pypa/setuptools/issues/2352
'pip==9.0.1', 'setuptools<50', 'cython==0.29.22',
'numpy==1.21.*', 'scipy==1.7.*', 'wheel==0.36.2'
] + requires + SPHINX_REQUIREMENTS_PIP
}
script = './test_cupy_doc.sh'
else:
raise
use_ideep = any(['ideep4py' in req for req in conf['requires']])
volume = []
env = {
'USE_GCC6_OR_LATER': '1' if use_gcc6_or_later else '0',
'CUDNN': conf['cudnn'],
'IDEEP': 'ideep4py' if use_ideep else 'none',
'CHAINER_BUILD_CHAINERX': '1' if build_chainerx else '0',
'CUPY_ACCELERATORS': ','.join(cupy_accelerators),
}
argconfig.parse_args(args, env, conf, volume)
# inherit specified environment variable
for key in args.env:
env[key] = os.environ[key]
# coverage result is reported when the same type of a test is executed
if args.coverage_repo and args.coverage_repo in args.test:
argconfig.setup_coverage(args, env)
if args.interactive:
docker.run_interactive(
conf, no_cache=args.no_cache, volume=volume, env=env,
use_root=args.root)
else:
docker.run_with(
conf, script, no_cache=args.no_cache, volume=volume, env=env,
timeout=args.timeout, gpu_id=args.gpu_id, use_root=args.root)
if __name__ == '__main__':
main()