Skip to content

Commit d49e85a

Browse files
DarkLight1337rasmith
authored andcommitted
[Bugfix] Use temporary directory in registry (vllm-project#9721)
Signed-off-by: Randall Smith <[email protected]>
1 parent c541040 commit d49e85a

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

vllm/model_executor/models/registry.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import importlib
2+
import os
23
import pickle
34
import subprocess
45
import sys
@@ -423,9 +424,13 @@ def is_attention_free_model(self, architectures: Union[str,
423424

424425

425426
def _run_in_subprocess(fn: Callable[[], _T]) -> _T:
426-
with tempfile.NamedTemporaryFile() as output_file:
427+
# NOTE: We use a temporary directory instead of a temporary file to avoid
428+
# issues like https://stackoverflow.com/questions/23212435/permission-denied-to-write-to-my-temporary-file
429+
with tempfile.TemporaryDirectory() as tempdir:
430+
output_filepath = os.path.join(tempdir, "registry_output.tmp")
431+
427432
# `cloudpickle` allows pickling lambda functions directly
428-
input_bytes = cloudpickle.dumps((fn, output_file.name))
433+
input_bytes = cloudpickle.dumps((fn, output_filepath))
429434

430435
# cannot use `sys.executable __file__` here because the script
431436
# contains relative imports
@@ -442,7 +447,7 @@ def _run_in_subprocess(fn: Callable[[], _T]) -> _T:
442447
raise RuntimeError(f"Error raised in subprocess:\n"
443448
f"{returned.stderr.decode()}") from e
444449

445-
with open(output_file.name, "rb") as f:
450+
with open(output_filepath, "rb") as f:
446451
return pickle.load(f)
447452

448453

0 commit comments

Comments
 (0)