From d8ce82cf44acf0fc82f5c85b385dd7be3fbe8a33 Mon Sep 17 00:00:00 2001 From: Cyril Diagne Date: Wed, 23 Oct 2019 19:07:06 +0200 Subject: [PATCH] remove dev command --- cmd/dev-start.go | 95 ---------------- cmd/dev-stop.go | 50 --------- cmd/dev.go | 33 ------ docs/contribute/development.md | 5 +- docs/kuda/cli.md | 34 +++--- docs/kuda/getting_started.md | 9 ++ docs/kuda/remote_development.md | 78 -------------- docs/summary.md | 5 +- providers/aws/VERSION | 2 +- providers/gcp/Dockerfile | 2 - providers/gcp/VERSION | 2 +- providers/gcp/dev_start.sh | 186 -------------------------------- providers/gcp/dev_stop.sh | 23 ---- 13 files changed, 28 insertions(+), 496 deletions(-) delete mode 100644 cmd/dev-start.go delete mode 100644 cmd/dev-stop.go delete mode 100644 cmd/dev.go delete mode 100644 docs/kuda/remote_development.md delete mode 100755 providers/gcp/dev_start.sh delete mode 100755 providers/gcp/dev_stop.sh diff --git a/cmd/dev-start.go b/cmd/dev-start.go deleted file mode 100644 index 7c37247..0000000 --- a/cmd/dev-start.go +++ /dev/null @@ -1,95 +0,0 @@ -/* -Package cmd - - -Copyright © 2019 Cyril Diagne . - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -package cmd - -import ( - "bufio" - "fmt" - "os" - "path/filepath" - - "github.com/cyrildiagne/kuda/pkg/docker" - "github.com/spf13/cobra" - "github.com/spf13/viper" -) - -// startCmd represents the `dev start` command -var startCmd = &cobra.Command{ - Use: "start [docker-image] [dir]", - Short: "Start a dev session.", - Long: "Start a dev session using the provider docker image.", - Args: cobra.MinimumNArgs(1), - Run: func(cmd *cobra.Command, args []string) { - // Set current working directory from 2nd argument if provided otherwise - // use the current working directory. - dir := "" - if len(args) > 1 { - argDir, err := filepath.Abs(args[1]) - if err != nil { - panic(err) - } - dir = argDir - } else { - cwd, err := os.Getwd() - if err != nil { - panic(err) - } - dir = cwd - } - - if err := start(args[0], dir); err != nil { - fmt.Println("ERROR:", err) - } - }, -} - -func init() { - devCmd.AddCommand(startCmd) -} - -func start(devImage string, folderMount string) error { - fmt.Println("→ Starting a remote session...") - // Image to run. - image := viper.GetString("image") - // Command to run. - command := []string{"kuda_dev_start", devImage} - - // Add the CWD to the volumes mounted in Docker. - volumes := []string{folderMount + ":/app_home"} - - // Run the command. - dockerErr := RunDockerWithEnvs(docker.CommandOption{ - Image: image, - Command: command, - AppendVolumes: volumes, - }) - if dockerErr != nil { - fmt.Println(dockerErr) - } - - // Ask if we should stop the session. - fmt.Print("Do you want to delete the remote session? (y/n) ") - scanner := bufio.NewScanner(os.Stdin) - scanner.Scan() - txt := scanner.Text() - if txt == "y" { - Stop() - } - - return nil -} diff --git a/cmd/dev-stop.go b/cmd/dev-stop.go deleted file mode 100644 index a1eec67..0000000 --- a/cmd/dev-stop.go +++ /dev/null @@ -1,50 +0,0 @@ -/* -Package cmd - - -Copyright © 2019 Cyril Diagne . - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -package cmd - -import ( - "github.com/cyrildiagne/kuda/pkg/docker" - "github.com/spf13/cobra" - "github.com/spf13/viper" -) - -// stopCmd represents the `dev stop` command -var stopCmd = &cobra.Command{ - Use: "stop", - Short: "Stop a dev session.", - Long: "Stop a dev session.", - Run: func(cmd *cobra.Command, args []string) { - Stop() - }, -} - -func init() { - devCmd.AddCommand(stopCmd) -} - -// Stop the remote session. -func Stop() error { - // color.Cyan("→ Stopping the remote session...") - // Image to run. - image := viper.GetString("image") - // Command to run. - command := []string{"kuda_dev_stop"} - // Run - err := RunDockerWithEnvs(docker.CommandOption{Image: image, Command: command}) - return err -} diff --git a/cmd/dev.go b/cmd/dev.go deleted file mode 100644 index ee55787..0000000 --- a/cmd/dev.go +++ /dev/null @@ -1,33 +0,0 @@ -/* -Package cmd - - -Copyright © 2019 Cyril Diagne . - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -package cmd - -import ( - "github.com/spf13/cobra" -) - -// devCmd represents the dev command -var devCmd = &cobra.Command{ - Use: "dev", - Short: "Manage dev sessions.", - Long: "Manage dev sessions.", -} - -func init() { - RootCmd.AddCommand(devCmd) -} diff --git a/docs/contribute/development.md b/docs/contribute/development.md index 15869f2..75bad8d 100644 --- a/docs/contribute/development.md +++ b/docs/contribute/development.md @@ -18,11 +18,8 @@ kuda_setup kuda_delete kuda_get -# Remote Dev Session -kuda_dev_start -kuda_dev_stop - # App +kuda_app_dev kuda_app_deploy kuda_app_delete ``` diff --git a/docs/kuda/cli.md b/docs/kuda/cli.md index 57cab3f..219357b 100644 --- a/docs/kuda/cli.md +++ b/docs/kuda/cli.md @@ -27,42 +27,34 @@ kuda delete Deletes the remote cluster. -## DEV +## APP -### → Start +### → Dev ```bash -kuda dev start [base-image] +kuda app dev ``` -Starts a remote dev session with the current working directory. - -**Example:** `kuda dev start nvidia/cuda:10.1-base` - -This command: - -- Provisions a node with GPU on the cluster & install the nvidia driver -- Starts a development pod based on the Deep Learning VM -- Synchronise the directory provided as parameter with the remote node +Example: `kuda app dev my-app` -You can find a list of suggested `base-image` in the [remote development](remote_development.md) documentation. +Starts the application in dev mode. -### → Stop +### → Deploy ```bash -kuda dev stop +kuda app deploy ``` -Stops the remote dev session. +Example: `kuda app deploy my-app:1.0.0` -## APP +Deploys the application as serverless API. -### → Deploy +### → Delete ```bash -kuda app deploy +kuda app delete ``` -Example: `kuda app deploy my-app:1.0.0` +Example: `kuda app delete my-app` -Deploys the application as serverless API. +Deletes the application from the cluster and container image from the registry. diff --git a/docs/kuda/getting_started.md b/docs/kuda/getting_started.md index de05858..a9e9613 100644 --- a/docs/kuda/getting_started.md +++ b/docs/kuda/getting_started.md @@ -39,6 +39,7 @@ to be allocated. You can then query your application using any program able to make an HTTP request. Here is an example using cURL: + ```bash curl -i -H "Host: my-hello-gpu.default.example.com" http:// ``` @@ -70,6 +71,14 @@ The first call might need to spawn an instance which could take while. Subsequen ## 5 - Cleanup +### • Delete the app + +To delete the app (the image on the registry and the knative service): + +```bash +kuda app delete hello-world +``` + ### • Delete the cluster The GPU nodes are setup to autoscale down to 0 when they're not in use. However, the system node will still incur charges on GCP. diff --git a/docs/kuda/remote_development.md b/docs/kuda/remote_development.md deleted file mode 100644 index 9e044b8..0000000 --- a/docs/kuda/remote_development.md +++ /dev/null @@ -1,78 +0,0 @@ -# Remote Development - -**⚠️ Remote development and this guide are still WIP. Following this guide probably won't work for now.** - -This guide will walk you through the process of developping remotely on the Kubernetes cluster. - -Make sure you have a cluster running with Kuda's dependencies. - -## 1 - Introduction - -Remote dev sessions work like a virtual machine running in you kubernetes cluster that will use [Ksync](https://github.com/vapor-ware/ksync/) to synchronize the local folder on your workstation. So you can code from any machine with your favorite IDE while running the workloads on powerful remote GPUs. - -Developping on remote sessions offers many other advantages such as: - -- Elastic resources - Scale up and down the hardware for the current task. -- Datacenter-fast internet - Download large datasets _much_ faster. -- Contained environment per project - No more conflict between librairies, CUDA or python version..etc. - -## 2 - Start a Remote Dev Session - -First clone the kuda-apps repository and navigate to the `hello-gpu` example. -```bash -git clone https://github.com/cyrildiagne/kuda-apps -cd hello-gpu -``` - -Start a remote dev session that will be provisioned on your cluster. - -```bash -kuda dev start gcr.io/deeplearning-platform-release/base-cu100 -``` - -`gcr.io/deeplearning-platform-release/base-cu100` Is the docker image to use as base. This image is convenient if you're using Kuda for deep learning since it packages most of the softwares needed in the deeplearning development cycle. It also allows you to specify which version of CUDA and CuDNN you need. - -This command will start the remote session and synchronize the CWD \(current working directory\) with the remote instance. - -Upon started, it will also print the cluster's IP address / port to use later on. Make not of that as we'll refer to it later as `` - -List of recommended `base-image`: - -- all images from [nvidia/cuda](https://hub.docker.com/r/nvidia/cuda/). These images are fairly lightweight but python must be installed manually. -- gcloud's [Deep Learning containers](https://cloud.google.com/ai-platform/deep-learning-containers/docs/choosing-container) - -→ For more information on the `kuda dev start` command, check the [reference](https://docs.kuda.dev/kuda/cli#dev). - -## • Retrieve & initialize an example application - -The next command should be ran in the remote shell that's started. - -Install the example dependencies. Because the remote dev session is short lived, you don't need to create a virtualenv: - -```bash -root@kuda-dev: pip install -r requirements.txt -``` - -## • Run and Test the example - -Then start the example in dev mode. It will reload automatically when you make changes from your local machine: - -```bash -root@kuda-dev: python app.py -``` - -Open `http:///101` in a web browser. You should see the result of the `nvidia-smi` command which gives some details about the GPU. - -You can make a change to the code of the example on your local workstation and the application will restart automatically after the code has synched. - -## 3 - Cleanup - -### • Stop the remote dev session - -From the remote shell that's opened after you've run `kuda dev start`, simply enter: - -```bash -root@kuda-dev: exit -``` - -This will automatically call `kuda dev stop` and shut down the remote session. diff --git a/docs/summary.md b/docs/summary.md index 1a7c500..736d80a 100644 --- a/docs/summary.md +++ b/docs/summary.md @@ -6,14 +6,15 @@ - [Install](kuda/install.md) - [Getting Started](kuda/getting_started.md) -- [Remote Development](kuda/remote_development.md) -- [Reference](kuda/cli.md) +- [CLI Reference](kuda/cli.md) - [Examples](https://github.com/cyrildiagne/kuda-apps) ## Providers - [GCP](../providers/gcp/README.md) - [AWS (WIP)](../providers/aws/README.md) +- Azure (Soon) +- NGC (Soon) ## Contribute diff --git a/providers/aws/VERSION b/providers/aws/VERSION index 6c6aa7c..359a5b9 100644 --- a/providers/aws/VERSION +++ b/providers/aws/VERSION @@ -1 +1 @@ -0.1.0 \ No newline at end of file +2.0.0 \ No newline at end of file diff --git a/providers/gcp/Dockerfile b/providers/gcp/Dockerfile index 8bb81ec..10e0e4f 100644 --- a/providers/gcp/Dockerfile +++ b/providers/gcp/Dockerfile @@ -42,8 +42,6 @@ RUN ln -s /kuda_cmd/app_deploy.sh /usr/local/bin/kuda_app_deploy && \ ln -s /kuda_cmd/app_delete.sh /usr/local/bin/kuda_app_delete && \ ln -s /kuda_cmd/setup.sh /usr/local/bin/kuda_setup && \ ln -s /kuda_cmd/delete.sh /usr/local/bin/kuda_delete && \ - ln -s /kuda_cmd/dev_start.sh /usr/local/bin/kuda_dev_start && \ - ln -s /kuda_cmd/dev_stop.sh /usr/local/bin/kuda_dev_stop && \ ln -s /kuda_cmd/get.sh /usr/local/bin/kuda_get # Go to the app home. diff --git a/providers/gcp/VERSION b/providers/gcp/VERSION index 867e524..359a5b9 100644 --- a/providers/gcp/VERSION +++ b/providers/gcp/VERSION @@ -1 +1 @@ -1.2.0 \ No newline at end of file +2.0.0 \ No newline at end of file diff --git a/providers/gcp/dev_start.sh b/providers/gcp/dev_start.sh deleted file mode 100755 index 776d97e..0000000 --- a/providers/gcp/dev_start.sh +++ /dev/null @@ -1,186 +0,0 @@ -#!/bin/bash - -set -e - -source $KUDA_CMD_DIR/.config.sh - -# Get cluster's credentials to use kubectl. -gcloud container clusters get-credentials $KUDA_GCP_CLUSTER_NAME - -# TODO: Increase the number of GPU nodes by 1 to speed up initialization. -# gcloud container clusters resize $KUDA_GCP_CLUSTER_NAME \ -# --node-pool $KUDA_GCP_GPU \ -# --num-nodes 1 \ -# --quiet - -# uid=$(head /dev/urandom | tr -dc a-z0-9 | head -c 7) -# dev_app_name=$KUDA_DEV_APP_NAME-$uid -dev_app_name=$KUDA_DEV_APP_NAME -dev_image=$1 - -# Launch. -# TODO: materialize as external yaml file and customize -# with Kustomize -cat < Not mandatory -# since the autoscaler will automatically scale down to 0 after a while. -# gcloud container clusters resize $KUDA_GCP_CLUSTER_NAME \ -# --node-pool $KUDA_GCP_GPU \ -# --num-nodes 0 \ -# --quiet \ No newline at end of file