File size: 742 Bytes
5956319
 
 
 
71b7f64
5956319
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr
import spaces
import torch
import subprocess
import numpy as np

zero = torch.Tensor([0]).cuda()
print(zero.device) # <-- 'cpu' 🤔

@spaces.GPU
def start_ochat_server():
    print(zero.device)  # <-- 'cuda:0' 🤗

    # Command to start the ochat inference server
    command = [
        "python", "-m", "ochat.serving.openai_api_server", 
        "--model", "openchat/openchat_3.5"
    ]

    # Start the server
    try:
        # Use subprocess to run the command
        subprocess.Popen(command)
        return "ochat server started successfully"
    except Exception as e:
        return f"Failed to start ochat server: {e}"
    

gr.Interface(fn=start_ochat_server, inputs=gr.Number(), outputs=gr.Text()).launch()