mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-04 05:39:06 +00:00
- Typing issues discovered using `mypy'. Fixed manually - Unused imports discovered and fixed using `autoflake' - Fix indentation in `org_to_jsonl' manually
32 lines
813 B
Python
32 lines
813 B
Python
# Standard Packages
|
|
from packaging import version
|
|
|
|
# External Packages
|
|
import torch
|
|
from pathlib import Path
|
|
|
|
# Internal Packages
|
|
from src.utils.config import SearchModels, ProcessorConfigModel
|
|
from src.utils.helpers import LRU
|
|
from src.utils.rawconfig import FullConfig
|
|
|
|
# Application Global State
|
|
config = FullConfig()
|
|
model = SearchModels()
|
|
processor_config = ProcessorConfigModel()
|
|
config_file: Path = None
|
|
verbose: int = 0
|
|
host: str = None
|
|
port: int = None
|
|
cli_args: list[str] = None
|
|
query_cache = LRU()
|
|
|
|
if torch.cuda.is_available():
|
|
# Use CUDA GPU
|
|
device = torch.device("cuda:0")
|
|
elif version.parse(torch.__version__) >= version.parse("1.13.0.dev") and torch.backends.mps.is_available():
|
|
# Use Apple M1 Metal Acceleration
|
|
device = torch.device("mps")
|
|
else:
|
|
device = torch.device("cpu")
|