This is an automated email from the ASF dual-hosted git repository.

junrushao pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm.git


The following commit(s) were added to refs/heads/main by this push:
     new ea388e5e74 [CI] Allow Limit CPUs in Docker (#15668)
ea388e5e74 is described below

commit ea388e5e747bd16de11b58db59c4b9285361fc41
Author: Junru Shao <[email protected]>
AuthorDate: Tue Sep 5 22:21:27 2023 -0700

    [CI] Allow Limit CPUs in Docker (#15668)
    
    This PR adds a new flag `--cpus` in `./docker/bash.sh`, which is passed
    to docker command that allows limiting the number of CPU cores of a
    docker container.
    
    Related materials: 
https://docs.docker.com/config/containers/resource_constraints/#configure-the-default-cfs-scheduler
---
 docker/bash.sh | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/docker/bash.sh b/docker/bash.sh
index b04270d0a8..a5dec23f91 100755
--- a/docker/bash.sh
+++ b/docker/bash.sh
@@ -38,9 +38,11 @@ set -euo pipefail
 function show_usage() {
     cat <<EOF
 Usage: docker/bash.sh [-i|--interactive] [--net=host] [-t|--tty]
-         [--mount MOUNT_DIR] [--repo-mount-point REPO_MOUNT_POINT]
-         [--dry-run] [--name NAME]
-         <DOCKER_IMAGE_NAME> [--] [COMMAND]
+          [--cpus NUM_CPUS] [--mount MOUNT_DIR]
+          [--repo-mount-point REPO_MOUNT_POINT]
+          [--dry-run] [--name NAME]
+          <DOCKER_IMAGE_NAME> [--] [COMMAND]
+
 
 -h, --help
 
@@ -54,6 +56,10 @@ Usage: docker/bash.sh [-i|--interactive] [--net=host] 
[-t|--tty]
 
     Start the docker session with a pseudo terminal (tty).
 
+--cpus NUM_CPUS
+
+    Limit the number of CPU cores to be used.
+
 --net=host
 
     Expose servers run into the container to the host, passing the
@@ -184,6 +190,11 @@ while (( $# )); do
             eval $break_joined_flag
             ;;
 
+        --cpus)
+            DOCKER_FLAGS+=(--cpus "$2")
+            shift 2
+            ;;
+
         --net=host)
             USE_NET_HOST=true
             shift

Reply via email to