Esempio n. 1
0
    inference_solver = SOLVERS[p.solver_type]
    solver = inference_solver(model, dataset_builder, config=p.inference_config)
    solver.inference(dataset_builder.as_dataset(batch_size=1), rank_size=rank_size)


if __name__ == "__main__":
    logging.set_verbosity(logging.INFO)
    if len(sys.argv) < 2:
        logging.warning('Usage: python {} config_json_file'.format(sys.argv[0]))
        sys.exit()
    tf.random.set_seed(1)

    jsonfile = sys.argv[1]
    with open(jsonfile) as file:
        config = json.load(file)
    p = parse_config(config)

    rank_size = 1
    rank_index = 0
    try:
        hvd.init()
        rank_size = hvd.size()
        rank_index = hvd.rank()
    except ImportError:
        print("There is some problem with your horovod installation. \
               But it wouldn't affect single-gpu inference")
    if rank_size > 1:
        HorovodSolver.initialize_devices(p.solver_gpu)
    else:
        BaseSolver.initialize_devices(p.solver_gpu)
Esempio n. 2
0
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
# Only support tensorflow 2.0
# pylint: disable=invalid-name, no-member
r""" a sample implementation of LAS for HKUST """
import sys
import json
import tensorflow as tf
import horovod.tensorflow as hvd
from absl import logging
from athena import HorovodSolver
from athena.main import parse_config, train

if __name__ == "__main__":
    logging.set_verbosity(logging.INFO)
    tf.random.set_seed(1)

    JSON_FILE = sys.argv[1]
    CONFIG = None
    with open(JSON_FILE) as f:
        CONFIG = json.load(f)
    PARAMS = parse_config(CONFIG)
    HorovodSolver.initialize_devices()
    train(JSON_FILE, HorovodSolver, hvd.size(), hvd.local_rank())