Skip to content

Commit

Permalink
Merge pull request #39 from arjunsuresh/mlperf-inference
Browse files Browse the repository at this point in the history
Support get, docker
  • Loading branch information
arjunsuresh authored May 31, 2024
2 parents c48f383 + 4ef87a4 commit d8e8b7a
Show file tree
Hide file tree
Showing 11 changed files with 158 additions and 19 deletions.
7 changes: 7 additions & 0 deletions automation/script/module_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1721,6 +1721,13 @@ def docker(i):
if image_repo == '':
image_repo = 'cknowledge'

# Host system needs to have docker
r = self_module.cmind.access({'action':'run',
'automation':'script',
'tags': "get,docker"})
if r['return'] > 0:
return r

for artifact in sorted(lst, key = lambda x: x.meta.get('alias','')):

meta = artifact.meta
Expand Down
3 changes: 3 additions & 0 deletions script/app-mlperf-inference-mlcommons-python/_cm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ default_env:
CM_MLPERF_SUT_NAME_IMPLEMENTATION_PREFIX: reference
CM_MLPERF_SUT_NAME_RUN_CONFIG_SUFFIX: ''

docker:
real_run: False

# Map script inputs to environment variables
input_mapping:
count: CM_MLPERF_LOADGEN_QUERY_COUNT
Expand Down
5 changes: 3 additions & 2 deletions script/app-mlperf-inference/_cm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,6 @@ variations:
real_run: false
run: true
docker_input_mapping:
imagenet_path: IMAGENET_PATH
gptj_checkpoint_path: GPTJ_CHECKPOINT_PATH
criteo_preprocessed_path: CRITEO_PREPROCESSED_PATH
dlrm_data_path: DLRM_DATA_PATH
intel_gptj_int8_model_path: CM_MLPERF_INFERENCE_INTEL_GPTJ_INT8_MODEL_PATH
Expand Down Expand Up @@ -904,9 +902,12 @@ variations:
cuda,reference:
docker:
base_image: nvcr.io/nvidia/pytorch:24.03-py3

cuda:
docker:
all_gpus: 'yes'
deps:
- tags: get,nvidia-docker
group:
device
env:
Expand Down
64 changes: 64 additions & 0 deletions script/get-docker/customize.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
from cmind import utils
import os

def preprocess(i):

os_info = i['os_info']

env = i['env']

automation = i['automation']

recursion_spaces = i['recursion_spaces']

file_name = 'docker.exe' if os_info['platform'] == 'windows' else 'docker'
env['FILE_NAME'] = file_name

if 'CM_DOCKER_BIN_WITH_PATH' not in env:
r = i['automation'].find_artifact({'file_name': file_name,
'env': env,
'os_info':os_info,
'default_path_env_key': 'PATH',
'detect_version':True,
'env_path_key':'CM_DOCKER_BIN_WITH_PATH',
'run_script_input':i['run_script_input'],
'recursion_spaces':recursion_spaces})
if r['return'] >0 :
if r['return'] == 16:
run_file_name = "install"
r = automation.run_native_script({'run_script_input':i['run_script_input'], 'env':env, 'script_name':run_file_name})
if r['return'] >0: return r
else:
return r

return {'return':0}

def detect_version(i):
r = i['automation'].parse_version({'match_text': r'Docker version\s*([\d.]+)',
'group_number': 1,
'env_key':'CM_DOCKER_VERSION',
'which_env':i['env']})
if r['return'] >0: return r

version = r['version']

print (i['recursion_spaces'] + ' Detected version: {}'.format(version))
return {'return':0, 'version':version}

def postprocess(i):
env = i['env']

r = detect_version(i)

if r['return'] >0: return r

version = r['version']
found_file_path = env['CM_DOCKER_BIN_WITH_PATH']

found_path = os.path.dirname(found_file_path)
env['CM_DOCKER_INSTALLED_PATH'] = found_path
env['+PATH'] = [ found_path ]

env['CM_DOCKER_CACHE_TAGS'] = 'version-'+version

return {'return':0, 'version': version}
13 changes: 13 additions & 0 deletions script/get-docker/install-centos.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
sudo yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

cmd="sudo usermod -aG docker $USER"
echo "$cmd"
eval "$cmd"
test $? -eq 0 || exit $?

echo "Please relogin to the shell so that the new group is effective"
exit 1
#exec newgrp docker
#sudo su - $USER
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ cmd="sudo usermod -aG docker $USER"
echo "$cmd"
eval "$cmd"
test $? -eq 0 || exit $?

echo "Please relogin to the shell so that the new group is effective"
exit 1
#exec newgrp docker
#sudo su - $USER

2 changes: 2 additions & 0 deletions script/get-docker/install.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
echo "Please install docker to continue"
exit 1
2 changes: 2 additions & 0 deletions script/get-docker/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
echo "Please install docker to continue"
exit 1
3 changes: 3 additions & 0 deletions script/get-docker/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
docker --version > tmp-ver.out
test $? -eq 0 || exit 1
25 changes: 23 additions & 2 deletions script/run-mlperf-inference-mobilenet-models/_cm.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,14 @@
"CM_MLPERF_SUBMISSION_MODE": "yes"
}
},
"populate-readme": {
"performance-and-accuracy": {
"group": "run-mode",
"default": "true",
"env": {
"CM_MLPERF_FIND_PERFORMANCE_MODE": "no",
"CM_MLPERF_POPULATE_README": "yes"
"CM_MLPERF_PERFORMANCE_MODE": "yes",
"CM_MLPERF_ACCURACY_MODE": "yes",
"CM_MLPERF_SUBMISSION_MODE": "no"
}
},
"all-models": {
Expand All @@ -86,6 +89,24 @@
"CM_MLPERF_RUN_MOBILENETS": "yes"
}
},
"mobilenet-v1": {
"group": "model-selection",
"env": {
"CM_MLPERF_RUN_MOBILENET_V1": "yes"
}
},
"mobilenet-v2": {
"group": "model-selection",
"env": {
"CM_MLPERF_RUN_MOBILENET_V2": "yes"
}
},
"mobilenet-v3": {
"group": "model-selection",
"env": {
"CM_MLPERF_RUN_MOBILENET_V3": "yes"
}
},
"efficientnet": {
"group": "model-selection",
"env": {
Expand Down
50 changes: 35 additions & 15 deletions script/run-mlperf-inference-mobilenet-models/customize.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def preprocess(i):
quiet = (env.get('CM_QUIET', False) == 'yes')
verbose = (env.get('CM_VERBOSE', False) == 'yes')

models = {
models_all = {
"mobilenet": {
"v1": {
"multiplier": [ "multiplier-1.0", "multiplier-0.75", "multiplier-0.5", "multiplier-0.25" ],
Expand All @@ -47,6 +47,22 @@ def preprocess(i):
}
}
}

models = {}
if env.get('CM_MLPERF_RUN_MOBILENET_V1', '') == "yes":
models['mobilenet'] = {}
models['mobilenet']['v1'] = models_all['mobilenet']['v1']
elif env.get('CM_MLPERF_RUN_MOBILENET_V2', '') == "yes":
models['mobilenet'] = {}
models['mobilenet']['v2'] = models_all['mobilenet']['v2']
elif env.get('CM_MLPERF_RUN_MOBILENET_V3', '') == "yes":
models['mobilenet'] = {}
models['mobilenet']['v3'] = models_all['mobilenet']['v3']
elif env.get('CM_MLPERF_RUN_MOBILENETS', '') == "yes":
models['mobilenet'] = models_all['mobilenet']
elif env.get('CM_MLPERF_RUN_EFFICIENTNETS', '') == "yes":
models['efficientnet'] = models_all['efficientnet']

variation_strings = {}
for t1 in models:
variation_strings[t1] = []
Expand All @@ -73,12 +89,12 @@ def preprocess(i):
variation_list.append("_"+k3)
variation_strings[t1].append(",".join(variation_list))

if env.get('CM_MLPERF_POPULATE_README','') == "yes":
var="_populate-readme"
execution_mode="valid"
elif env.get('CM_MLPERF_SUBMISSION_MODE','') == "yes":
if env.get('CM_MLPERF_SUBMISSION_MODE','') == "yes":
var="_submission"
execution_mode="valid"
elif env.get('CM_MLPERF_ACCURACY_MODE','') == "yes" and env.get('CM_MLPERF_PERFORMANCE_MODE','') == "yes":
var="_full,_performance-and-accuracy"
execution_mode="valid"
elif env.get('CM_MLPERF_ACCURACY_MODE','') == "yes":
var="_full,_accuracy-only"
execution_mode="valid"
Expand Down Expand Up @@ -151,22 +167,26 @@ def preprocess(i):
if env.get('CM_MLPERF_INFERENCE_SUBMISSION_DIR', '') != '':
cm_input['submission_dir'] = env['CM_MLPERF_INFERENCE_SUBMISSION_DIR']

if env.get('CM_MLPERF_ACCURACY_MODE','') == "yes":
cm_input['mode'] = 'accuracy'

if env.get('CM_MLPERF_PERFORMANCE_MODE','') == "yes":
cm_input['mode'] = 'performance'

if env.get('CM_MLPERF_FIND_PERFORMANCE_MODE','') == "yes" and env.get('CM_MLPERF_NO_RERUN','') != 'yes':
cm_input['rerun'] = True

if env.get('CM_MLPERF_POWER','') == "yes":
cm_input['power'] = 'yes'

print(cm_input)
r = cmind.access(cm_input)
if r['return'] > 0:
return r
if env.get('CM_MLPERF_ACCURACY_MODE','') == "yes":
cm_input['mode'] = 'accuracy'
print(cm_input)
r = cmind.access(cm_input)
if r['return'] > 0:
return r

if env.get('CM_MLPERF_PERFORMANCE_MODE','') == "yes":
cm_input['mode'] = 'performance'

print(cm_input)
r = cmind.access(cm_input)
if r['return'] > 0:
return r

if env.get('CM_TEST_ONE_RUN', '') == "yes":
return {'return':0}
Expand Down

0 comments on commit d8e8b7a

Please sign in to comment.