pytorch

Форк
0
/
run_plan_mpi.cc 
49 строк · 1.7 Кб
1
/**
2
 * Copyright (c) 2016-present, Facebook, Inc.
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *     http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16

17
#include <mpi.h>
18

19
#include "c10/util/Flags.h"
20
#include "caffe2/core/init.h"
21
#include "caffe2/core/logging.h"
22
#include "caffe2/core/operator.h"
23
#include "caffe2/proto/caffe2_pb.h"
24
#include "caffe2/utils/proto_utils.h"
25

26
C10_DEFINE_string(plan, "", "The given path to the plan protobuffer.");
27

28
int main(int argc, char** argv) {
29
  c10::SetUsageMessage("Runs a caffe2 plan that has MPI operators in it.");
30
  int mpi_ret;
31
  MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE, &mpi_ret);
32
  if (mpi_ret != MPI_THREAD_MULTIPLE &&
33
      mpi_ret != MPI_THREAD_SERIALIZED) {
34
    std::cerr << "Caffe2 MPI requires the underlying MPI to support the "
35
                 "MPI_THREAD_SERIALIZED or MPI_THREAD_MULTIPLE mode.\n";
36
    return 1;
37
  }
38
  caffe2::GlobalInit(&argc, &argv);
39
  LOG(INFO) << "Loading plan: " << FLAGS_plan;
40
  caffe2::PlanDef plan_def;
41
  CAFFE_ENFORCE(ReadProtoFromFile(FLAGS_plan, &plan_def));
42
  std::unique_ptr<caffe2::Workspace> workspace(new caffe2::Workspace());
43
  workspace->RunPlan(plan_def);
44

45
  // This is to allow us to use memory leak checks.
46
  caffe2::ShutdownProtobufLibrary();
47
  MPI_Finalize();
48
  return 0;
49
}
50

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.