in optimum_benchmark/launchers/base.py [0:0]
def numactl_executable(self):
self.logger.info("\t+ Warming up multiprocessing context")
dummy_process = Process(target=dummy_target, daemon=False)
dummy_process.start()
dummy_process.join()
dummy_process.close()
self.logger.info("\t+ Creating numactl wrapper executable for multiprocessing")
python_path = sys.executable
numactl_path = shutil.which("numactl")
if numactl_path is None:
raise RuntimeError("ِCould not find numactl executable. Please install numactl and try again.")
numactl_args = " ".join([f"--{key}={value}" for key, value in self.config.numactl_kwargs.items()])
numa_executable = tempfile.NamedTemporaryFile(delete=False, prefix="numa_executable_", suffix=".sh")
numa_executable_content = NUMA_EXECUTABLE_CONTENT.format(
numactl_path=numactl_path, numactl_args=numactl_args, python_path=python_path
)
numa_executable.write(numa_executable_content.encode())
os.chmod(numa_executable.name, 0o777)
numa_executable.close()
self.logger.info("\t+ Setting multiprocessing executable to numactl wrapper")
set_executable(numa_executable.name)
yield
self.logger.info("\t+ Resetting default multiprocessing executable")
os.unlink(numa_executable.name)
set_executable(sys.executable)