Skip to content

Commit bb028cc

Browse files
authored
feat: Allow passing workspace base directory via environment variable (#973)
I'm using sglang in kubernetes; sglang is importing flashinfer I have rather strict setup that does not allow root user to run the container, so I'm running the container with user `nobody` and I need to specify various directories that are supposed to be writable. With latest flashinfer, I noticed that it tries to create some directories under `$HOME`. Common way to get around it is to path some env variable to the libraries trying to write stuff so I can control the target path and let it write to the writable directory (And in my case this is not $HOME). So I'm proposing to add an option to explicitly specify directory where flashinfer wants to write so that the user has more control over it
1 parent 893172c commit bb028cc

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

flashinfer/jit/env.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
limitations under the License.
1515
"""
1616

17+
import os
1718
import pathlib
1819
import re
1920
import warnings
@@ -32,8 +33,11 @@ def _get_workspace_dir_name() -> pathlib.Path:
3233
arch = "_".join(sorted(set(re.findall(r"compute_(\d+)", "".join(flags)))))
3334
except Exception:
3435
arch = "noarch"
36+
flashinfer_base = os.getenv(
37+
"FLASHINFER_WORKSPACE_BASE", pathlib.Path.home().as_posix()
38+
)
3539
# e.g.: $HOME/.cache/flashinfer/75_80_89_90/
36-
return pathlib.Path.home() / ".cache" / "flashinfer" / arch
40+
return pathlib.Path(flashinfer_base) / ".cache" / "flashinfer" / arch
3741

3842

3943
# use pathlib

0 commit comments

Comments
 (0)