forked from cupy/cupy-release-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dist.py
executable file
·743 lines (628 loc) · 27 KB
/
dist.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
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import argparse
import json
import os
import pathlib
import shutil
import subprocess
import sys
import tempfile
import time
from dist_config import (
CYTHON_VERSION,
SDIST_CONFIG,
SDIST_LONG_DESCRIPTION,
WHEEL_LINUX_CONFIGS,
WHEEL_WINDOWS_CONFIGS,
WHEEL_PYTHON_VERSIONS,
WHEEL_LONG_DESCRIPTION,
VERIFY_PYTHON_VERSIONS,
PYTHON_VERSIONS,
) # NOQA
from dist_utils import (
sdist_name,
wheel_name,
get_version_from_source_tree,
get_system_cuda_version,
find_file_in_path,
) # NOQA
def log(msg):
out = sys.stdout
out.write('[{}]: {}\n'.format(time.asctime(), msg))
out.flush()
def run_command(*cmd, **kwargs):
log('Running command: {}'.format(str(cmd)))
subprocess.check_call(cmd, **kwargs)
def run_command_output(*cmd, **kwargs):
log('Running command: {}'.format(str(cmd)))
return subprocess.check_output(cmd, **kwargs)
def extract_nccl_archive(nccl_config, nccl_assets, dest_dir):
# This method uses platform-dependent command because
# NCCL is only supported on Linux.
log('Extracting NCCL assets from {} to {}'.format(nccl_assets, dest_dir))
asset_type = nccl_config['type']
if asset_type == 'v1-deb':
for nccl_deb in nccl_config['files']:
run_command(
'dpkg', '-x',
'{}/{}'.format(nccl_assets, nccl_deb),
dest_dir,
)
# Adjust paths to align with tarball.
shutil.move(
'{}/usr/lib/x86_64-linux-gnu'.format(dest_dir),
'{}/lib'.format(dest_dir)
)
shutil.move(
'{}/usr/include'.format(dest_dir),
'{}/include'.format(dest_dir)
)
elif asset_type == 'v2-tar':
for nccl_tar in nccl_config['files']:
run_command(
'tar', '-x',
'-f', '{}/{}'.format(nccl_assets, nccl_tar),
'-C', dest_dir, '--strip', '1',
)
else:
raise RuntimeError('unknown NCCL asset type: {}'.format(asset_type))
def get_cudnn_record(cuda_version, platform):
log('Retrieving cuDNN records for CUDA {} ({})'.format(
cuda_version, platform))
command = [
sys.executable,
'cupy/cupyx/tools/install_library.py',
'--library', 'cudnn',
'--cuda', cuda_version,
'--action', 'dump',
]
cudnn_records = json.loads(run_command_output(*command).decode('utf-8'))
for record in cudnn_records:
if record['cuda'] == cuda_version:
return record['cudnn'], record['assets'][platform]
raise RuntimeError(
'CUDA {} not supported by install_library tool'.format(
cuda_version))
def download_extract_cudnn_archive(url, dest_dir):
with tempfile.TemporaryDirectory() as tmpdir:
filepath = os.path.join(tmpdir, os.path.basename(url))
log('Downloading {} to {}...'.format(url, filepath))
run_command('curl', '-L', '-o', filepath, url)
log('Extracting...')
shutil.unpack_archive(filepath, tmpdir)
log('Moving to the destination directory...')
shutil.move(os.path.join(tmpdir, 'cuda'), dest_dir)
log('Cleaning up...')
def install_cudnn_windows(cudnn_workdir, cuda_path):
"""Install the extracted cuDNN to $CUDA_PATH."""
cudnn_workdir = pathlib.Path(cudnn_workdir)
cuda_path = pathlib.Path(cuda_path)
log('Installing cuDNN from {} to {}'.format(cudnn_workdir, cuda_path))
for srcpath, _, files in os.walk(cudnn_workdir):
srcpath = pathlib.Path(srcpath)
destpath = cuda_path / srcpath.relative_to(cudnn_workdir)
if not destpath.exists():
destpath.mkdir()
for f in files:
srcfile = srcpath / f
destfile = destpath / f
log('Copying: {} <- {}'.format(destfile, srcfile))
shutil.copy2(srcfile, destfile)
class Controller(object):
def parse_args(self):
parser = argparse.ArgumentParser()
parser.add_argument(
'--action', choices=['build', 'verify'], required=True,
help='action to perform')
# Common options:
parser.add_argument(
'--target', choices=['sdist', 'wheel-linux', 'wheel-win'],
required=True,
help='build target')
parser.add_argument(
'--nccl-assets', type=str,
help='path to the directory containing NCCL distributions')
parser.add_argument(
'--cuda', type=str,
help='CUDA version for the wheel distribution')
parser.add_argument(
'--python', type=str, choices=PYTHON_VERSIONS, required=True,
help='python version')
# Build mode options:
parser.add_argument(
'--source', type=str,
help='[build] path to the CuPy source tree; '
'must be a clean checkout')
parser.add_argument(
'--output', type=str, default='.',
help='[build] path to the directory to place '
'the built distribution')
# Verify mode options:
parser.add_argument(
'--dist', type=str,
help='[verify] path to the CuPy distribution (sdist or wheel)')
parser.add_argument(
'--test', type=str, action='append', default=[],
help='[verify] path to the directory containing CuPy unit tests '
'(can be specified for multiple times)')
args = parser.parse_args()
if args.action == 'build':
assert args.source
assert args.output
elif args.action == 'verify':
assert args.dist
assert args.test
return args
def main(self):
args = self.parse_args()
if args.action == 'build':
if args.target == 'wheel-win':
self.build_windows(
args.target, args.nccl_assets, args.cuda, args.python,
args.source, args.output)
else:
self.build_linux(
args.target, args.nccl_assets, args.cuda, args.python,
args.source, args.output)
elif args.action == 'verify':
if args.target == 'wheel-win':
self.verify_windows(
args.target, args.nccl_assets, args.cuda, args.python,
args.dist, args.test)
else:
self.verify_linux(
args.target, args.nccl_assets, args.cuda, args.python,
args.dist, args.test)
def _create_builder_linux(self, image_tag, base_image, docker_ctx):
"""Create a docker image to build distributions."""
python_versions = ' '.join(PYTHON_VERSIONS)
log('Building Docker image: {}'.format(image_tag))
run_command(
'docker', 'build',
'--tag', image_tag,
'--build-arg', 'base_image={}'.format(base_image),
'--build-arg', 'python_versions={}'.format(python_versions),
'--build-arg', 'cython_version={}'.format(CYTHON_VERSION),
docker_ctx,
)
def _create_verifier_linux(self, image_tag, base_image, docker_ctx):
"""Create a docker image to verify distributions."""
# Choose Dockerfile template
if 'rhel' in base_image or 'centos' in base_image:
log('Using RHEL Dockerfile template')
template = 'rhel'
elif 'ubuntu' in base_image or 'rocm' in base_image:
log('Using Debian Dockerfile template')
template = 'debian'
else:
raise RuntimeError(
'cannot detect OS from image name: {}'.format(base_image))
shutil.copy2(
'{}/Dockerfile.{}'.format(docker_ctx, template),
'{}/Dockerfile'.format(docker_ctx))
python_versions = ' '.join(VERIFY_PYTHON_VERSIONS)
log('Building Docker image: {}'.format(image_tag))
run_command(
'docker', 'build',
'--tag', image_tag,
'--build-arg', 'base_image={}'.format(base_image),
'--build-arg', 'python_versions={}'.format(python_versions),
docker_ctx,
)
def _run_container(self, image_tag, kind, workdir, agent_args):
log('Running docker container with image: {} ({})'.format(
image_tag, kind))
if kind == 'cuda':
docker_run = ['nvidia-docker', 'run']
elif kind == 'rocm':
docker_run = [
'docker', 'run',
'--device=/dev/kfd', '--device=/dev/dri',
'--security-opt', 'seccomp=unconfined',
'--group-add', 'video',
'--env', 'HCC_AMDGPU_TARGET',
]
else:
assert False
command = docker_run + [
'--rm',
'--volume', '{}:/work'.format(workdir),
'--workdir', '/work',
image_tag,
] + agent_args
run_command(*command)
def build_linux(
self, target, nccl_assets, cuda_version, python_version,
source, output):
"""Build a single wheel distribution for Linux."""
version = get_version_from_source_tree(source)
if target == 'wheel-linux':
assert cuda_version is not None
log(
'Starting wheel-linux build from {} '
'(version {}, for CUDA {} + Python {})'.format(
source, version, cuda_version, python_version))
action = 'bdist_wheel'
image_tag = 'cupy-builder-{}'.format(cuda_version)
kind = WHEEL_LINUX_CONFIGS[cuda_version]['kind']
base_image = WHEEL_LINUX_CONFIGS[cuda_version]['image']
package_name = WHEEL_LINUX_CONFIGS[cuda_version]['name']
long_description = WHEEL_LONG_DESCRIPTION.format(cuda=cuda_version)
if kind == 'cuda':
# NCCL
nccl_config = WHEEL_LINUX_CONFIGS[cuda_version]['nccl']
# cuDNN
cudnn_version, cudnn_assets = get_cudnn_record(
cuda_version, 'Linux')
elif kind == 'rocm':
nccl_config = None
cudnn_version = None
cudnn_assets = None
else:
assert False
# Rename wheels to manylinux1.
asset_name = wheel_name(
package_name, version, python_version, 'linux_x86_64')
asset_dest_name = wheel_name(
package_name, version, python_version, 'manylinux1_x86_64')
elif target == 'sdist':
assert cuda_version is None
log('Starting sdist build from {} (version {})'.format(
source, version))
action = 'sdist'
image_tag = 'cupy-builder-sdist'
kind = 'cuda'
base_image = SDIST_CONFIG['image']
package_name = 'cupy'
long_description = SDIST_LONG_DESCRIPTION
# NCCL
nccl_config = None
# cuDNN (use pre-installed version)
cudnn_version = None
cudnn_assets = None
# Rename not needed for sdist.
asset_name = sdist_name('cupy', version)
asset_dest_name = asset_name
else:
raise RuntimeError('unknown target')
# Arguments for the agent.
agent_args = [
'--action', action,
'--source', 'cupy',
'--python', python_version,
'--chown', '{}:{}'.format(os.getuid(), os.getgid()),
]
# Add arguments to pass to setup.py.
setup_args = [
'--cupy-package-name', package_name,
'--cupy-long-description', '../description.rst',
]
if target == 'wheel-linux':
# Add requirements for build.
for req in WHEEL_PYTHON_VERSIONS[python_version]['requires']:
agent_args += ['--requires', req]
setup_args += [
'--cupy-no-rpath',
'--cupy-wheel-metadata', '../_wheel.json',
]
for lib in WHEEL_LINUX_CONFIGS[cuda_version]['libs']:
setup_args += ['--cupy-wheel-lib', lib]
for include_path, include_relpath in (
WHEEL_LINUX_CONFIGS[cuda_version]['includes']):
spec = '{}:{}'.format(include_path, include_relpath)
setup_args += ['--cupy-wheel-include', spec]
elif target == 'sdist':
setup_args += [
'--cupy-no-cuda',
]
agent_args += setup_args
# Create a working directory.
workdir = tempfile.mkdtemp(prefix='cupy-dist-')
try:
log('Using working directory: {}'.format(workdir))
# Copy source tree to working directory.
log('Copying source tree from: {}'.format(source))
shutil.copytree(source, '{}/cupy'.format(workdir))
# Add long description file.
with open('{}/description.rst'.format(workdir), 'w') as f:
f.write(long_description)
# Copy builder directory to working directory.
docker_ctx = '{}/builder'.format(workdir)
log('Copying builder directory to: {}'.format(docker_ctx))
shutil.copytree('builder/', docker_ctx)
# Extract NCCL archive.
log('Creating nccl directory under builder directory')
nccl_workdir = '{}/nccl'.format(docker_ctx)
os.mkdir(nccl_workdir)
if nccl_config is not None:
log('Extracting NCCL archive')
extract_nccl_archive(nccl_config, nccl_assets, nccl_workdir)
else:
log('NCCL is not installed for this build')
# Extract cuDNN archive.
cudnn_workdir = '{}/cudnn'.format(docker_ctx)
os.mkdir(cudnn_workdir)
if cudnn_version is not None:
log('cuDNN version: {}'.format(cudnn_version))
log('cuDNN assets: {}'.format(cudnn_assets))
log('Creating cudnn directory under builder directory')
download_extract_cudnn_archive(
cudnn_assets['url'], cudnn_workdir)
else:
log('cuDNN is not installed for this build')
# Create a wheel metadata file for preload.
if target == 'wheel-linux':
log('Writing wheel metadata')
wheel_metadata = {
'cuda': cuda_version,
}
if cudnn_version is not None:
wheel_metadata['cudnn'] = {
'version': cudnn_version,
'filename': cudnn_assets['filename'],
}
with open('{}/_wheel.json'.format(workdir), 'w') as f:
json.dump(wheel_metadata, f)
# Creates a Docker image to build distribution.
self._create_builder_linux(image_tag, base_image, docker_ctx)
# Build.
log('Starting build')
self._run_container(image_tag, kind, workdir, agent_args)
log('Finished build')
# Copy assets.
asset_path = '{}/cupy/dist/{}'.format(workdir, asset_name)
output_path = '{}/{}'.format(output, asset_dest_name)
log('Copying asset from {} to {}'.format(asset_path, output_path))
shutil.copy2(asset_path, output_path)
finally:
log('Removing working directory: {}'.format(workdir))
shutil.rmtree(workdir)
def _check_windows_environment(self, cuda_version, python_version):
# Check if this script is running on Windows.
if not sys.platform.startswith('win32'):
raise RuntimeError(
'you are on non-Windows system: {}'.format(sys.platform))
# Check Python version.
current_python_version = '.'.join(map(str, sys.version_info[0:3]))
if python_version != current_python_version:
log('Note: Building wheel for Python {} using Python {}'.format(
python_version, current_python_version))
# Check CUDA runtime version.
config = WHEEL_WINDOWS_CONFIGS[cuda_version]
cuda_check_version = config['check_version']
current_cuda_version = get_system_cuda_version(config['cudart_lib'])
if current_cuda_version is None:
raise RuntimeError(
'Cannot build wheel without CUDA Runtime installed')
elif not cuda_check_version(current_cuda_version):
raise RuntimeError(
'Cannot build wheel for CUDA {} using CUDA {}'.format(
cuda_version, current_cuda_version))
def build_windows(
self, target, nccl_assets, cuda_version, python_version,
source, output):
"""Build a single wheel distribution for Windows.
Note that Windows build is not isolated.
"""
# Perform additional check as Windows environment is not isoalted.
self._check_windows_environment(cuda_version, python_version)
if target != 'wheel-win':
raise ValueError('unknown target')
if nccl_assets is not None:
raise RuntimeError('NCCL not supported on Windows')
version = get_version_from_source_tree(source)
log(
'Starting wheel-win build from {} '
'(version {}, for CUDA {} + Python {})'.format(
source, version, cuda_version, python_version))
action = 'bdist_wheel'
package_name = WHEEL_WINDOWS_CONFIGS[cuda_version]['name']
long_description = WHEEL_LONG_DESCRIPTION.format(cuda=cuda_version)
asset_name = wheel_name(
package_name, version, python_version, 'win_amd64')
asset_dest_name = asset_name
agent_args = [
'--action', action,
'--source', 'cupy',
]
# Add requirements for build.
for req in WHEEL_PYTHON_VERSIONS[python_version]['requires']:
agent_args += ['--requires', req]
# Add arguments to pass to setup.py.
setup_args = [
'--cupy-package-name', package_name,
'--cupy-long-description', '../description.rst',
]
setup_args += ['--cupy-wheel-metadata', '../_wheel.json']
for lib in WHEEL_WINDOWS_CONFIGS[cuda_version]['libs']:
libpath = find_file_in_path(lib)
if libpath is None:
raise RuntimeError(
'Library {} could not be found in PATH'.format(lib))
setup_args += ['--cupy-wheel-lib', libpath]
agent_args += setup_args
# Create a working directory.
workdir = tempfile.mkdtemp(prefix='cupy-dist-')
try:
log('Using working directory: {}'.format(workdir))
# Copy source tree and NCCL to working directory.
log('Copying source tree from: {}'.format(source))
shutil.copytree(source, '{}/cupy'.format(workdir))
# Add long description file.
with open('{}/description.rst'.format(workdir), 'w') as f:
f.write(long_description)
# Get cuDNN version.
cudnn_version, cudnn_assets = get_cudnn_record(
cuda_version, 'Windows')
log('cuDNN version: {}'.format(cudnn_version))
log('cuDNN assets: {}'.format(cudnn_assets))
# Extract cuDNN archive.
log('Creating cudnn directory under work directory')
cudnn_workdir = '{}/cudnn'.format(workdir)
download_extract_cudnn_archive(
cudnn_assets['url'], cudnn_workdir)
cuda_path = os.environ['CUDA_PATH']
log('Installing cuDNN to {}'.format(cuda_path))
install_cudnn_windows(cudnn_workdir, cuda_path)
# Create a wheel metadata file for preload.
log('Writing wheel metadata')
wheel_metadata = {
'cuda': cuda_version,
'cudnn': {
'version': cudnn_version,
'filename': cudnn_assets['filename'],
}
}
with open('{}/_wheel.json'.format(workdir), 'w') as f:
json.dump(wheel_metadata, f)
# Build.
log('Starting build')
run_command(
sys.executable, '{}/builder/agent.py'.format(os.getcwd()),
*agent_args, cwd=workdir)
log('Finished build')
# Copy assets.
asset_path = '{}/cupy/dist/{}'.format(workdir, asset_name)
output_path = '{}/{}'.format(output, asset_dest_name)
log('Copying asset from {} to {}'.format(asset_path, output_path))
shutil.copy2(asset_path, output_path)
finally:
log('Removing working directory: {}'.format(workdir))
try:
shutil.rmtree(workdir)
except OSError as e:
# TODO(kmaehashi): On Windows, removal of `.git` directory may
# fail with PermissionError (on Python 3) or OSError (on
# Python 2). Note that PermissionError inherits OSError.
log('Failed to clean-up working directory: {}\n\n'
'Please remove the working directory manually: {}'.format(
e, workdir))
def verify_linux(
self, target, nccl_assets, cuda_version, python_version,
dist, tests):
"""Verify a single distribution for Linux."""
if target == 'sdist':
assert cuda_version is None
image_tag = 'cupy-verifier-sdist'
kind = 'cuda'
base_image = SDIST_CONFIG['verify_image']
systems = SDIST_CONFIG['verify_systems']
preloads = SDIST_CONFIG['verify_preloads']
nccl_config = SDIST_CONFIG['nccl']
assert len(preloads) == 0
elif target == 'wheel-linux':
assert cuda_version is not None
image_tag = 'cupy-verifier-wheel-linux-{}'.format(cuda_version)
kind = WHEEL_LINUX_CONFIGS[cuda_version]['kind']
base_image = WHEEL_LINUX_CONFIGS[cuda_version]['verify_image']
systems = WHEEL_LINUX_CONFIGS[cuda_version]['verify_systems']
preloads = WHEEL_LINUX_CONFIGS[cuda_version]['verify_preloads']
nccl_config = None
else:
raise RuntimeError('unknown target')
for system in systems:
image = base_image.format(system=system)
image_tag_system = '{}-{}'.format(image_tag, system)
log('Starting verification for {} on {} with Python {}'.format(
dist, image, python_version))
self._verify_linux(
image_tag_system, image, kind, dist, tests,
python_version, nccl_assets, nccl_config,
cuda_version, preloads)
def _verify_linux(
self, image_tag, base_image, kind, dist, tests, python_version,
nccl_assets, nccl_config, cuda_version, preloads):
dist_basename = os.path.basename(dist)
# Arguments for the agent.
agent_args = [
'--python', python_version,
'--dist', dist_basename,
'--chown', '{}:{}'.format(os.getuid(), os.getgid()),
]
if 0 < len(preloads):
agent_args += ['--cuda', cuda_version]
for p in preloads:
agent_args += ['--preload', p]
# Add arguments for `python -m pytest`.
agent_args += ['tests']
# Create a working directory.
workdir = tempfile.mkdtemp(prefix='cupy-dist-')
try:
log('Using working directory: {}'.format(workdir))
# Copy dist and tests to working directory.
log('Copying distribution from: {}'.format(dist))
shutil.copy2(dist, '{}/{}'.format(workdir, dist_basename))
tests_dir = '{}/tests'.format(workdir)
os.mkdir(tests_dir)
for test in tests:
log('Copying tests from: {}'.format(test))
shutil.copytree(
test,
'{}/{}'.format(tests_dir, os.path.basename(test)))
# Copy verifier directory to working directory.
docker_ctx = '{}/verifier'.format(workdir)
log('Copying verifier directory to: {}'.format(docker_ctx))
shutil.copytree('verifier/', docker_ctx)
# Extract NCCL archive.
log('Creating nccl directory under verifier directory')
nccl_workdir = '{}/nccl'.format(docker_ctx)
os.mkdir(nccl_workdir)
if nccl_config:
log('Extracting NCCL archive')
extract_nccl_archive(nccl_config, nccl_assets, nccl_workdir)
else:
log('NCCL is not installed for this verification')
# Creates a Docker image to verify specified distribution.
self._create_verifier_linux(image_tag, base_image, docker_ctx)
# Verify.
log('Starting verification')
self._run_container(image_tag, kind, workdir, agent_args)
log('Finished verification')
finally:
log('Removing working directory: {}'.format(workdir))
shutil.rmtree(workdir)
def verify_windows(
self, target, nccl_assets, cuda_version, python_version,
dist, tests):
"""Verify a single distribution for Windows."""
# Perform additional check as Windows environment is not isoalted.
self._check_windows_environment(cuda_version, python_version)
if target != 'wheel-win':
raise ValueError('unknown target')
if nccl_assets is not None:
raise RuntimeError('NCCL not supported on Windows')
log('Starting verification for {} with Python {}'.format(
dist, python_version))
dist_basename = os.path.basename(dist)
# Arguments for the agent.
agent_args = [
'--dist', dist,
]
# Add arguments for `python -m pytest`.
agent_args += ['tests']
# Create a working directory.
workdir = tempfile.mkdtemp(prefix='cupy-dist-')
try:
log('Using working directory: {}'.format(workdir))
# Copy dist and tests to working directory.
log('Copying distribution from: {}'.format(dist))
shutil.copy2(dist, '{}/{}'.format(workdir, dist_basename))
tests_dir = '{}/tests'.format(workdir)
os.mkdir(tests_dir)
for test in tests:
log('Copying tests from: {}'.format(test))
shutil.copytree(
test,
'{}/{}'.format(tests_dir, os.path.basename(test)))
# Verify.
log('Starting verification')
run_command(
sys.executable, '{}/verifier/agent.py'.format(os.getcwd()),
*agent_args, cwd=workdir)
log('Finished verification')
finally:
log('Removing working directory: {}'.format(workdir))
shutil.rmtree(workdir)
if __name__ == '__main__':
Controller().main()