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

Configure Container Startup Timeout #2869

Closed
Tracked by #27
luisquintanilla opened this issue Mar 13, 2024 · 8 comments
Closed
Tracked by #27

Configure Container Startup Timeout #2869

luisquintanilla opened this issue Mar 13, 2024 · 8 comments
Labels
area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication

Comments

@luisquintanilla
Copy link

luisquintanilla commented Mar 13, 2024

Containers like HuggingFace text-generation-inference take a long time to startup because they're pulling down the model which is usually multi-GB files.

This causes the app to time out.

info: Aspire.Hosting.DistributedApplication[0]
      Distributed application starting.
info: Aspire.Hosting.DistributedApplication[0]
      Application host directory is: C:\Users\luquinta\source\repos\TestAspireDeployment\TestAspireDeployment.AppHost
info: Aspire.Hosting.DistributedApplication[0]
      Now listening on: http://localhost:15201
info: Aspire.Hosting.DistributedApplication[0]
      Distributed application started. Press CTRL-C to stop.
info: Grpc.AspNetCore.Server.ServerCallHandler[14]
      Error reading message.
      System.IO.IOException: The client reset the request stream.
         at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpRequestPipeReader.ReadAsync(CancellationToken cancellationToken)
         at Grpc.AspNetCore.Server.Internal.PipeExtensions.ReadSingleMessageAsync[T](PipeReader input, HttpContextServerCallContext serverCallContext, Func`2 deserializer)
fail: Grpc.AspNetCore.Server.ServerCallHandler[6]
      Error when executing service method 'WatchResourceConsoleLogs'.
      System.IO.IOException: The client reset the request stream.
         at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpRequestPipeReader.ReadAsync(CancellationToken cancellationToken)
         at Grpc.AspNetCore.Server.Internal.PipeExtensions.ReadSingleMessageAsync[T](PipeReader input, HttpContextServerCallContext serverCallContext, Func`2 deserializer)
         at Grpc.AspNetCore.Server.Internal.CallHandlers.ServerStreamingServerCallHandler`3.HandleCallAsyncCore(HttpContext httpContext, HttpContextServerCallContext serverCallContext)
         at Grpc.AspNetCore.Server.Internal.CallHandlers.ServerCallHandlerBase`3.<HandleCallAsync>g__AwaitHandleCall|8_0(HttpContextServerCallContext serverCallContext, Method`2 method, Task handleCall)

Provide a way to enable containers that take a long time to start up.

To repro in Aspire, add this to AppHost project.

var hf =
    builder.AddContainer("hf-generation", "ghcr.io/huggingface/text-generation-inference",tag: "1.4")
    .WithVolumeMount("$PWD/data", "/data", VolumeMountType.Bind)
    .WithHttpEndpoint(hostPort: 8080, name: "generation")
    .WithArgs("--model-id", "HuggingFaceH4/zephyr-7b-beta");
@dotnet-issue-labeler dotnet-issue-labeler bot added the area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication label Mar 13, 2024
@DamianEdwards
Copy link
Member

I tried to repro this on latest bits and it seemed to indicate there's an error in your WithArgs call?

image

@DamianEdwards DamianEdwards added the needs-author-action An issue or pull request that requires more info or actions from the author. label Mar 14, 2024
@luisquintanilla
Copy link
Author

Yeah. Good catch. I don't think that's needed in this case so you can still run it without that arg. Updated the repro command

@dotnet-policy-service dotnet-policy-service bot removed the needs-author-action An issue or pull request that requires more info or actions from the author. label Mar 14, 2024
@DamianEdwards
Copy link
Member

For reference, --shm-size is an arg for docker run itself which we don't support right now (similar to #2737).

I'm trying the repro again now...

@DamianEdwards
Copy link
Member

Also note, your .WithVolumeMount("$PWD/data", "/data", VolumeMountType.Bind) needs to be changed to .WithBindMount("./data", "/data") with latest bits and to work the way you intended I think (the $PWD just gets taken literally, not interpreted as the current directory).

@luisquintanilla
Copy link
Author

luisquintanilla commented Mar 14, 2024

For reference, --shm-size is an arg for docker run itself which we don't support right now (similar to #2737).

I'm trying the repro again now...

I see. So to clarify docker run args aren't supported yet but args passed to to the container are. In this case --model-id being something you pass to the container.

@DamianEdwards
Copy link
Member

DamianEdwards commented Mar 15, 2024

Ok I got this working locally on latest (daily) bits.

I had to change your code to the following to ensure the endpoint was registered correctly:

var hf =
    builder.AddContainer("hf-generation", "ghcr.io/huggingface/text-generation-inference", tag: "1.4")
        .WithBindMount("./data", "/data")
        .WithHttpEndpoint(containerPort: 80, hostPort: 8080)
        .WithArgs("--model-id", "HuggingFaceH4/zephyr-7b-beta");

I watched the logs in Docker Desktop and on the Aspire Dashboard and it took about 5 minutes to fully startup (having previously downloaded the model into the ./data directory):

image

At that point I opened a terminal and ran the following command:

 curl localhost:8080/generate -X POST -d '{"inputs":"What is Deep Learning?","parameters":{"max_new_tokens":20}}' -H 'Content-Type: application/json'

And got the following reply:

{"generated_text":"\n\nDeep Learning is a subset of Machine Learning that uses Artificial Neural Networks with multiple"}

I could see the generation details in the log too:

image

If there was a problem before it seems it's fixed now, perhaps by the recent change to streaming logs.

@luisquintanilla
Copy link
Author

luisquintanilla commented Mar 18, 2024

Awesome! Is this the right guidance for setting up the latest daily version of Aspire?

https://github.com/dotnet/aspire/blob/main/docs/using-latest-daily.md

@DamianEdwards
Copy link
Member

Yep! Let us know if you run into any issues. Getting the feeds and workload just right can be a little tricky.

@github-actions github-actions bot locked and limited conversation to collaborators May 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication
Projects
None yet
Development

No branches or pull requests

4 participants