MCPcopy Create free account
hub / github.com/pytorch/pytorch / initialize

Method initialize

torch/_inductor/autotune_process.py:140–163  ·  view source on GitHub ↗

Create child process, request/response queues, and do the warm up. Set the environment to make only the provided GPU device visible to the process.

(self)

Source from the content-addressed store, hash-verified

138 self.process = self.request_queue = self.response_queue = None
139
140 def initialize(self) -> None:
141 """
142 Create child process, request/response queues, and do the warm up.
143 Set the environment to make only the provided GPU device visible
144 to the process.
145 """
146 if self.valid():
147 return
148
149 # cuda runtime does not work with "fork", use "spawn" to start processes.
150 ctx = multiprocessing.get_context("spawn")
151 self.request_queue = ctx.Queue()
152 self.response_queue = ctx.Queue()
153
154 self.process = ctx.Process(
155 target=self.process_main,
156 args=(
157 self.request_queue,
158 self.response_queue,
159 ),
160 )
161 assert self.process is not None
162 with set_cuda_visible_device(self.device):
163 self.process.start()
164
165 def put(self, obj: Any) -> None:
166 """

Callers 7

putMethod · 0.95
initializeMethod · 0.95
__call__Method · 0.45
test_initializeMethod · 0.45
test_initialize_errorMethod · 0.45
test_apex_o2Method · 0.45

Calls 4

validMethod · 0.95
set_cuda_visible_deviceFunction · 0.85
get_contextMethod · 0.80
startMethod · 0.45

Tested by 3

test_initializeMethod · 0.36
test_initialize_errorMethod · 0.36
test_apex_o2Method · 0.36