zonos2 / zonos2 /kernel /__main__.py
Mike0021's picture
Initial ZONOS2 ZeroGPU Space
a63d266 verified
Raw
History Blame Contribute Delete
1.37 kB
assert __name__ == "__main__"
def generate_clangd():
import os
import subprocess
from tvm_ffi.libinfo import find_dlpack_include_path, find_include_path
from zonos2.kernel.utils import DEFAULT_INCLUDE
from zonos2.utils import init_logger
logger = init_logger(__name__)
logger.info("Generating .clangd file...")
include_paths = [find_include_path(), find_dlpack_include_path()] + DEFAULT_INCLUDE
status = subprocess.run(
args=["nvidia-smi", "--query-gpu=compute_cap", "--format=csv,noheader"],
capture_output=True,
check=True,
)
compute_cap = status.stdout.decode("utf-8").strip().split("\n")[0]
major, minor = compute_cap.split(".")
compile_flags = ",\n ".join(
[
"-xcuda",
f"--cuda-gpu-arch=sm_{major}{minor}",
"-std=c++20",
"-Wall",
"-Wextra",
]
+ [f"-isystem{path}" for path in include_paths]
)
clangd_content = f"""
CompileFlags:
Add: [
{compile_flags}
]
"""
if os.path.exists(".clangd"):
logger.warning(".clangd file already exists, nothing done.")
logger.warning(f"suggested content: {clangd_content}")
else:
with open(".clangd", "w") as f:
f.write(clangd_content)
logger.info(".clangd file generated.")
generate_clangd()