MCPcopy Create free account
hub / github.com/PaddlePaddle/FastDeploy / init_device

Method init_device

fastdeploy/worker/iluvatar_worker.py:51–74  ·  view source on GitHub ↗

Initialize device and construct model runner

(self)

Source from the content-addressed store, hash-verified

49 )
50
51 def init_device(self):
52 """
53 Initialize device and construct model runner
54 """
55 if paddle.is_compiled_with_custom_device("iluvatar_gpu"):
56 # Set environment variable
57 self.device = f"iluvatar_gpu:{self.local_rank}"
58 paddle.device.set_device(self.device)
59 paddle.set_default_dtype(self.model_config.dtype)
60 self.device_ids = self.parallel_config.device_ids.split(",")
61
62 gc.collect()
63 else:
64 raise RuntimeError(f"Not support device type: {self.device_config.device}")
65
66 set_random_seed(self.fd_config.model_config.seed)
67 # Construct model runner
68 self.model_runner: IluvatarModelRunner = IluvatarModelRunner(
69 fd_config=self.fd_config,
70 device=self.device,
71 device_id=self.device_ids[self.local_rank],
72 rank=self.rank,
73 local_rank=self.local_rank,
74 )
75
76 def determine_available_memory(self) -> int:
77 """

Callers

nothing calls this directly

Calls 4

set_random_seedFunction · 0.90
IluvatarModelRunnerClass · 0.90
splitMethod · 0.80
collectMethod · 0.80

Tested by

no test coverage detected