import subprocess | |
import sys | |
# Uninstall the existing llama-cpp-python package | |
# uninstall_command = ["pip", "uninstall", "-y", "llama-cpp-python"] | |
# subprocess.run(uninstall_command, shell=True) | |
# Install llama-cpp-python with CUDA support | |
install_command = ["pip", "install", "--upgrade", "--force-reinstall", "llama-cpp-python", "--no-cache-dir"] | |
install_command_cmake_args = ["CMAKE_ARGS=-DLLAMA_CUBLAS=on", "FORCE_CMAKE=1"] | |
install_command.extend(install_command_cmake_args) | |
subprocess.run(install_command, shell=True) | |
# Start the Hugging Face Space | |
uvicorn_command = ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] | |
subprocess.run(uvicorn_command, shell=True) | |
subprocess.run(install_command, shell=True) | |