Spaces:
Runtime error
Runtime error
File size: 1,509 Bytes
3a478bf |
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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
import os, sys
import torch
import json
import gradio as gr
from assets.i18n.i18n import I18nAuto
from tabs.settings.restart import restart_applio
now_dir = os.getcwd()
sys.path.append(now_dir)
i18n = I18nAuto()
ngpu = torch.cuda.device_count()
config_file = os.path.join(now_dir, "assets", "config.json")
def gpu_available():
if torch.cuda.is_available() or ngpu != 0:
return True
def load_fake_gpu():
with open(config_file, "r", encoding="utf8") as file:
config = json.load(file)
return config["fake_gpu"]
def save_config(value):
with open(config_file, "r", encoding="utf8") as file:
config = json.load(file)
config["fake_gpu"] = value
with open(config_file, "w", encoding="utf8") as file:
json.dump(config, file, indent=2)
def fake_gpu_tab():
with gr.Row():
with gr.Column():
presence = gr.Checkbox(
label=i18n("Enable fake GPU"),
info=i18n(
"Activates the train tab. However, please note that this device lacks GPU capabilities, hence training is not supported. This option is only for testing purposes. (This option will restart Applio)"
),
interactive=True,
value=load_fake_gpu(),
)
presence.change(
fn=toggle,
inputs=[presence],
outputs=[],
)
def toggle(checkbox):
save_config(bool(checkbox))
restart_applio()
|