33
33
sys .path .insert (0 , os .path .abspath ('./.jenkins' ))
34
34
import pytorch_sphinx_theme
35
35
import torch
36
- import numpy
37
- import gc
38
36
import glob
39
37
import random
40
38
import shutil
52
50
import sphinx_gallery .gen_rst
53
51
import multiprocessing
54
52
55
- # Monkey patching sphinx gallery to run each example in an isolated process so
56
- # that we don't need to worry about examples changing global state
53
+ # Monkey patch sphinx gallery to run each example in an isolated process so that
54
+ # we don't need to worry about examples changing global state.
55
+ #
56
+ # Other option 1: Parallelism was added to sphinx gallery (a later version that
57
+ # we are not using yet) using joblib, but it seems to result in errors for us,
58
+ # and it has no effect if you set parallel = 1 (it will not put each file run
59
+ # into its own process and run singly) so you need parallel >= 2, and there may
60
+ # be tutorials that cannot be run in parallel.
61
+ #
62
+ # Other option 2: Run sphinx gallery once per file (similar to how we shard in
63
+ # CI but with shard sizes of 1), but running sphinx gallery for each file has a
64
+ # ~5min overhead, resulting in the entire suite taking ~2x time
57
65
def call_fn (func , args , kwargs , result_queue ):
58
66
try :
59
67
result = func (* args , ** kwargs )
@@ -77,7 +85,6 @@ def wrapper(*args, **kwargs):
77
85
raise RuntimeError (f"Error in subprocess: { result } " )
78
86
return wrapper
79
87
80
- # Monkey-patch
81
88
sphinx_gallery .gen_rst .generate_file_rst = call_in_subprocess (sphinx_gallery .gen_rst .generate_file_rst )
82
89
83
90
try :
@@ -128,21 +135,6 @@ def wrapper(*args, **kwargs):
128
135
129
136
# -- Sphinx-gallery configuration --------------------------------------------
130
137
131
- def reset_seeds (gallery_conf , fname ):
132
- pass
133
- # torch.cuda.empty_cache()
134
- # torch.backends.cudnn.deterministic = True
135
- # torch.backends.cudnn.benchmark = False
136
- # torch._dynamo.reset()
137
- # torch._inductor.config.force_disable_caches = True
138
- # torch.manual_seed(42)
139
- # torch.set_default_device(None)
140
- # random.seed(10)
141
- # numpy.random.seed(10)
142
- # torch.set_grad_enabled(True)
143
-
144
- # gc.collect()
145
-
146
138
sphinx_gallery_conf = {
147
139
'examples_dirs' : ['beginner_source' , 'intermediate_source' ,
148
140
'advanced_source' , 'recipes_source' , 'prototype_source' ],
0 commit comments