Pin PyTorch <2.4.0 for AudioCraft compatibility

AudioCraft requires PyTorch 2.1.x. PyTorch 2.4+ changed the
torch.utils._pytree API (serialized_type_name parameter), breaking
AudioCraft's model loading.

- Pin torch>=2.1.0,<2.4.0
- Pin torchaudio>=2.1.0,<2.4.0
- Remove broken pytree monkey-patch attempt

After pulling, reinstall with:
  pip install -r requirements.txt --force-reinstall torch torchaudio

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-27 13:43:26 +01:00
parent 4c602a6c07
commit f27ac50f1d
2 changed files with 3 additions and 14 deletions

11
main.py
View File

@@ -16,17 +16,6 @@ os.chdir(PROJECT_ROOT)
# Add project root to path # Add project root to path
sys.path.insert(0, str(PROJECT_ROOT)) sys.path.insert(0, str(PROJECT_ROOT))
# PyTorch 2.5+ compatibility patch for audiocraft
# The _pytree API changed - add backwards compatibility
try:
import torch.utils._pytree as _pytree
if not hasattr(_pytree, 'register_pytree_node') and hasattr(_pytree, '_register_pytree_node'):
_pytree.register_pytree_node = _pytree._register_pytree_node
elif not hasattr(_pytree, '_register_pytree_node') and hasattr(_pytree, 'register_pytree_node'):
_pytree._register_pytree_node = _pytree.register_pytree_node
except Exception:
pass # Ignore if patch fails
from config.settings import get_settings from config.settings import get_settings
from src.core.gpu_manager import GPUMemoryManager from src.core.gpu_manager import GPUMemoryManager
from src.core.model_registry import ModelRegistry from src.core.model_registry import ModelRegistry

View File

@@ -1,6 +1,6 @@
# Core ML # Core ML - Pin to AudioCraft-compatible versions (2.4+ breaks pytree API)
torch>=2.1.0 torch>=2.1.0,<2.4.0
torchaudio>=2.1.0 torchaudio>=2.1.0,<2.4.0
audiocraft>=1.3.0 audiocraft>=1.3.0
xformers>=0.0.22 xformers>=0.0.22