Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Model files not found when installing by docker #818

Open
Hamlet626 opened this issue Sep 3, 2024 · 2 comments
Open

Model files not found when installing by docker #818

Hamlet626 opened this issue Sep 3, 2024 · 2 comments

Comments

@Hamlet626
Copy link

Hamlet626 commented Sep 3, 2024

I tried to start a tortoise server by writing a docker file installing tortoise and other dependencies, and a python script to run the server, but it always shows error:

File "/opt/program/predictor.py", line 11, in <module>
    tts = TextToSpeech(enable_redaction=False)
  File "/usr/local/lib/python3.10/site-packages/tortoise/api_fast.py", line 215, in __init__
    self.autoregressive.load_state_dict(torch.load(get_model_path('autoregressive.pth', models_dir)), strict=False)
  File "/usr/local/lib/python3.10/site-packages/torch/serialization.py", line 1065, in load
    with _open_file_like(f, 'rb') as opened_file:
  File "/usr/local/lib/python3.10/site-packages/torch/serialization.py", line 468, in _open_file_like
    return _open_file(name_or_buffer, mode)
  File "/usr/local/lib/python3.10/site-packages/torch/serialization.py", line 449, in __init__
    super().__init__(open(name, mode))
    
 FileNotFoundError: [Errno 2] No such file or directory: '/opt/ml/model/tortoise/models/models--Manmay--tortoise-tts/snapshots/50672670cecf2265aa61edb4eef5d1a293a8a373/autoregressive.pth'

my docker file is like below (I tried both default and custom model dir, but none works, if I use the default model dir, the error will be something like [No such file or directory: '/root/.cache/tortoise/...']):

FROM python:3.10

# Install system dependencies
RUN apt-get -y update && apt-get install -y --no-install-recommends \
         wget \
         git \
         python3 \
         nginx \
         ca-certificates \
    && rm -rf /var/lib/apt/lists/*

# Install pip using the official installer and upgrade pip
RUN wget https://bootstrap.pypa.io/get-pip.py && python3 get-pip.py && \
    python -m pip install --upgrade pip

# Set environment variables
ENV HF_HOME=/opt/ml/model/huggingface
ENV TORTOISE_MODELS_DIR=/opt/ml/model/tortoise/models

# Install tortoise-tts and additional Python packages
RUN python -m pip install flask gevent gunicorn tortoise-tts spacy && \
    python -m spacy download en

COPY serverDir /opt/program
WORKDIR /opt/program

my predictor.py is like:

from fastapi import FastAPI, Request
from tortoise.api import TextToSpeech
import torch
import io

os.environ['TORTOISE_MODELS_DIR'] = '/opt/ml/model/tortoise/models'

# I used enable_redaction=False, otherwise it's going to raise hugging face model FileNotFoundError as well 
tts_model = TextToSpeech(enable_redaction=False)

#... other code

Does anyone know if I'm setting up tortoise correctly(by just installing the package and call TextToSpeech())? Thanks in advance

@Hamlet626
Copy link
Author

Also I tried to download and upload all the models from https://huggingface.co/Manmay/tortoise-tts/tree/main, but it seems that it requires 'autoregressive.ptt', instead of 'autoregressive.pth' as I saw in source code

if os.path.exists(f'{models_dir}/autoregressive.ptt'):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
@Hamlet626 and others