Attempting to deploy a trained ML model to our gateway management module in ThingWorx 9.6 and consistently getting ‘Model not compatible with gateway runtime’ error. The model trains successfully in ThingWorx Analytics but fails during deployment.
ModelDeploymentService.deployToGateway(model, "gateway-01");
// Error: Model not compatible with gateway runtime
// Missing dependencies: numpy 1.21.0, scikit-learn 0.24.2
The error mentions missing dependencies but we have those libraries installed on the gateway. I suspect there’s a model packaging issue or the gateway runtime compatibility isn’t matching the training environment. Has anyone successfully deployed Analytics models to edge gateways? What’s the proper dependency management approach for ThingWorx 9.6?
Beyond Python versions, check the model serialization format. ThingWorx gateways expect models in PMML or ONNX format for maximum compatibility. If you’re exporting as pickle files, that could explain the runtime incompatibility. Convert your model to PMML using sklearn2pmml or export to ONNX format. These formats are runtime-agnostic and don’t require exact dependency matching. Also ensure your gateway has sufficient memory - some models fail deployment due to resource constraints.
The dependency management for gateway deployment is tricky. You need to create a deployment manifest that explicitly lists all dependencies with exact versions. ThingWorx 9.6 introduced stricter validation for edge deployments. Build a requirements.txt that matches the gateway runtime capabilities, test locally using the gateway simulator, then package everything together. Don’t rely on system-level libraries - bundle everything with the model artifact.
I’ve deployed dozens of ML models to ThingWorx gateways and this error pattern is very familiar. Here’s the complete solution:
Gateway Runtime Compatibility: ThingWorx 9.6 gateways run a specific runtime environment that’s more restrictive than the Analytics training environment. The key is matching environments exactly:
-
Python Version Alignment: Gateway runtime in 9.6 uses Python 3.7.9. Your Analytics server might be using 3.8 or 3.9. This version mismatch causes dependency failures even when library versions appear correct.
-
Dependency Management: Don’t rely on system libraries. Package dependencies with your model:
ModelPackager packager = new ModelPackager();
packager.includeDependencies(true);
packager.setRuntimeVersion("python-3.7.9");
ModelPackage pkg = packager.package(model);
- Model Packaging Best Practices:
- Export models in PMML format for maximum compatibility
- If using scikit-learn, use sklearn2pmml to convert
- Create a deployment descriptor with exact dependency versions
- Test packaging locally before gateway deployment
- Use the ThingWorx Gateway Simulator to validate before production
Specific Steps for Your Situation:
-
Verify gateway runtime version: Check gateway logs for Python and library versions
-
Recreate training environment matching gateway specs
-
Retrain model in compatible environment or convert existing model to PMML
-
Create deployment manifest with dependencies:
numpy==1.19.5 (not 1.21.0 - too new for Python 3.7)
scikit-learn==0.23.2 (not 0.24.2)
-
Package model with dependencies bundled
-
Deploy using ModelDeploymentService with validation enabled
-
Monitor gateway logs during deployment for detailed error messages
Common Gotchas:
- Numpy 1.21+ requires Python 3.8+, causing your exact error
- Gateway memory limits can cause silent deployment failures
- Network timeouts between Analytics and gateway need extended timeout settings
- Security certificates must be valid and trusted by gateway
The root cause is almost always environment mismatch between training and deployment. Once you align Python versions and use compatible dependency versions, deployment should succeed. After fixing this, our gateway deployment success rate went from 40% to 98%.
The dependency versions are critical. Gateway runtime uses a containerized environment with specific library versions. Even if you have numpy and scikit-learn installed on the gateway host, they need to be packaged with the model. Check your model export settings in Analytics - there should be an option to bundle dependencies. Also verify that your gateway runtime version matches the Analytics server version.
I’ve hit this exact error. The problem is ThingWorx 9.6 gateways have strict runtime requirements. Your model was likely trained in a Python 3.8+ environment but the gateway runtime only supports Python 3.7. This causes dependency incompatibilities even when library versions match. You need to retrain your model in an environment that matches the gateway’s Python version exactly, then package it as a self-contained deployment unit with all dependencies included.
Check your gateway logs for more detailed error messages. The ‘Model not compatible’ error is often a catch-all for various issues including certificate problems, network connectivity between Analytics and gateway, or insufficient permissions. I’ve seen cases where the model itself was fine but gateway security policies blocked the deployment. Review gateway security settings and ensure the deployment service account has proper authorization.