Error loading ASGI app. Could not import module "main".

I'm trying to run a Fast API app on a Pod. I've followed this tutorial https://www.runpod.io/articles/guides/deploy-fastapi-applications-gpu-cloud My Docker Image runs locally fine. The container gets created fine on RunPod. However I gett an error message in the Container Logs.
Error loading ASGI app. Could not import module "main".
Error loading ASGI app. Could not import module "main".
If I attempt to override the start CMD then I just get error messages saying a file can't be found, even if I enter the exact same CMD that is in the docker file.
5/29/2025, 6:43:14 AM
[FATAL tini (31)] exec CMD failed: No such file or directory
5/29/2025, 6:43:14 AM
[FATAL tini (31)] exec CMD failed: No such file or directory
This is my Docker FIle
# Use an official PyTorch image with CUDA support as base (contains Python, CUDA, PyTorch)
FROM pytorch/pytorch:2.0.1-cuda11.7-cudnn8-runtime

RUN pip install --upgrade pip

# Install the Python requirements
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Copy application code
WORKDIR /app
COPY app/ /app/


ENV HF_HOME="/tmp/huggingface/hub"
ENV TOKENIZERS_PARALLELISM=false
ENV TORCH_HOME="app/torch"

# Expose port 8000 (the port our FastAPI app will run on)
EXPOSE 8000

# Specify the entrypoint to run the app with Uvicorn (listening on all interfaces at port 8000)
CMD ["uvicorn", "api:app", "--host", "0.0.0.0", "--port", "8000"]
# Use an official PyTorch image with CUDA support as base (contains Python, CUDA, PyTorch)
FROM pytorch/pytorch:2.0.1-cuda11.7-cudnn8-runtime

RUN pip install --upgrade pip

# Install the Python requirements
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Copy application code
WORKDIR /app
COPY app/ /app/


ENV HF_HOME="/tmp/huggingface/hub"
ENV TOKENIZERS_PARALLELISM=false
ENV TORCH_HOME="app/torch"

# Expose port 8000 (the port our FastAPI app will run on)
EXPOSE 8000

# Specify the entrypoint to run the app with Uvicorn (listening on all interfaces at port 8000)
CMD ["uvicorn", "api:app", "--host", "0.0.0.0", "--port", "8000"]
How to Deploy FastAPI Applications with GPU Access in the Cloud
Deploying a FastAPI application that uses GPU acceleration (e.g. with PyTorch) can be achieved by containerizing the app and running it on a cloud GPU...
4 Replies
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
selectedpixel
selectedpixelOP4mo ago
Actually I think the problem was that my changes weren't pushed to Docker Hub correctly.
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
selectedpixel
selectedpixelOP4mo ago
The problem was just that I wasn't retagging the local container. It's working now. Thank you

Did you find this page helpful?