Skip to content

Commit 53ef6d2

Browse files
committed
fix styles for 'develop ng' branch
1 parent 7236094 commit 53ef6d2

File tree

33 files changed

+417
-453
lines changed

33 files changed

+417
-453
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ all: venv
2727
# we need to update pip and setuptools because venv versions aren't latest
2828
# need to prepend $(ACTIVATE) everywhere because all make calls are in subshells
2929
# otherwise we won't be installing anything in the venv itself
30-
$(ACTIVATE): tests/requirements.txt
30+
$(ACTIVATE):
3131
@echo "Updating virtualenv dependencies in: $(VIRTUALENV_DIR)..."
3232
@test -d $(VIRTUALENV_DIR) || $(VIRTUALENV_EXE) $(VIRTUALENV_DIR)
3333
@. $(ACTIVATE) && python -m pip install -r requirements-test.txt

benchmarks/common/base_benchmark_util.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,11 @@ def _define_args(self):
168168
"This option can be used by models (like SSD_Resnet34) "
169169
"to do fine-tuning training or achieve convergence.",
170170
dest="backbone_model", default=None, type=check_valid_folder)
171-
171+
172172
self._common_arg_parser.add_argument(
173173
"-g", "--in-graph", help="Full path to the input graph ",
174174
dest="input_graph", default=None, type=check_valid_filename)
175175

176-
177176
self._common_arg_parser.add_argument(
178177
"-k", "--benchmark-only",
179178
help="For benchmark measurement only. If neither --benchmark-only "

benchmarks/common/base_model_init.py

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -58,31 +58,39 @@ def __init__(self, args, custom_args=[], platform_util=None):
5858
raise ValueError("Did not find any platform info.")
5959

6060
# use case: bare-metal with openmpi, horovod and multi-node
61-
if os.environ["MPI_HOSTNAMES"] != "None" and (not "DOCKER" in os.environ or os.environ["DOCKER"] == "False"):
62-
if os.environ["MPI_NUM_PROCESSES"] != "None":
63-
try:
64-
# slots per host calculation using MPI_NUM_PROCESSES and number of hosts
65-
host_names = os.environ["MPI_HOSTNAMES"]
66-
number_of_hosts = len(host_names.split(','))
67-
slots_per_host = int(int(os.environ["MPI_NUM_PROCESSES"]) / number_of_hosts)
68-
host_names = ",".join([ host + ":" + str(slots_per_host) for host in host_names.split(',') ])
69-
# see the [examples](https://horovod.readthedocs.io/en/latest/mpirun.html) for the mca flags
70-
self.python_exe = "mpirun " + " -x LD_LIBRARY_PATH " + " -x PYTHONPATH " + " --allow-run-as-root -n " + os.environ["MPI_NUM_PROCESSES"] + " -H " + host_names + " -mca pml ob1 -mca btl ^openib -mca btl_tcp_if_exclude lo,docker0 --bind-to none --map-by slot " + self.python_exe
71-
except Exception as exception:
72-
raise ValueError("Caught exception calculating slots per host {}".format(str(exception)))
73-
else:
74-
raise ValueError("MPI_NUM_PROCESSES is required for MPI_HOSTNAMES and will be split evenly across the hosts.")
61+
if os.environ["MPI_HOSTNAMES"] != "None" and ("DOCKER" not in os.environ or os.environ["DOCKER"] == "False"):
62+
if os.environ["MPI_NUM_PROCESSES"] != "None":
63+
try:
64+
# slots per host calculation using MPI_NUM_PROCESSES and number of hosts
65+
host_names = os.environ["MPI_HOSTNAMES"]
66+
number_of_hosts = len(host_names.split(','))
67+
slots_per_host = int(int(os.environ["MPI_NUM_PROCESSES"]) / number_of_hosts)
68+
host_names = ",".join([host + ":" + str(slots_per_host) for host in host_names.split(',')])
69+
# see the [examples](https://horovod.readthedocs.io/en/latest/mpirun.html) for the mca flags
70+
self.python_exe = "mpirun " + " -x LD_LIBRARY_PATH " + " -x PYTHONPATH " \
71+
+ " --allow-run-as-root -n " + os.environ["MPI_NUM_PROCESSES"] + " -H " + host_names \
72+
+ " -mca pml ob1 -mca btl ^openib -mca btl_tcp_if_exclude " \
73+
"lo,docker0 --bind-to none --map-by slot " \
74+
+ self.python_exe
75+
except Exception as exception:
76+
raise ValueError("Caught exception calculating slots per host {}".format(str(exception)))
77+
else:
78+
raise ValueError("MPI_NUM_PROCESSES is required for MPI_HOSTNAMES and will be split evenly across the "
79+
"hosts.")
7580
# use case: docker with openmpi, single-node, multi-instance
7681
elif os.environ["MPI_NUM_PROCESSES"] != "None":
7782
if os.environ["MPI_NUM_PROCESSES_PER_SOCKET"] == "1":
78-
# Map by socket using OpenMPI by default (PPS=1).
79-
self.python_exe = "mpirun --allow-run-as-root -n " + os.environ["MPI_NUM_PROCESSES"] + " --map-by socket " + self.python_exe
83+
# Map by socket using OpenMPI by default (PPS=1).
84+
self.python_exe = "mpirun --allow-run-as-root -n " + os.environ["MPI_NUM_PROCESSES"] \
85+
+ " --map-by socket " + self.python_exe
8086
else:
81-
# number of processes per socket (pps)
82-
pps = int(os.environ["MPI_NUM_PROCESSES_PER_SOCKET"])
83-
split_a_socket = str(platform_util.num_cores_per_socket // pps)
84-
# Launch pps MPI processes over one socket
85-
self.python_exe = "mpirun --allow-run-as-root -n " + os.environ["MPI_NUM_PROCESSES"] + " --map-by ppr:" + str(pps) + ":socket:pe=" + split_a_socket + " --cpus-per-proc " + split_a_socket + " " + self.python_exe
87+
# number of processes per socket (pps)
88+
pps = int(os.environ["MPI_NUM_PROCESSES_PER_SOCKET"])
89+
split_a_socket = str(platform_util.num_cores_per_socket // pps)
90+
# Launch pps MPI processes over one socket
91+
self.python_exe = "mpirun --allow-run-as-root -n " + os.environ["MPI_NUM_PROCESSES"] \
92+
+ " --map-by ppr:" + str(pps) + ":socket:pe=" + split_a_socket + " --cpus-per-proc " \
93+
+ split_a_socket + " " + self.python_exe
8694

8795
def run_command(self, cmd):
8896
"""
@@ -182,15 +190,14 @@ def set_num_inter_intra_threads(self, num_inter_threads=None, num_intra_threads=
182190
if not self.args.num_inter_threads:
183191
self.args.num_inter_threads = self.platform_util.num_cpu_sockets
184192
if os.environ["MPI_NUM_PROCESSES"] != "None":
185-
self.args.num_inter_threads = 1
193+
self.args.num_inter_threads = 1
186194
if not self.args.num_intra_threads:
187195
if self.args.num_cores == -1:
188196
self.args.num_intra_threads = \
189197
int(self.platform_util.num_cores_per_socket *
190198
self.platform_util.num_cpu_sockets)
191199
if os.environ["MPI_NUM_PROCESSES"] != "None":
192-
self.args.num_intra_threads = \
193-
self.platform_util.num_cores_per_socket - 2
200+
self.args.num_intra_threads = self.platform_util.num_cores_per_socket - 2
194201
else:
195202
self.args.num_intra_threads = self.args.num_cores
196203

benchmarks/common/platform_util.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
from __future__ import division
2323
from __future__ import print_function
2424

25-
import os
2625
import re
2726
import platform as system_platform
2827
import subprocess

benchmarks/image_recognition/tensorflow/mobilenet_v1/inference/fp32/model_init.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def __init__(self, args, custom_args=[], platform_util=None):
7474
self.command_prefix, script_args_list)
7575

7676
def parse_args(self):
77-
if self.custom_args == None:
77+
if self.custom_args is None:
7878
return
7979

8080
parser = argparse.ArgumentParser()
@@ -101,8 +101,7 @@ def parse_args(self):
101101
help="name of output layer",
102102
type=str, default="MobilenetV1/Predictions/Reshape_1")
103103

104-
self.args = parser.parse_args(self.custom_args,
105-
namespace=self.args)
104+
self.args = parser.parse_args(self.custom_args, namespace=self.args)
106105

107106
def run(self):
108107
self.run_command(self.command_prefix)

benchmarks/image_recognition/tensorflow/resnet50v1_5/inference/bfloat16/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,3 @@
1515
# See the License for the specific language governing permissions and
1616
# limitations under the License.
1717
#
18-

benchmarks/image_recognition/tensorflow/resnet50v1_5/training/common_resnet50/resnet50_model_init.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525

2626
import os
2727
from argparse import ArgumentParser
28-
import time
2928

3029

3130
class ResNet50ModelInitializer(BaseModelInitializer):
@@ -72,7 +71,7 @@ def __init__(self, args, custom_args=[], platform_util=None):
7271

7372
# We need to change directory to model source to avoid python
7473
# module name conflicts.
75-
#self.benchmark_command = "cd " + self.args.model_source_dir + \
74+
# self.benchmark_command = "cd " + self.args.model_source_dir + \
7675
# "/models && " + self.get_command_prefix(args.socket_id) + \
7776
# self.python_exe + " " + benchmark_script
7877

benchmarks/language_modeling/tensorflow/bert_large/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,3 @@
1717
#
1818
# SPDX-License-Identifier: EPL-2.0
1919
#
20-

benchmarks/language_modeling/tensorflow/bert_large/inference/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,3 @@
1717
#
1818
# SPDX-License-Identifier: EPL-2.0
1919
#
20-

benchmarks/language_modeling/tensorflow/bert_large/inference/bfloat16/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,3 @@
1717
#
1818
# SPDX-License-Identifier: EPL-2.0
1919
#
20-

benchmarks/language_modeling/tensorflow/bert_large/inference/bfloat16/model_init.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626

2727
import os
2828
from argparse import ArgumentParser
29-
import time
3029

3130

3231
class ModelInitializer(BaseModelInitializer):
@@ -143,4 +142,3 @@ def run(self):
143142
else:
144143
print("Warning: The {} preditions file was not found. Unable to "
145144
"run the evaluation script.".format(predictions_json))
146-

benchmarks/language_modeling/tensorflow/bert_large/inference/fp32/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,3 @@
1717
#
1818
# SPDX-License-Identifier: EPL-2.0
1919
#
20-

benchmarks/language_modeling/tensorflow/bert_large/inference/fp32/model_init.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626

2727
import os
2828
from argparse import ArgumentParser
29-
import time
3029

3130

3231
class ModelInitializer(BaseModelInitializer):
@@ -142,4 +141,3 @@ def run(self):
142141
else:
143142
print("Warning: The {} preditions file was not found. Unable to "
144143
"run the evaluation script.".format(predictions_json))
145-

0 commit comments

Comments
 (0)