Skip to main content
Version: 最新版本(unreleased)

Wrapper Image Build Process

The process of building a business image

1. Build requirements

  • Docker (20.10.0 or above)
  • Service based on conda environment (one conda environment corresponds to one inference service)

2. Envd install

pip install --pre --upgrade envd
envd bootstrap

3. Export the conda environment list of the current inference service

conda env export > env.yaml

4.Write build.envd file

Select the base image to load and the python version of conda

  • base(language="python3.8", os="ubuntu20.4")
  • Optional base mirror
    • aiges_cpu
    • aiges_gpu

Install the conda env environment list under the specified path

  • install.conda_packages(env_file="env.yaml")

Install system dependencies (write the dependencies to be installed into the name list, separated by commas)

  • install.system_packages(name = ["..."])

Copy the service code to the business image

  • io.copy(src="./detectron2", dest="/")

Offline installation (requires file copy and then install)

  • io.copy(src="./detectron2", dest="/")
  • run(commands=["pip install -e /detectron2",])

Set the installation source

  • config.pip_index()
  • config.conda_channel()

Example (there are optional other installation interfaces)

def build():
mirror_config()
base(language="python3.8", os="ubuntu20.4") # Load the base image and set the python version built into conda
install.python_packages(name = [
"torch==1.10",
"openmim"
])
install.conda_packages(channel= ["pytorch"], env_file = "env.yaml") # Install conda yaml environment in the specified path
install.python_packages(requirements="build.txt") # Install requirements.txt in the specified path
install.system_packages(name = [ # System dependent installation
"libgl1-mesa-glx"
])
run(commands=[
"mim install mmcv-full", # Install through the third-party tool mim
])

io.copy(src="./detectron2", dest="/") # Copy of local files to mirror
run(commands=[ # Dependency package installation offline
"pip install -e /detectron2",
])
def mirror_config(): # Configure download source
config.pip_index(url = "https://pypi.tuna.tsinghua.edu.cn/simple")
config.conda_channel(channel="""
channels:
- defaults
show_channel_urls: true
default_channels:
- https://repo.anaconda.com/pkgs/main
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/menpo/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
custom_channels:
conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
pytorch-lts: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
""")

5. Image building via envd

envd build -t ImageName:TAG -f build.envd         

example:envd build -t yolo:v1.0.0 -f build.envd