
AWS SageMaker is Amazon's cloud-native machine learning platform that provides notebooks, training jobs, pipelines, a model registry, and model endpoints as hosted services within the AWS ecosystem. It abstracts infrastructure management but ties teams to AWS-specific APIs, per-instance compute billing, and Amazon's tooling.
ClearML is an open-source MLOps platform that replaces SageMaker's managed services with self-hosted components deployable on any cloud or on-premises hardware. It eliminates per-minute compute charges, removes AWS API dependencies, and automatically captures metrics, hyperparameters, and artifacts from existing training code without modification.
This article explains how to deploy ClearML Server using Docker Compose with Traefik as a reverse proxy, configure agents for remote execution, and run machine learning workflows. It covers experiment tracking, pipeline creation, hyperparameter optimization, model serving with Triton, and migration strategies from AWS SageMaker.
ClearML maps directly to AWS SageMaker components, providing equivalent functionality through a self-hosted, cloud-agnostic platform.
The ClearML architecture consists of:
Before you begin, you need to:
app.clearml.example.com (Web UI), api.clearml.example.com (API server), and files.clearml.example.com (file server).The ClearML Server does not require a GPU instance. Deploy ClearML Agents on GPU-enabled instances to handle compute-intensive training tasks.
ClearML Server runs as a multi-container application with Elasticsearch for indexing, MongoDB for metadata, and Redis for caching. Traefik handles HTTPS termination and routes traffic to the appropriate service.
Increase the virtual memory limit for Elasticsearch.
Apply the sysctl configuration.
Restart the Docker service to apply memory changes.
Create the directory structure for persistent storage.
data/elastic_7: Elasticsearch index storagedata/mongo_4: MongoDB database filesdata/redis: Redis cache persistencedata/fileserver: Uploaded artifacts and modelslogs: Service log filesconfig: Configuration filesSet ownership to match the container user IDs.
Create the project directory.
Navigate to the project directory.
Download the official ClearML Docker Compose file.
Open the Docker Compose file to modify port mappings and network configuration.
Locate each ports: block under the apiserver, webserver, and fileserver services and comment them out by adding # at the beginning of each line. Traefik handles external routing, so direct port exposure is not needed.
Locate the networks block at the bottom of the file and update it to use named bridge networks:
Save and close the file.
Create the environment file for ClearML service URLs. Replace clearml.example.com with your domain.
Add the following configuration:
Save and close the file.
Start the ClearML services.
Verify all containers are running.
The output displays containers for clearml-webserver, clearml-apiserver, clearml-fileserver, clearml-mongo, clearml-elastic, and clearml-redis.
Check the logs for startup errors.
For more information on managing Docker Compose stacks, see the How To Use Docker Compose article.
Traefik routes HTTPS traffic to ClearML services using subdomain-based routing. Each ClearML component receives a dedicated subdomain with automatic Let's Encrypt certificate management.
Create the Traefik directory.
Navigate to the Traefik directory.
Create the Let's Encrypt storage directory.
Create the certificate storage file.
Restrict the file permissions so only the owner can read and write it. Let's Encrypt requires this permission level before it writes any certificate data.
Create the Traefik environment file. Replace admin@example.com with your email address for Let's Encrypt notifications.
Add the following configuration:
Save and close the file.
Create the Traefik Docker Compose file.
Add the following configuration:
Save and close the file.
Create the Traefik dynamic configuration file. Replace clearml.example.com with your domain.
Add the following routing rules:
Save and close the file.
Start Traefik.
Verify Traefik obtained the SSL certificates.
The output indicates certificate generation for each subdomain.
The ClearML Web UI provides initial setup and ongoing configuration management through a browser-based interface.
Open a web browser and navigate to the ClearML Web UI at https://app.clearml.example.com.
Create the administrator account on first access:
admin).Navigate to Settings in the left sidebar.
Click Workspace to view the workspace configuration.
Click Create new credentials to generate API credentials.
Copy and save the credentials block. This contains the API access key and secret key required for agent and SDK configuration.
The credentials block follows this format:
ClearML Agent transforms any machine into a remote worker that pulls tasks from queues and executes them with full environment reproducibility. The agent manages virtual environments, GPU allocation, and code versioning automatically.
You can run the ClearML Agent on the same server as the ClearML Server or on a dedicated machine. For GPU workloads, deploy agents on GPU-enabled instances.
Create the agent directory.
Navigate to the agent directory.
Install the Python virtual environment package.
Create and activate a virtual environment.
Install the ClearML Agent package.
Initialize the agent configuration.
The command starts an interactive setup. When prompted:
The agent saves the configuration to ~/clearml.conf.
Start the agent in daemon mode on the default queue.
For GPU workloads, specify GPU indices:
Verify the agent registered in the ClearML Web UI by navigating to Workers & Queues and selecting the Workers tab.
The ClearML SDK instruments Python scripts for automatic experiment tracking, logging hyperparameters, metrics, code versions, and model artifacts without code changes.
Ensure the virtual environment is active.
Install the ClearML SDK and common data science dependencies.
Configure the SDK connection to your ClearML Server.
Paste the credentials block from the ClearML Web UI when prompted. The configuration saves to ~/clearml.conf.
ClearML tracks every script execution as a task, automatically logging hyperparameters, metrics, code changes, and artifacts. The following experiment trains a Random Forest classifier to verify the server connection and demonstrate the tracking workflow.
Create a directory for experiments.
Navigate to the experiments directory.
Create the experiment script.
Add the following code:
Save and close the file.
Run the experiment.
The output displays a task URL. Open the URL to view the experiment in the ClearML Web UI.
Open the ClearML Web UI and navigate to the ClearML Tutorial project to view the experiment details.
The web interface organizes experiment data into tabs:
ClearML Pipelines chain tasks into a Directed Acyclic Graph (DAG) where step outputs feed into downstream inputs. The pipeline controller manages execution order, caching, and data flow between steps.
Navigate to the experiments directory.
Create the pipeline script.
Add the following code:
Save and close the file.
Run the pipeline.
View the pipeline execution graph in the ClearML Web UI under the ClearML Tutorial project.
Hyperparameter Optimization (HPO) automates the search for optimal model parameters by spawning experiment variations. ClearML clones a baseline experiment, modifies parameters according to defined search ranges, and tracks each trial independently.
Navigate to the experiments directory.
Create the HPO script.
Add the following code:
Save and close the file.
Run the optimization.
Monitor the optimization progress in the ClearML Web UI under ClearML Tutorial.
ClearML Serving provides model deployment with Triton inference server support. It enables production endpoints with versioning, monitoring, and automatic model updates.
Navigate to the project directory.
Clone the ClearML Serving repository.
Install the ClearML Serving package.
Create a serving service.
Copy the Serving Service ID from the output for use in subsequent steps.
Open the serving environment file.
Update the configuration with your ClearML server details. Replace the placeholders with your actual values.
Replace:
clearml.example.com with your domain.YOUR_ACCESS_KEY with your ClearML API access key.YOUR_SECRET_KEY with your ClearML API secret key.SERVING_SERVICE_ID with the ID from the previous step.Save and close the file.
Start the serving stack.
Install the PyTorch example dependencies.
Train and register a sample model.
Navigate to the task's Artifacts tab in the ClearML Web UI and copy the Model ID.
Add the model endpoint to the serving service. Replace SERVING_SERVICE_ID and MODEL_ID with your actual values.
Restart the serving containers to load the new endpoint.
Test the inference endpoint. Replace SERVER-IP with your server's IP address.
Validate the complete ClearML deployment by testing each component's functionality.
Navigate to https://app.clearml.example.com and verify you can log in and view projects.
Verify the API server responds.
Confirm the file server is accessible.
Navigate to Workers & Queues in the Web UI and confirm the agent appears under the Workers tab.
Confirm the first experiment appears in the ClearML Tutorial project with metrics, artifacts, and execution details.
Clone an experiment in the Web UI, modify a hyperparameter, and enqueue it. Verify the agent picks up and executes the task.
Migrating from SageMaker to ClearML shifts workflows from a cloud-locked environment to a self-hosted, infrastructure-agnostic platform.
SageMaker experiments use the sagemaker.experiments module with manual Trial Components.
sagemaker.experiments imports with clearml.Task.SageMaker uses Estimators to launch managed training instances.
sagemaker.estimator.Estimator with ClearML Agent execution.task.execute_remotely() or enqueue through the Web UI. Agents running on any infrastructure pick up and execute tasks.SageMaker Pipelines use a JSON-based DAG definition with proprietary syntax.
PipelineController or the @pipeline decorator.SageMaker Model Registry tracks model packages with approval workflows.
OutputModel for automatic model tracking.SageMaker Endpoints provide managed HTTPS inference services.
boto3 and sagemaker imports with the clearml package. The API is more Pythonic with fewer configuration dictionaries.clearml.conf or environment variables (CLEARML_API_ACCESS_KEY, CLEARML_API_SECRET_KEY)./opt/ml/). ClearML agents work with standard Python environments and any Docker container.You have successfully deployed ClearML Server with Traefik reverse proxy, configured agents for remote execution, and executed machine learning workflows including experiment tracking, pipelines, hyperparameter optimization, and model serving. For more information, visit the official ClearML documentation.
0 Comments
Be the first to comment and share your perspective with the community.