-
Notifications
You must be signed in to change notification settings - Fork 79
Add ollama support #242
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
Add ollama support #242
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -72,6 +72,80 @@ func inspectStandaloneRunner(container container.Summary) *standaloneRunner { | |||||||||||||||||||||||||||||||||||||||||||||||
| return result | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| // ensureOllamaRunnerAvailable is a utility function that ensures an ollama runner | ||||||||||||||||||||||||||||||||||||||||||||||||
| // is available. Unlike the regular runner, ollama runners are always used via | ||||||||||||||||||||||||||||||||||||||||||||||||
| // controller containers on all platforms. | ||||||||||||||||||||||||||||||||||||||||||||||||
| func ensureOllamaRunnerAvailable(ctx context.Context, printer standalone.StatusPrinter) (*standaloneRunner, error) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| // For ollama, we always use controller containers on all platforms | ||||||||||||||||||||||||||||||||||||||||||||||||
| // If automatic installation has been disabled, then don't do anything. | ||||||||||||||||||||||||||||||||||||||||||||||||
| if os.Getenv("MODEL_RUNNER_NO_AUTO_INSTALL") != "" { | ||||||||||||||||||||||||||||||||||||||||||||||||
| return nil, nil | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| // Ensure that the output printer is non-nil. | ||||||||||||||||||||||||||||||||||||||||||||||||
| if printer == nil { | ||||||||||||||||||||||||||||||||||||||||||||||||
| printer = standalone.NoopPrinter() | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| // Create a Docker client for the active context. | ||||||||||||||||||||||||||||||||||||||||||||||||
| dockerClient, err := desktop.DockerClientForContext(dockerCLI, dockerCLI.CurrentContext()) | ||||||||||||||||||||||||||||||||||||||||||||||||
| if err != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||
| return nil, fmt.Errorf("failed to create Docker client: %w", err) | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| // Check if an ollama runner container exists. | ||||||||||||||||||||||||||||||||||||||||||||||||
| containerID, _, container, err := standalone.FindOllamaControllerContainer(ctx, dockerClient) | ||||||||||||||||||||||||||||||||||||||||||||||||
| if err != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||
| return nil, fmt.Errorf("unable to identify existing ollama runner: %w", err) | ||||||||||||||||||||||||||||||||||||||||||||||||
| } else if containerID != "" { | ||||||||||||||||||||||||||||||||||||||||||||||||
| return inspectStandaloneRunner(container), nil | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| // Automatically determine GPU support. | ||||||||||||||||||||||||||||||||||||||||||||||||
| gpu, err := gpupkg.ProbeGPUSupport(ctx, dockerClient) | ||||||||||||||||||||||||||||||||||||||||||||||||
| if err != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||
| return nil, fmt.Errorf("unable to probe GPU support: %w", err) | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| // Ensure that we have an up-to-date copy of the ollama image. | ||||||||||||||||||||||||||||||||||||||||||||||||
| if err := standalone.EnsureOllamaImage(ctx, dockerClient, gpu, "", printer); err != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||
| return nil, fmt.Errorf("unable to pull latest ollama image: %w", err) | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| // Ensure that we have an ollama storage volume. | ||||||||||||||||||||||||||||||||||||||||||||||||
| modelStorageVolume, err := standalone.EnsureOllamaStorageVolume(ctx, dockerClient, printer) | ||||||||||||||||||||||||||||||||||||||||||||||||
| if err != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||
| return nil, fmt.Errorf("unable to initialize ollama storage: %w", err) | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| // Create the ollama runner container. | ||||||||||||||||||||||||||||||||||||||||||||||||
| port := uint16(standalone.DefaultOllamaPort) | ||||||||||||||||||||||||||||||||||||||||||||||||
| host := "127.0.0.1" | ||||||||||||||||||||||||||||||||||||||||||||||||
| engineKind := modelRunner.EngineKind() | ||||||||||||||||||||||||||||||||||||||||||||||||
| environment := "moby" | ||||||||||||||||||||||||||||||||||||||||||||||||
| if engineKind == types.ModelRunnerEngineKindCloud { | ||||||||||||||||||||||||||||||||||||||||||||||||
| environment = "cloud" | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
| if err := standalone.CreateOllamaControllerContainer(ctx, dockerClient, port, host, environment, false, gpu, "", modelStorageVolume, printer, engineKind); err != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||
| return nil, fmt.Errorf("unable to initialize ollama container: %w", err) | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| // Poll until we get a response from the ollama runner. | ||||||||||||||||||||||||||||||||||||||||||||||||
| // Note: We reuse the same wait logic, assuming ollama responds similarly | ||||||||||||||||||||||||||||||||||||||||||||||||
| if err := waitForStandaloneRunnerAfterInstall(ctx); err != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||
| return nil, err | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+135
to
+137
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The A dedicated waiting logic that polls the (You will also need to add
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| // Find the runner container. | ||||||||||||||||||||||||||||||||||||||||||||||||
| containerID, _, container, err = standalone.FindOllamaControllerContainer(ctx, dockerClient) | ||||||||||||||||||||||||||||||||||||||||||||||||
| if err != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||
| return nil, fmt.Errorf("unable to identify existing ollama runner: %w", err) | ||||||||||||||||||||||||||||||||||||||||||||||||
| } else if containerID == "" { | ||||||||||||||||||||||||||||||||||||||||||||||||
| return nil, errors.New("ollama runner not found after installation") | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
| return inspectStandaloneRunner(container), nil | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| // ensureStandaloneRunnerAvailable is a utility function that other commands can | ||||||||||||||||||||||||||||||||||||||||||||||||
| // use to initialize a default standalone model runner. It is a no-op in | ||||||||||||||||||||||||||||||||||||||||||||||||
| // unsupported contexts or if automatic installs have been disabled. | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -168,6 +242,7 @@ type runnerOptions struct { | |||||||||||||||||||||||||||||||||||||||||||||||
| doNotTrack bool | ||||||||||||||||||||||||||||||||||||||||||||||||
| pullImage bool | ||||||||||||||||||||||||||||||||||||||||||||||||
| pruneContainers bool | ||||||||||||||||||||||||||||||||||||||||||||||||
| ollama bool | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| // runInstallOrStart is shared logic for install-runner and start-runner commands | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -191,7 +266,11 @@ func runInstallOrStart(cmd *cobra.Command, opts runnerOptions) error { | |||||||||||||||||||||||||||||||||||||||||||||||
| // Use "0" as a sentinel default flag value so it's not displayed automatically. | ||||||||||||||||||||||||||||||||||||||||||||||||
| // The default values are written in the usage string. | ||||||||||||||||||||||||||||||||||||||||||||||||
| // Hence, the user currently won't be able to set the port to 0 in order to get a random available port. | ||||||||||||||||||||||||||||||||||||||||||||||||
| port = standalone.DefaultControllerPortMoby | ||||||||||||||||||||||||||||||||||||||||||||||||
| if opts.ollama { | ||||||||||||||||||||||||||||||||||||||||||||||||
| port = standalone.DefaultOllamaPort | ||||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| port = standalone.DefaultControllerPortMoby | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
| // HACK: If we're in a Cloud context, then we need to use a | ||||||||||||||||||||||||||||||||||||||||||||||||
| // different default port because it conflicts with Docker Desktop's | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -200,7 +279,7 @@ func runInstallOrStart(cmd *cobra.Command, opts runnerOptions) error { | |||||||||||||||||||||||||||||||||||||||||||||||
| // when context detection happens. So assume that a default value | ||||||||||||||||||||||||||||||||||||||||||||||||
| // indicates that we want the Cloud default port. This is less | ||||||||||||||||||||||||||||||||||||||||||||||||
| // problematic in Cloud since the UX there is mostly invisible. | ||||||||||||||||||||||||||||||||||||||||||||||||
| if engineKind == types.ModelRunnerEngineKindCloud && | ||||||||||||||||||||||||||||||||||||||||||||||||
| if !opts.ollama && engineKind == types.ModelRunnerEngineKindCloud && | ||||||||||||||||||||||||||||||||||||||||||||||||
| port == standalone.DefaultControllerPortMoby { | ||||||||||||||||||||||||||||||||||||||||||||||||
| port = standalone.DefaultControllerPortCloud | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -219,51 +298,93 @@ func runInstallOrStart(cmd *cobra.Command, opts runnerOptions) error { | |||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| // If pruning containers (reinstall), remove any existing model runner containers. | ||||||||||||||||||||||||||||||||||||||||||||||||
| if opts.pruneContainers { | ||||||||||||||||||||||||||||||||||||||||||||||||
| if err := standalone.PruneControllerContainers(cmd.Context(), dockerClient, false, cmd); err != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||
| return fmt.Errorf("unable to remove model runner container(s): %w", err) | ||||||||||||||||||||||||||||||||||||||||||||||||
| if opts.ollama { | ||||||||||||||||||||||||||||||||||||||||||||||||
| if err := standalone.PruneOllamaControllerContainers(cmd.Context(), dockerClient, false, cmd); err != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||
| return fmt.Errorf("unable to remove ollama runner container(s): %w", err) | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| if err := standalone.PruneControllerContainers(cmd.Context(), dockerClient, false, cmd); err != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||
| return fmt.Errorf("unable to remove model runner container(s): %w", err) | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| // Check if an active model runner container already exists (install only). | ||||||||||||||||||||||||||||||||||||||||||||||||
| if ctrID, ctrName, _, err := standalone.FindControllerContainer(cmd.Context(), dockerClient); err != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||
| var ctrID, ctrName string | ||||||||||||||||||||||||||||||||||||||||||||||||
| var err error | ||||||||||||||||||||||||||||||||||||||||||||||||
| if opts.ollama { | ||||||||||||||||||||||||||||||||||||||||||||||||
| ctrID, ctrName, _, err = standalone.FindOllamaControllerContainer(cmd.Context(), dockerClient) | ||||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| ctrID, ctrName, _, err = standalone.FindControllerContainer(cmd.Context(), dockerClient) | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
| if err != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||
| return err | ||||||||||||||||||||||||||||||||||||||||||||||||
| } else if ctrID != "" { | ||||||||||||||||||||||||||||||||||||||||||||||||
| runnerType := "Model Runner" | ||||||||||||||||||||||||||||||||||||||||||||||||
| if opts.ollama { | ||||||||||||||||||||||||||||||||||||||||||||||||
| runnerType = "ollama runner" | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
| if ctrName != "" { | ||||||||||||||||||||||||||||||||||||||||||||||||
| cmd.Printf("Model Runner container %s (%s) is already running\n", ctrName, ctrID[:12]) | ||||||||||||||||||||||||||||||||||||||||||||||||
| cmd.Printf("%s container %s (%s) is already running\n", runnerType, ctrName, ctrID[:12]) | ||||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| cmd.Printf("Model Runner container %s is already running\n", ctrID[:12]) | ||||||||||||||||||||||||||||||||||||||||||||||||
| cmd.Printf("%s container %s is already running\n", runnerType, ctrID[:12]) | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
| return nil | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
299
to
333
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This function contains a significant amount of duplicated logic within You can refactor this by defining runner-specific configurations at the beginning of the function and then using a single, unified code path. The This same pattern of duplication appears later in the function when ensuring images and volumes, and creating the container, which could also be refactored similarly. runnerTypeStr := "Model Runner"
runnerTypeLabel := "model-runner"
pruneErrMsg := "unable to remove model runner container(s): %w"
if opts.ollama {
runnerTypeStr = "ollama runner"
runnerTypeLabel = "ollama"
pruneErrMsg = "unable to remove ollama runner container(s): %w"
}
// If pruning containers (reinstall), remove any existing model runner containers.
if opts.pruneContainers {
if err := standalone.PruneControllerContainersByType(cmd.Context(), dockerClient, false, cmd, runnerTypeLabel); err != nil {
return fmt.Errorf(pruneErrMsg, err)
}
} else {
// Check if an active model runner container already exists (install only).
ctrID, ctrName, _, err := standalone.FindControllerContainerByType(cmd.Context(), dockerClient, runnerTypeLabel)
if err != nil {
return err
} else if ctrID != "" {
if ctrName != "" {
cmd.Printf("%s container %s (%s) is already running\n", runnerTypeStr, ctrName, ctrID[:12])
} else {
cmd.Printf("%s container %s is already running\n", runnerTypeStr, ctrID[:12])
}
return nil
}
} |
||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| // Determine GPU support. | ||||||||||||||||||||||||||||||||||||||||||||||||
| var gpu gpupkg.GPUSupport | ||||||||||||||||||||||||||||||||||||||||||||||||
| var gpuVariant string | ||||||||||||||||||||||||||||||||||||||||||||||||
| if opts.gpuMode == "auto" { | ||||||||||||||||||||||||||||||||||||||||||||||||
| gpu, err = gpupkg.ProbeGPUSupport(cmd.Context(), dockerClient) | ||||||||||||||||||||||||||||||||||||||||||||||||
| if err != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||
| return fmt.Errorf("unable to probe GPU support: %w", err) | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
| } else if opts.gpuMode == "cuda" { | ||||||||||||||||||||||||||||||||||||||||||||||||
| gpu = gpupkg.GPUSupportCUDA | ||||||||||||||||||||||||||||||||||||||||||||||||
| } else if opts.gpuMode == "rocm" { | ||||||||||||||||||||||||||||||||||||||||||||||||
| gpu = gpupkg.GPUSupportROCm | ||||||||||||||||||||||||||||||||||||||||||||||||
| gpuVariant = "rocm" | ||||||||||||||||||||||||||||||||||||||||||||||||
| } else if opts.gpuMode != "none" { | ||||||||||||||||||||||||||||||||||||||||||||||||
| return fmt.Errorf("unknown GPU specification: %q", opts.gpuMode) | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| // Ensure that we have an up-to-date copy of the image, if requested. | ||||||||||||||||||||||||||||||||||||||||||||||||
| if opts.pullImage { | ||||||||||||||||||||||||||||||||||||||||||||||||
| if err := standalone.EnsureControllerImage(cmd.Context(), dockerClient, gpu, cmd); err != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||
| return fmt.Errorf("unable to pull latest standalone model runner image: %w", err) | ||||||||||||||||||||||||||||||||||||||||||||||||
| if opts.ollama { | ||||||||||||||||||||||||||||||||||||||||||||||||
| if err := standalone.EnsureOllamaImage(cmd.Context(), dockerClient, gpu, gpuVariant, cmd); err != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||
| return fmt.Errorf("unable to pull latest ollama image: %w", err) | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| if err := standalone.EnsureControllerImage(cmd.Context(), dockerClient, gpu, cmd); err != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||
| return fmt.Errorf("unable to pull latest standalone model runner image: %w", err) | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| // Ensure that we have a model storage volume. | ||||||||||||||||||||||||||||||||||||||||||||||||
| modelStorageVolume, err := standalone.EnsureModelStorageVolume(cmd.Context(), dockerClient, cmd) | ||||||||||||||||||||||||||||||||||||||||||||||||
| if err != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||
| return fmt.Errorf("unable to initialize standalone model storage: %w", err) | ||||||||||||||||||||||||||||||||||||||||||||||||
| var modelStorageVolume string | ||||||||||||||||||||||||||||||||||||||||||||||||
| if opts.ollama { | ||||||||||||||||||||||||||||||||||||||||||||||||
| modelStorageVolume, err = standalone.EnsureOllamaStorageVolume(cmd.Context(), dockerClient, cmd) | ||||||||||||||||||||||||||||||||||||||||||||||||
| if err != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||
| return fmt.Errorf("unable to initialize ollama storage: %w", err) | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| modelStorageVolume, err = standalone.EnsureModelStorageVolume(cmd.Context(), dockerClient, cmd) | ||||||||||||||||||||||||||||||||||||||||||||||||
| if err != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||
| return fmt.Errorf("unable to initialize standalone model storage: %w", err) | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| // Create the model runner container. | ||||||||||||||||||||||||||||||||||||||||||||||||
| if err := standalone.CreateControllerContainer(cmd.Context(), dockerClient, port, opts.host, environment, opts.doNotTrack, gpu, modelStorageVolume, cmd, engineKind); err != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||
| return fmt.Errorf("unable to initialize standalone model runner container: %w", err) | ||||||||||||||||||||||||||||||||||||||||||||||||
| if opts.ollama { | ||||||||||||||||||||||||||||||||||||||||||||||||
| if err := standalone.CreateOllamaControllerContainer(cmd.Context(), dockerClient, port, opts.host, environment, opts.doNotTrack, gpu, gpuVariant, modelStorageVolume, cmd, engineKind); err != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||
| return fmt.Errorf("unable to initialize ollama container: %w", err) | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| if err := standalone.CreateControllerContainer(cmd.Context(), dockerClient, port, opts.host, environment, opts.doNotTrack, gpu, modelStorageVolume, cmd, engineKind); err != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||
| return fmt.Errorf("unable to initialize standalone model runner container: %w", err) | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| // Poll until we get a response from the model runner. | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -275,6 +396,7 @@ func newInstallRunner() *cobra.Command { | |||||||||||||||||||||||||||||||||||||||||||||||
| var host string | ||||||||||||||||||||||||||||||||||||||||||||||||
| var gpuMode string | ||||||||||||||||||||||||||||||||||||||||||||||||
| var doNotTrack bool | ||||||||||||||||||||||||||||||||||||||||||||||||
| var ollama bool | ||||||||||||||||||||||||||||||||||||||||||||||||
| c := &cobra.Command{ | ||||||||||||||||||||||||||||||||||||||||||||||||
| Use: "install-runner", | ||||||||||||||||||||||||||||||||||||||||||||||||
| Short: "Install Docker Model Runner (Docker Engine only)", | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -286,14 +408,16 @@ func newInstallRunner() *cobra.Command { | |||||||||||||||||||||||||||||||||||||||||||||||
| doNotTrack: doNotTrack, | ||||||||||||||||||||||||||||||||||||||||||||||||
| pullImage: true, | ||||||||||||||||||||||||||||||||||||||||||||||||
| pruneContainers: false, | ||||||||||||||||||||||||||||||||||||||||||||||||
| ollama: ollama, | ||||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||
| ValidArgsFunction: completion.NoComplete, | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
| c.Flags().Uint16Var(&port, "port", 0, | ||||||||||||||||||||||||||||||||||||||||||||||||
| "Docker container port for Docker Model Runner (default: 12434 for Docker Engine, 12435 for Cloud mode)") | ||||||||||||||||||||||||||||||||||||||||||||||||
| "Docker container port for Docker Model Runner (default: 12434 for Docker Engine, 12435 for Cloud mode, 11434 for ollama)") | ||||||||||||||||||||||||||||||||||||||||||||||||
| c.Flags().StringVar(&host, "host", "127.0.0.1", "Host address to bind Docker Model Runner") | ||||||||||||||||||||||||||||||||||||||||||||||||
| c.Flags().StringVar(&gpuMode, "gpu", "auto", "Specify GPU support (none|auto|cuda)") | ||||||||||||||||||||||||||||||||||||||||||||||||
| c.Flags().StringVar(&gpuMode, "gpu", "auto", "Specify GPU support (none|auto|cuda|rocm)") | ||||||||||||||||||||||||||||||||||||||||||||||||
| c.Flags().BoolVar(&doNotTrack, "do-not-track", false, "Do not track models usage in Docker Model Runner") | ||||||||||||||||||||||||||||||||||||||||||||||||
| c.Flags().BoolVar(&ollama, "ollama", false, "Use ollama runner instead of Docker Model Runner") | ||||||||||||||||||||||||||||||||||||||||||||||||
| return c | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
waitForStandaloneRunnerAfterInstall checks the Desktop model-runner status, not the ollama container, so ollama readiness will likely time out even when the daemon is up. Implement a dedicated readiness check (e.g., try HTTP to http://127.0.0.1:11434/api/tags or poll the container state) and use it here instead.