From ff01bcb870e6a5bca6b11f32d522911b5f2ccf40 Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Sun, 8 Jun 2025 15:33:05 -0700 Subject: [PATCH] Use user_data/cache/gradio for Gradio temp files --- server.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/server.py b/server.py index bd440fe0..e178e8fe 100644 --- a/server.py +++ b/server.py @@ -1,12 +1,26 @@ import os +import shutil import warnings +from pathlib import Path from modules import shared from modules.block_requests import OpenMonkeyPatch, RequestBlocker from modules.logging_colors import logger -os.environ['GRADIO_ANALYTICS_ENABLED'] = 'False' -os.environ['BITSANDBYTES_NOWELCOME'] = '1' +# Set up Gradio temp directory path +gradio_temp_path = Path('user_data') / 'cache' / 'gradio' + +# Set environment variables +os.environ.update({ + 'GRADIO_ANALYTICS_ENABLED': 'False', + 'BITSANDBYTES_NOWELCOME': '1', + 'GRADIO_TEMP_DIR': str(gradio_temp_path) +}) + +# Clear and recreate gradio temp directory +shutil.rmtree(gradio_temp_path, ignore_errors=True) +gradio_temp_path.mkdir(parents=True, exist_ok=True) + warnings.filterwarnings('ignore', category=UserWarning, message='TypedStorage is deprecated') warnings.filterwarnings('ignore', category=UserWarning, message='Using the update method is deprecated') warnings.filterwarnings('ignore', category=UserWarning, message='Field "model_name" has conflict') @@ -27,7 +41,6 @@ import signal import sys import time from functools import partial -from pathlib import Path from threading import Lock, Thread import yaml