Spaces:
Runtime error
Runtime error
import os | |
import subprocess | |
# 模型下载链接 | |
model_url = "https://huggingface.co/CMLL/ZhongJing-2-1_8b-GGUF/resolve/main/ZhongJing1_5-1_8b-fp16.gguf" | |
def install_packages(): | |
subprocess.run(['apt-get', '-y', 'install', '-qq', 'aria2'], check=True) | |
subprocess.run(['git', 'clone', '-b', 'V20230828', 'https://github.com/Troyanovsky/text-generation-webui'], check=True) | |
os.chdir('/text-generation-webui') | |
subprocess.run(['pip', 'install', '-r', 'requirements.txt'], check=True) | |
subprocess.run(['pip', 'install', '-U', 'gradio==3.33.1'], check=True) | |
subprocess.run(['pip', 'uninstall', '-y', 'llama-cpp-python'], check=True) | |
os.environ['CMAKE_ARGS'] = "-DLLAMA_CUBLAS=on" | |
os.environ['FORCE_CMAKE'] = "1" | |
subprocess.run(['pip', 'install', 'llama-cpp-python', '--no-cache-dir'], check=True) | |
def download_model(model_url, model_name): | |
subprocess.run(['aria2c', '--console-log-level=error', '-c', '-x', '16', '-s', '16', '-k', '1M', model_url, '-d', '/text-generation-webui/models/', '-o', model_name], check=True) | |
def run_server(model_name): | |
os.chdir('/text-generation-webui') | |
subprocess.run(['python', 'server.py', '--share', '--n-gpu-layers', '1000000000', '--model', model_name], check=True) | |
if __name__ == "__main__": | |
install_packages() | |
model_name = 'ZhongJing1_5-1_8b-fp16.gguf' | |
download_model(model_url, model_name) | |
run_server(model_name) | |