Исходный код СУБД RuDB — свободной СУБД с открытым исходным кодом на базе PostgreSQL
rudb
2 days ago bd039d1e92813358c5c5a1e346b49074baf513f2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
import argparse
import os  # noqa: F401
import re
import sys  # noqa: F401
 
from azure.common.client_factory import get_client_from_cli_profile
from azure.mgmt.containerregistry import ContainerRegistryManagementClient
from azureml.core import Datastore, Experiment, Run, Workspace  # noqa: F401
from azureml.core.compute import AmlCompute, ComputeTarget  # noqa: F401
from azureml.core.container_registry import ContainerRegistry
from azureml.core.runconfig import MpiConfiguration, RunConfiguration  # noqa: F401
from azureml.data.azure_storage_datastore import AzureBlobDatastore, AzureFileDatastore  # noqa: F401
from azureml.train.estimator import Estimator
 
parser = argparse.ArgumentParser()
parser.add_argument(
    "--subscription", type=str, default="ea482afa-3a32-437c-aa10-7de928a9e793"
)  # AI Platform GPU - MLPerf
parser.add_argument(
    "--resource_group", type=str, default="onnx_training", help="Azure resource group containing the AzureML Workspace"
)
parser.add_argument(
    "--workspace", type=str, default="ort_training_dev", help="AzureML Workspace to run the Experiment in"
)
parser.add_argument(
    "--compute_target", type=str, default="onnx-training", help="AzureML Compute target to run the Experiment on"
)
parser.add_argument("--experiment", type=str, default="BERT-ONNX", help="Name of the AzureML Experiment")
parser.add_argument(
    "--tags",
    type=str,
    default=None,
    help="Tags to be added to the submitted run (--tag1=value1 --tag2=value2 --tag3=value3)",
)
 
parser.add_argument(
    "--datastore", type=str, default="bert_premium", help="AzureML Datastore to be mounted into the Experiment"
)
parser.add_argument(
    "--train_dir", type=str, default="book/train", help="Path in the AzureML Datastore containing the train files"
)
parser.add_argument(
    "--test_dir", type=str, default="book/test", help="Path in the AzureML Datastore containing the test files"
)
parser.add_argument(
    "--train_dir2", type=str, default=None, help="Path in the AzureML Datastore containing the train files for phase 2"
)
parser.add_argument(
    "--test_dir2", type=str, default=None, help="Path in the AzureML Datastore containing the test files for phase 2"
)
 
parser.add_argument(
    "--container",
    type=str,
    default="onnxtraining.azurecr.io/azureml/bert:latest-openmpi4.0.0-cuda10.1-cudnn7-ubuntu16.04",
    help="Docker container to use to run the Experiment",
)
parser.add_argument(
    "--container_registry_resource_group",
    type=str,
    default="onnx_training",
    help="Azure resource group containing the Azure Container Registry (if not public)",
)
 
parser.add_argument(
    "--node_count",
    type=int,
    default=1,
    help="Number of nodes to use for the Experiment. If greater than 1, an MPI distributed job will be run.",
)
parser.add_argument(
    "--gpu_count",
    type=int,
    default=1,
    help="Number of GPUs to use per node. If greater than 1, an MPI distributed job will be run.",
)
 
parser.add_argument(
    "--model_name",
    type=str,
    default="bert_L-24_H-1024_A-16_V_30528_optimized_layer_norm",
    help="Model to be trained (must exist in the AzureML Datastore)",
)
parser.add_argument(
    "--script_params",
    type=str,
    default="",
    help="Training script parameters (--param1=value1 --param2=value2 --param3=value3)",
)
args = parser.parse_args()
 
# Get the AzureML Workspace to run the Experiment in
ws = Workspace.get(name=args.workspace, subscription_id=args.subscription, resource_group=args.resource_group)
 
# Get the existing AzureML Compute target
compute_target = ComputeTarget(workspace=ws, name=args.compute_target)
 
# Get the datastore from current workspace
ds = Datastore.get(workspace=ws, datastore_name=args.datastore)
 
# Construct common script parameters
script_params = {
    "--model_name": ds.path(args.model_name).as_download(),
    "--train_data_dir": ds.path(args.train_dir).as_mount(),
    "--test_data_dir": ds.path(args.test_dir).as_mount(),
}
 
# Optional phase2 script parameters
if args.train_dir2:
    script_params["--train_data_dir_phase2"] = ds.path(args.train_dir2).as_mount()
if args.test_dir2:
    script_params["--test_data_dir_phase2"] = ds.path(args.test_dir2).as_mount()
 
# Allow additional custom script parameters
for params in args.script_params.split(" "):
    key, value = params.split("=")
    script_params[key] = value
 
# Allow custom tags on the run
tags = {}
if args.tags:
    for tag in args.tags.split(" "):
        key, value = tag.split("=")
        tags[key] = value
 
# Get container registry information (if private)
container_image = args.container
registry_details = None
 
acr = re.match("^((\\w+).azurecr.io)/(.*)", args.container)
if acr:
    # Extract the relevant parts from the container image
    #   e.g. onnxtraining.azurecr.io/azureml/bert:latest
    registry_address = acr.group(1)  # onnxtraining.azurecr.io
    registry_name = acr.group(2)  # onnxtraining
    container_image = acr.group(3)  # azureml/bert:latest
 
    registry_client = get_client_from_cli_profile(ContainerRegistryManagementClient, subscription_id=args.subscription)
    registry_credentials = registry_client.registries.list_credentials(
        args.container_registry_resource_group, registry_name
    )
 
    registry_details = ContainerRegistry()
    registry_details.address = registry_address
    registry_details.username = registry_credentials.username
    registry_details.password = registry_credentials.passwords[0].value
 
# MPI configuration if executing a distributed run
mpi = MpiConfiguration()
mpi.process_count_per_node = args.gpu_count
 
# AzureML Estimator that describes how to run the Experiment
estimator = Estimator(
    source_directory="./",
    script_params=script_params,
    compute_target=compute_target,
    node_count=args.node_count,
    distributed_training=mpi,
    image_registry_details=registry_details,
    use_docker=True,
    custom_docker_image=container_image,
    entry_script="train.py",
    inputs=[ds.path("./").as_mount()],
)
 
# Start the AzureML Experiment
experiment = Experiment(workspace=ws, name=args.experiment)
run = experiment.submit(estimator, tags)
print(f"Experiment running at: {run.get_portal_url()}")