-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathinstall.py
More file actions
38 lines (27 loc) · 794 Bytes
/
install.py
File metadata and controls
38 lines (27 loc) · 794 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import sys
import subprocess
from pathlib import Path
from typing import List
PARENT_DIR = Path(__file__).parent
def pip_install(args: List[str]) -> None:
subprocess.check_call(
[sys.executable, "-m", "pip", "install", ] + args, cwd=PARENT_DIR
)
def try_get_cuda_version() -> str | None:
try:
import torch
return torch.version.cuda
except ImportError or AttributeError:
return None
def main() -> None:
cuda_version = try_get_cuda_version()
if cuda_version is not None:
if cuda_version.startswith("12."):
pip_install(["-e", ".[cuda-12]"])
else:
pip_install(["-e", ".[cuda]"])
else:
# Default install
pip_install(["-e", ".[cpu]"])
if __name__ == "__main__":
main()