Create portable conda environment files for OS/glibc upgrades
Project description
conda-env-replicator
Create portable conda environment files that work across OS and glibc upgrades by removing overly-specific build strings while preserving critical CUDA/GPU requirements.
The Problem
When migrating conda environments across systems (especially during HPC OS/glibc upgrades), environment recreation often fails due to:
- Overly-specific build strings that are no longer available in conda channels
- Platform-specific dependencies that don't exist on new systems
- Missing channel information in exported environment files
This tool solves these issues by creating portable environment files that:
- Remove unnecessary build strings
- Preserve critical CUDA/GPU version constraints with wildcards
- Explicitly specify package channels
- Work across different Linux versions and glibc updates
Installation
From PyPI (recommended)
pip install conda-env-replicator
From source
git clone https://github.com/mpinb/conda-env-replicator.git
cd conda-env-replicator
pip install -e .
Quick Start
Export and process an existing environment
conda-env-replicator -n myenv -o portable_env.yml
Process existing export files
# First, export your environment manually
conda env export -n myenv > env.yml
conda list -n myenv --explicit > explicit.txt
# Then process them
conda-env-replicator -y env.yml -e explicit.txt -o portable_env.yml
Recreate environment on new system
conda env create -n myenv_new -f portable_env.yml
How It Works
The tool processes conda environment files using this logic:
- Removes build strings:
ptxcompiler=0.2.0=py39h107f55c_0→ptxcompiler=0.2.0 - Preserves CUDA versions:
ucx=1.12.0=cuda11.2_0→ucx=1.12.0=*cuda11* - Preserves GPU builds:
package=1.0=gpu_0→package=1.0=*gpu* - Adds explicit channels:
ptxcompiler=0.2.0→rapidsai::ptxcompiler=0.2.0
Example Transformation
Before (fails on new system):
dependencies:
- ptxcompiler=0.2.0=py39h107f55c_0
- ucx=1.12.0=cuda11.2_0
- numpy=1.21.2=py39h20f2e39_0
After (portable):
dependencies:
- rapidsai::ptxcompiler=0.2.0
- rapidsai::ucx=1.12.0=*cuda11*
- conda-forge::numpy=1.21.2
Usage
Command Line Options
conda-env-replicator [-h] [-y YAML] [-e EXPLICIT] [-n NAME] -o OUTPUT [--keep-intermediates]
Options:
-y, --yaml YAML Input conda environment YAML file
-e, --explicit EXPLICIT Input conda list --explicit output file
-n, --name NAME Name of existing conda environment to export
-o, --output OUTPUT Output portable YAML file (required)
--keep-intermediates Keep intermediate export files (when using -n)
-h, --help Show this help message and exit
Examples
Process an existing environment directly
conda-env-replicator -n pytorch-cuda11 -o portable_pytorch.yml
Process existing export files
conda-env-replicator -y my_env.yml -e my_env_explicit.txt -o portable.yml
Keep intermediate files for inspection
conda-env-replicator -n myenv -o portable.yml --keep-intermediates
Use Cases
HPC System Migrations
Perfect for HPC centers upgrading OS or glibc versions:
# On old system
conda-env-replicator -n research_env -o research_portable.yml
# Transfer file to new system
scp research_portable.yml newcluster:~/
# On new system
conda env create -n research_env -f research_portable.yml
Cross-Platform Development
Create environments that work across different Linux distributions:
# On Ubuntu 20.04
conda-env-replicator -n dev_env -o portable_dev.yml
# Works on Rocky Linux 8, Ubuntu 22.04, etc.
CUDA Version Flexibility
Maintain CUDA major version requirements while allowing flexibility:
# Original: cuda11.2_0 → Portable: *cuda11*
# Allows conda to find any cuda 11.x compatible build
Requirements
- Python 3.7+
- PyYAML
- conda (for environment export functionality)
Comparison with Other Tools
| Tool | Purpose | Use Case |
|---|---|---|
conda-env-replicator |
OS/glibc migration | HPC upgrades, cross-distro |
conda clone |
Exact environment copy | Same system only |
conda-lock |
Lockfile generation | Reproducibility with exact versions |
conda env export |
YAML export | Starting point (not portable) |
Contributing
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
Development Setup
git clone https://github.com/mpinb/conda-env-replicator.git
cd conda-env-replicator
pip install -e ".[dev]"
pytest tests/
License
This project is licensed under the MIT License - see the LICENSE file for details.
Citation
If you use this tool in your research, please cite:
@software{conda_env_replicator,
title = {conda-env-replicator: Portable Conda Environment Migration Tool},
author = {{Max Planck Institute for Neurobiology of Behavior - caesar}},
year = {2025},
url = {https://github.com/mpinb/conda-env-replicator}
}
Support
- Issues: GitHub Issues
- Discussions: GitHub Discussions
Acknowledgments
Developed at the Max Planck Institute for Neurobiology of Behavior - caesar to facilitate HPC environment migrations and improve reproducibility in computational neuroscience research.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file conda_env_replicator-0.1.3.tar.gz.
File metadata
- Download URL: conda_env_replicator-0.1.3.tar.gz
- Upload date:
- Size: 8.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
abae595ded6afc6f697230e578e65861deb8d46fc20ba2d52a4c70a98f7ece59
|
|
| MD5 |
f0d2fd7fd480b69957677881fd341217
|
|
| BLAKE2b-256 |
6600663e938036b51ce484aecd744cec6895c07648998bdaf231b0e9907f17a1
|
File details
Details for the file conda_env_replicator-0.1.3-py3-none-any.whl.
File metadata
- Download URL: conda_env_replicator-0.1.3-py3-none-any.whl
- Upload date:
- Size: 7.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cfc2668d8e61a426098f72277f977a9f1fd95a5d9c4e670470191752739bfa77
|
|
| MD5 |
c2348d89723d10e1fc6ae972140fada4
|
|
| BLAKE2b-256 |
29455ef7538508915750198b00168a9ad636296e8f7cdec4fd4c6253c0fbb714
|