Installing and Configuring Your ClearML Agent¶
Install ClearML Agent and configure it using the ClearML Agent setup wizard. If you previously configured ClearML for ClearML Server, then a configuration file may exist; if one does exist, add ClearML Agent configuration settings to it.
The configuration file is clearml.conf
. The GitHub clearml
repository contains an example configuration file.
Once installed, ClearML Agent uses a cache folder to cache pip packages, apt packages, and cloned repositories. The default cache folder in Linux is ~/.clearml
.
To install and configure ClearML Agent:
Install ClearML Agent.
pip install clearml-agent
In a terminal session, run the setup wizard.
clearml-agent init
The setup wizard prompts for your ClearML credentials.
CLEARML-AGENT setup process Please create new clearml credentials through the profile page in your clearml web app (e.g., https://demoapp.demo.clear.ml/profile) In the profile page, press "Create new credentials", then press "Copy to clipboard". Paste copied configuration here:
If the setup wizard’s response indicates you already have a configuration file, follow the instructions in here. The wizard does not edit or overwrite existing configuration files.
Get your ClearML credentials. Open the ClearML Web UI in your browser. On the PROFILE page, click Create new credentials > Copy to clipboard.
At the command prompt
Paste copied configuration here:
, copy and paste the ClearML credentials and press Enter. The setup wizard confirms the credentials.Detected credentials key="********************" secret="*******"
Enter the ClearML Server web server URL, or press Enter to accept the default which is detected from your credentials.
You must use a secure protocol, https. Do not use http.
WEB Host configured to: [https://app.community.clear.ml]
Note
If you are using a self-host ClearML Server, the default URL will use your domain.
Enter the ClearML Server API server URL, or press Enter to accept the default value which is based on your previous response:
API Host configured to: [https://demoapi.clearml.allegro.ai]
Enter the ClearML Server file server URL, or press Enter to accept the default value which is based on your previous response:
File Store Host configured to: [https://demofiles.clearml.allegro.ai]
The wizard responds with your configuration and directs you to your ClearML Server.
CLEARML Hosts configuration: Web App: https://app.community.clear.ml API: https://demoapi.clearml.allegro.ai File Store: https://demofiles.clearml.allegro.ai Verifying credentials ... Credentials verified!
Enter your Git user name and password. Leave blank for SSH key authentication.
Enter git username for repository cloning (leave blank for SSH key authentication): [] Enter password for user '<username>':
The setup wizard confirms your git credentials.
Git repository cloning will be using user=<username> password=<password>
Enter an additional artifact repository, or press Enter if not required.
Enter additional artifact repository (extra-index-url) to use when installing python packages (leave blank if not required):
The setup wizard completes.
New configuration stored in /home/<username>/clearml.conf CLEARML-AGENT setup completed successfully.
The configuration file location depends upon your operating system:
Linux -
~/clearml.conf
Mac -
$HOME/clearml.conf
Windows -
\User\<username>\clearml.conf
Optionally, configure ClearML options for ClearML Agent (for example, the default docker, package manager), see the ClearML Configuration Reference.
Adding ClearML Agent to a configuration file¶
The setup wizard may indicate that you already have a configuration file. For example, if you previously configured ClearML for a self-hosted ClearML Server, you created a configuration file. The wizard does not edit or overwrite existing configuration files.
To add ClearML Agent to a ClearML configuration file:
Open your ClearML configuration file for editing. Depending upon your operating system, it is:
Linux -
~/clearml.conf
Mac -
$HOME/clearml.conf
Windows -
\User\<username>\clearml.conf
After the
api
section, add the following for your Git credentials, and an additional artifact repository.# Set GIT user/pass credentials # leave blank for GIT SSH credentials agent.git_user="<git_username>" agent.git_pass="<git_password>" # extra_index_url: ["https://allegroai.jfrog.io/clearmlai/api/pypi/public/simple"] agent.package_manager.extra_index_url= [ ]
After the Git credentials (see the previous step), add the following
agent
section:agent { # unique name of this worker, if None, created based on hostname:process_id # Override with os environment: CLEARML_WORKER_ID # worker_id: "clearml-agent-machine1:gpu0" worker_id: "" # worker name, replaces the hostname when creating a unique name for this worker # Override with os environment: CLEARML_WORKER_NAME # worker_name: "clearml-agent-machine1" worker_name: "" # Set GIT user/pass credentials (if user/pass are set, GIT protocol will be set to https) # leave blank for GIT SSH credentials (set force_git_ssh_protocol=true to force SSH protocol) # git_user: "" # git_pass: "" # Force GIT protocol to use SSH regardless of the git url (Assumes GIT user/pass are blank) force_git_ssh_protocol: false # Set the python version to use when creating the virtual environment and launching the experiment # Example values: "/usr/bin/python3" or "/usr/local/bin/python3.6" # The default is the python executing the clearml_agent python_binary: "" # select python package manager: # currently supported pip and conda # poetry is used if pip selected and repository contains poetry.lock file package_manager: { # supported options: pip, conda, poetry type: pip, # specify pip version to use (examples "<20", "==19.3.1", "", empty string will install the latest version) pip_version: "<20.2", # virtual environment inheres packages from system system_site_packages: false, # install with --upgrade force_upgrade: false, # additional artifact repositories to use when installing python packages # extra_index_url: ["https://allegroai.jfrog.io/clearmlai/api/pypi/public/simple"] # additional conda channels to use when installing with conda package manager conda_channels: ["defaults", "conda-forge", "pytorch", ] # set to True to support torch nightly build installation, # notice: torch nightly builds are ephemeral and are deleted from time to time torch_nightly: false, }, # target folder for virtual environments builds, created when executing experiment venvs_dir = ~/.clearml/venvs-builds # cached git clone folder vcs_cache: { enabled: true, path: ~/.clearml/vcs-cache }, # use venv-update in order to accelerate python virtual environment building # Still in beta, turned off by default venv_update: { enabled: false, }, # cached folder for specific python package download (used for pytorch package caching) pip_download_cache { enabled: true, path: ~/.clearml/pip-download-cache }, translate_ssh: true, # reload configuration file every daemon execution reload_config: false, # pip cache folder mapped into docker, used for python package caching docker_pip_cache = ~/.clearml/pip-cache # apt cache folder mapped into docker, used for ubuntu package caching docker_apt_cache = ~/.clearml/apt-cache # optional arguments to pass to docker image # these are local for this agent and will not be updated in the experiment's docker_cmd section # extra_docker_arguments: ["--ipc=host", ] # optional shell script to run in docker when started before the experiment is started # extra_docker_shell_script: ["apt-get install -y bindfs", ] # set to true in order to force "docker pull" before running an experiment using a docker image. # This makes sure the docker image is updated. docker_force_pull: false default_docker: { # default docker image to use when running in docker mode image: "nvidia/cuda:10.1-runtime-ubuntu18.04" # optional arguments to pass to docker image # arguments: ["--ipc=host", ] } # set the initial bash script to execute at the startup of any docker. # all lines will be executed regardless of their exit code. # {python_single_digit} is translated to 'python3' or 'python2' according to requested python version # docker_init_bash_script = [ # "echo 'Binary::apt::APT::Keep-Downloaded-Packages \"true\";' > /etc/apt/apt.conf.d/docker-clean", # "chown -R root /root/.cache/pip", # "apt-get update", # "apt-get install -y git libsm6 libxext6 libxrender-dev libglib2.0-0", # "(which {python_single_digit} && {python_single_digit} -m pip --version) || apt-get install -y {python_single_digit}-pip", # ] # cuda versions used for solving pytorch wheel packages # should be detected automatically. Override with os environment CUDA_VERSION / CUDNN_VERSION # cuda_version: 10.1 # cudnn_version: 7.6 }
In the
sdk.storage.cache
section, add thesize
.size { # max_used_bytes = -1 min_free_bytes = 10GB # cleanup_margin_percent = 5% }
For example:
sdk { # CLEARML - default SDK configuration storage { cache { # Defaults to system temp folder / cache default_base_dir: "~/.clearml/cache" size { # max_used_bytes = -1 min_free_bytes = 10GB # cleanup_margin_percent = 5% } }
Save your configuration.