Skip to main content

ClearML 代理命令行界面

以下页面提供了对clearml-agent的CLI命令的参考:

  • build - 创建一个工作环境而不执行实验。
  • config - 列出您的ClearML代理配置数据。
  • daemon - 运行一个工作守护进程,监听队列以执行任务(实验)。
  • execute - 在本地执行一个实验,无需队列。
  • list - 列出当前的工作者。

构建

使用build命令创建工作者环境而不执行任务。

您可以根据特定任务的执行环境构建Docker容器,代理稍后可以使用这些容器来执行其他任务。请参阅教程

您还可以创建一个在启动时执行特定任务的Docker容器。请参阅教程

clearml-agent build [-h] --id TASK_ID [--target TARGET]
[--install-globally]
[--docker [DOCKER [DOCKER ...]]] [--force-docker]
[--python-version PYTHON_VERSION]
[--entry-point {reuse_task,clone_task}] [-O]
[--git-user GIT_USER] [--git-pass GIT_PASS]
[--log-level {DEBUG,INFO,WARN,WARNING,ERROR,CRITICAL}]
[--gpus GPUS] [--cpu-only]

参数

NameDescriptionOptional
--idBuild a worker environment for this Task ID.No
--cpu-onlyDisable GPU access for the Docker container.Yes
--dockerRun agent in Docker mode. Specify a Docker container that a worker will execute at launch. To specify the image name and optional arguments, use one of the following:
  • --docker 在命令行上
  • --docker 在命令行上,并在配置文件中指定默认的镜像名称和参数。
Environment variable settings for Docker containers:
  • CLEARML_DOCKER_SKIP_GPUS_FLAG - 忽略Docker容器内的--gpus标志。这也允许你在19.03之前的Docker版本中执行ClearML Agent。
  • NVIDIA_VISIBLE_DEVICES - 限制Docker容器的GPU可见性。
  • CLEARML_AGENT_GIT_USERCLEARML_AGENT_GIT_PASS - 在执行时将凭据传递给 Docker 容器。
To limit GPU visibility for Docker, set the NVIDIA_VISIBLE_DEVICES environment variable.
Yes
--entry-pointUsed in conjunction with --docker, indicates how to run the Task specified by --task-id on Docker startup. The --entry-point options are:
  • reuse - 覆盖现有的任务数据。
  • clone_task - 克隆任务,并执行克隆的任务。
Yes
--force-dockerForce using the agent-specified docker image (either explicitly in the --docker argument or using the agent's default docker image). If provided, the agent will not use any docker container information stored in the task itself (default False)Yes
--git-passGit password for repository access.Yes
--git-userGit username for repository access.Yes
--gpusSpecify the active GPUs for the Docker containers to use. These are the same GPUs set in the NVIDIA_VISIBLE_DEVICES environment variable. For example:
  • --gpus 0
  • --gpu 0,1,2
  • --gpus all
Yes
-h, --helpGet help for this command.Yes
--install-globallyInstall the required Python packages before creating the virtual environment. Use agent.package_manager.system_site_packages to control the installation of the system packages. When --docker is used, --install-globally is always true.Yes
--log-levelSDK log level. The values are:
  • DEBUG
  • INFO
  • WARN
  • WARNING
  • ERROR
  • CRITICAL
Yes
--python-versionVirtual environment Python version to use.Yes
-OCompile optimized pyc code (see python documentation). Repeat for more optimization.Yes
--targetThe target folder for the virtual environment and source code that will be used at launch.Yes

配置

列出您的ClearML代理配置。

clearml-agent config [-h]

守护进程

使用daemon命令在任何机器上启动一个代理:无论是在本地还是云实例上。当启动代理时,为其分配一个或多个队列来服务,当实验被添加到其队列中时,代理将拉取并执行它们。

使用daemon命令,您可以配置代理的行为:分配资源、优先处理队列、设置它在Docker中运行等。

clearml-agent daemon [-h] [--foreground] [--queue QUEUES [QUEUES ...]] [--order-fairness] 
[--standalone-mode] [--services-mode [SERVICES_MODE]]
[--child-report-tags CHILD_REPORT_TAGS [CHILD_REPORT_TAGS ...]]
[--create-queue] [--detached] [--stop] [--dynamic-gpus]
[--uptime [UPTIME [UPTIME ...]]] [--downtime [DOWNTIME [DOWNTIME ...]]]
[--status] [--use-owner-token] [-O]
[--git-user GIT_USER] [--git-pass GIT_PASS]
[--log-level {DEBUG,INFO,WARN,WARNING,ERROR,CRITICAL}]
[--gpus GPUS] [--cpu-only]
[--docker [DOCKER [DOCKER ...]]] [--force-current-version]

参数

NameDescriptionOptional
--child-report-tagsList of tags to send with the status reports from the worker that executes a task.Yes
--cpu-onlyIf running in Docker mode (see the --docker option), disable GPU access for the Docker container or virtual environment.Yes
--create-queueIf the queue name provided with --queue does not exist in the server, create it on-the-fly and use it.Yes
--detachedRun agent in the background. The clearml-agent command returns immediately.Yes
--dockerRun in Docker mode. Execute the Task inside a Docker container. To specify the image name and optional arguments, either:
  • 在命令行中使用 --docker ,或者
  • 在命令行中使用 --docker,并在配置文件中指定默认的镜像名称和参数。
Environment variable settings for Docker containers:
  • CLEARML_DOCKER_SKIP_GPUS_FLAG - 忽略Docker容器内的--gpus标志。这也允许你在19.03之前的Docker版本中执行ClearML Agent。
  • NVIDIA_VISIBLE_DEVICES - 限制Docker容器的GPU可见性。
  • CLEARML_AGENT_GIT_USERCLEARML_AGENT_GIT_PASS - 在执行时将凭据传递给 Docker 容器。
Yes
--downtimeSpecify downtime for clearml-agent in <hours> <days> format. For example, use 09-13 TUE to set Tuesday's downtime to 09-13.

NOTES:
  • 此功能在ClearML企业版计划下可用
  • 确保只配置--uptime--downtime,但不要同时配置两者。
Yes
--dynamic-gpusAllow to dynamically allocate GPUs based on queue properties, configure with --queue <queue_name>=<num_gpus>. For example: --dynamic-gpus --queue dual_gpus=2 single_gpu=1

NOTE: This feature is available under the ClearML Enterprise plan
Yes
--force-current-versionTo use your current version of ClearML Agent when running in Docker mode (the --docker argument is specified), instead of the latest ClearML Agent version which is automatically installed, specify force-current-version.

For example, if your current ClearML Agent version is 0.13.1, but the latest version of ClearML Agent is 0.13.3, use --force-current-version and your Task will execute in the Docker container with ClearML Agent version 0.13.1.
Yes
--foregroundPipe full log to stdout/stderr. Do not use this option if running in background.Yes
--git-passGit password for repository access.Yes
--git-userGit username for repository accessYes
--gpusIf running in Docker mode (see the --docker option), specify the active GPUs for the Docker containers to use. These are the same GPUs set in the NVIDIA_VISIBLE_DEVICES environment variable. For example:
  • --gpus 0
  • --gpu 0,1,2
  • --gpus all
Yes
-h, --helpGet help for this command.Yes
--log-levelSDK log level. The values are:
  • DEBUG
  • INFO
  • WARN
  • WARNING
  • ERROR
  • CRITICAL
Yes
-OCompile optimized pyc code (see python documentation). Repeat for more optimization.Yes
--order-fairnessPull from each queue in a round-robin order, instead of priority order.Yes
--queueSpecify the queues which the worker is listening to. The values can be any combination of:
  • 一个或多个队列ID
  • 一个或多个队列名称
  • default 表示默认队列
Yes
--services-modeLaunch multiple long-term docker services. Spin multiple, simultaneous Tasks, each in its own Docker container, on the same machine. Each Task will be registered as a new node in the system, providing tracking and transparency capabilities. Start up and shutdown of each Docker is verified. Use in CPU mode (--cpu-only) only.
To limit the number of simultaneous tasks run in services mode, pass the maximum number immediately after the --services-mode option (e.g. --services-mode 5)
Yes
--standalone-modeDo not use any network connects. This assumes all requirements are pre-installed.Yes
--statusPrint the worker's schedule (uptime properties, server's runtime properties and listening queues)Yes
--stopTerminate a running ClearML Agent, if other arguments are the same. If no additional arguments are provided, agents are terminated in lexicographical order.Yes
--uptimeSpecify uptime for clearml-agent in <hours> <days> format. For example, use 17-20 TUE to set Tuesday's uptime to 17-20.

NOTES:
  • 此功能在ClearML企业版计划下可用
  • 确保只配置--uptime--downtime,但不要同时配置两者。
Yes
--use-owner-tokenGenerate and use the task owner's token for the execution of the task.Yes

执行

使用execute命令设置代理直接构建和执行特定任务,而无需监听队列。

clearml-agent execute [-h] --id TASK_ID [--log-file LOG_FILE] [--disable-monitoring] 
[--full-monitoring] [--require-queue]
[--standalone-mode] [--docker [DOCKER [DOCKER ...]]] [--clone]
[-O] [--git-user GIT_USER] [--git-pass GIT_PASS]
[--log-level {DEBUG,INFO,WARN,WARNING,ERROR,CRITICAL}]
[--gpus GPUS] [--cpu-only]

参数

NameDescriptionOptional
--idThe ID of the Task to buildNo
--cloneClone the Task specified by --id, and then execute that cloned Task.Yes
--cpu-onlyDisable GPU access for the daemon, only use CPU in either docker or virtual environment.Yes
--dockerRun in Docker mode. Execute the Task inside a Docker container. To specify the image name and optional arguments, use one of the following:
  • --docker 在命令行上
  • --docker 在命令行上,并在配置文件中指定默认的镜像名称和参数。
Environment variable settings for Dockers containers:
  • CLEARML_DOCKER_SKIP_GPUS_FLAG - 忽略Docker容器内的--gpus标志。这也允许你在19.03之前的Docker版本中执行ClearML Agent。
  • NVIDIA_VISIBLE_DEVICES - 限制Docker容器的GPU可见性。
  • CLEARML_AGENT_GIT_USERCLEARML_AGENT_GIT_PASS - 在执行时将凭据传递给 Docker 容器。
Yes
--disable-monitoringDisable logging and monitoring, except for stdout.Yes
--full-monitoringCreate a full log, including the environment setup log, Task log, and monitoring, as well as stdout.Yes
--git-passGit password for repository access.Yes
--git-userGit username for repository access.Yes
--gpusSpecify active GPUs for the daemon to use (docker / virtual environment). Equivalent to setting NVIDIA_VISIBLE_DEVICES. For example:
  • --gpus 0
  • --gpu 0,1,2
  • --gpus all
Yes
-h, --helpGet help for this command.Yes
--log-fileThe log file for Task execution output (stdout / stderr) to a text file.Yes
--log-levelSDK log level. The values are:
  • DEBUG
  • INFO
  • WARN
  • WARNING
  • ERROR
  • CRITICAL
Yes
-OCompile optimized pyc code (see python documentation). Repeat for more optimization.Yes
--require-queueIf the specified task is not queued, the execution will fail (used for 3rd party scheduler integration, e.g. K8s, SLURM, etc.)Yes
--standalone-modeDo not use any network connects, assume everything is pre-installedYes

列表

列出所有活跃工作人员的信息。

clearml-agent list [-h]