Skip to content

Commit cdc12c3

Browse files
authored
Change workspace dir (#566)
In my development setup, I have different machines with different GPUs. They share the home directory on a network filesystem. When I switch between machines, since the JIT compilation flags change, I'll have to recompile kernels every time. One solution is to specify the same `TORCH_CUDA_ARCH_LIST` every time. However, I keep forgetting that. Another solution, as proposed in this PR, is to put different arch list in different cache directory.
1 parent d30667b commit cdc12c3

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

python/flashinfer/jit/env.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,20 @@
1515
"""
1616

1717
import pathlib
18+
import re
19+
20+
from torch.utils.cpp_extension import _get_cuda_arch_flags
21+
22+
23+
def _get_workspace_dir_name() -> pathlib.Path:
24+
flags = _get_cuda_arch_flags()
25+
arch = "_".join(sorted(set(re.findall(r"compute_(\d+)", "".join(flags)))))
26+
# e.g.: $HOME/.cache/flashinfer/75_80_89_90/
27+
return pathlib.Path.home() / ".cache" / "flashinfer" / arch
28+
1829

1930
# use pathlib
20-
FLASHINFER_WORKSPACE_DIR = pathlib.Path.home() / ".flashinfer"
31+
FLASHINFER_WORKSPACE_DIR = _get_workspace_dir_name()
2132
FLASHINFER_JIT_DIR = FLASHINFER_WORKSPACE_DIR / "cached_ops"
2233
FLASHINFER_GEN_SRC_DIR = FLASHINFER_WORKSPACE_DIR / "generated"
2334
_project_root = pathlib.Path(__file__).resolve().parent.parent.parent

0 commit comments

Comments
 (0)