download the correct wheel based on cpuinfo

This commit is contained in:
Alex O'Connell
2024-04-16 21:14:05 -04:00
parent e86d7153f8
commit 556edc19a7

View File

@@ -85,8 +85,17 @@ def install_llama_cpp_python(config_dir: str):
_LOGGER.info("Installing llama-cpp-python from local wheel")
_LOGGER.debug(f"Wheel location: {latest_wheel}")
return install_package(os.path.join(folder, latest_wheel), pip_kwargs(config_dir))
instruction_extensions_suffix = ""
if platform_suffix == "amd64" or platform_suffix == "i386":
with open("/proc/cpuinfo") as f:
cpu_features = [ line for line in f.readlines() if line.startswith("Features")][0]
if "avx512f" in cpu_features and "avx512bw" in cpu_features:
instruction_extensions_suffix = "-avx512"
elif "avx" not in cpu_features:
instruction_extensions_suffix = "-noavx"
github_release_url = f"https://github.com/acon96/home-llm/releases/download/v{INTEGRATION_VERSION}/llama_cpp_python-{EMBEDDED_LLAMA_CPP_PYTHON_VERSION}-{runtime_version}-{runtime_version}-musllinux_1_2_{platform_suffix}.whl"
github_release_url = f"https://github.com/acon96/home-llm/releases/download/v{INTEGRATION_VERSION}/llama_cpp_python-{EMBEDDED_LLAMA_CPP_PYTHON_VERSION}-{runtime_version}-{runtime_version}-musllinux_1_2_{platform_suffix}{instruction_extensions_suffix}.whl"
if install_package(github_release_url, pip_kwargs(config_dir)):
_LOGGER.info("llama-cpp-python successfully installed from GitHub release")
return True