Spaces:
Runtime error
Runtime error
File size: 1,414 Bytes
cdddf91 550b1f1 f2ae05b ed0a7ea cdddf91 f2ae05b d7810f3 f2ae05b d7810f3 a90c92b d7810f3 44ac364 f2ae05b cdddf91 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
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)
|