How to set the Python version in Hugging Face Space?

I previously deployed my model on Hugging Face Spaces, and it ran successfully with good user experience for several months. However, it seems that there have been some recent changes to Spaces, and the default Python version has been set to Python 3.10, which is causing my model deployment to fail consistently. Below is the error message:

  File "/home/user/.pyenv/versions/3.10.16/lib/python3.10/site-packages/peft/peft_model.py", line 514, in __init__
    super().__init__(model, peft_config)
  File "/home/user/.pyenv/versions/3.10.16/lib/python3.10/site-packages/peft/peft_model.py", line 79, in __init__
    self.base_model = LoraModel(peft_config, model)
  File "/home/user/.pyenv/versions/3.10.16/lib/python3.10/site-packages/peft/tuners/lora.py", line 118, in __init__
    self._find_and_replace()
  File "/home/user/.pyenv/versions/3.10.16/lib/python3.10/site-packages/peft/tuners/lora.py", line 152, in _find_and_replace
    "memory_efficient_backward": target.state.memory_efficient_backward,
AttributeError: 'MatmulLtState' object has no attribute 'memory_efficient_backward'

Has anyone encountered this issue?

  1. Is the error caused by incompatibility with the Python 3.10 version?
  2. How can I set the Python version in Hugging Face Spaces to my previous version, Python 3.8?
1 Like