Spaces:
Running on Zero
Running on Zero
File size: 1,169 Bytes
cdc4405 | 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 | # Copyright (c) 2026 Scenema AI
# https://scenema.ai
# SPDX-License-Identifier: MIT
"""Scenema Audio entry point.
CRITICAL: CUDA memory config must happen before torch imports.
"""
import os
if "expandable_segments" not in os.environ.get("PYTORCH_CUDA_ALLOC_CONF", ""):
_alloc = os.environ.get("PYTORCH_CUDA_ALLOC_CONF", "")
os.environ["PYTORCH_CUDA_ALLOC_CONF"] = (
(_alloc + ",expandable_segments:True") if _alloc else "expandable_segments:True"
)
import logging
logging.basicConfig(
level=logging.DEBUG if os.environ.get("DEBUG") else logging.INFO,
format="%(asctime)s | %(levelname)-8s | %(name)s | %(message)s",
)
logger = logging.getLogger(__name__)
def main():
# These imports are inside main() because CUDA config above
# must execute before torch is imported (processor -> engine -> torch)
from common.runner import run
from .processor import AudioProcessor
handler_mode = os.environ.get("HANDLER_MODE", "http")
logger.info("Starting Scenema Audio in %s mode", handler_mode)
processor = AudioProcessor()
run(processor, service_type="scenema_audio")
if __name__ == "__main__":
main()
|