Skip to content

Commit 0d27efc

Browse files
mglaesercypof
authored andcommitted
Python layers should build on multiprocess & solver_cnt; enable with bindings
1 parent e21b420 commit 0d27efc

4 files changed

Lines changed: 6 additions & 4 deletions

File tree

include/caffe/layers/python_layer.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class PythonLayer : public Layer<Dtype> {
2121
// Disallow PythonLayer in MultiGPU training stage, due to GIL issues
2222
// Details: https://github.com/BVLC/caffe/issues/2936
2323
if (this->phase_ == TRAIN && Caffe::solver_count() > 1
24-
&& !Caffe::root_solver() && !Caffe::multiprocess()) {
24+
&& !Caffe::multiprocess()) {
2525
LOG(FATAL) << "PythonLayer does not support CLI Multi-GPU, use train.py";
2626
}
2727
self_.attr("param_str") = bp::str(

python/caffe/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from .pycaffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, RMSPropSolver, AdaDeltaSolver, AdamSolver, NCCL, Timer
2-
from ._caffe import init_log, log, set_mode_cpu, set_mode_gpu, set_device, Layer, get_solver, layer_type_list, set_random_seed, solver_count, set_solver_count, solver_rank, set_solver_rank, Layer, get_solver
2+
from ._caffe import init_log, log, set_mode_cpu, set_mode_gpu, set_device, Layer, get_solver, layer_type_list, set_random_seed, solver_count, set_solver_count, solver_rank, set_solver_rank, set_multiprocess, Layer, get_solver
33
from ._caffe import __version__
44
from .proto.caffe_pb2 import TRAIN, TEST
55
from .classifier import Classifier

python/caffe/_caffe.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@ BOOST_PYTHON_MODULE(_caffe) {
359359
bp::def("set_solver_count", &Caffe::set_solver_count);
360360
bp::def("solver_rank", &Caffe::solver_rank);
361361
bp::def("set_solver_rank", &Caffe::set_solver_rank);
362+
bp::def("set_multiprocess", &Caffe::set_multiprocess);
362363

363364
bp::def("layer_type_list", &LayerRegistry<Dtype>::LayerTypeList);
364365

python/train.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ def show_time():
4444
if solver.iter % display == 0:
4545
s = '\n'
4646
for i in range(len(solver.net.layers)):
47-
s += 'forw %3d %8s ' % (i, solver.net.layers[i].layer_param.name)
47+
s += 'forw %3d %8s ' % (i, solver.net._layer_names[i])
4848
s += ': %.2f\n' % fprop[i].ms
4949
for i in range(len(solver.net.layers) - 1, -1, -1):
50-
s += 'back %3d %8s ' % (i, solver.net.layers[i].layer_param.name)
50+
s += 'back %3d %8s ' % (i, solver.net._layer_names[i])
5151
s += ': %.2f\n' % bprop[i].ms
5252
s += 'solver total: %.2f\n' % total.ms
5353
s += 'allreduce: %.2f\n' % allrd.ms
@@ -67,6 +67,7 @@ def solve(proto, snapshot, gpus, timing, uid, rank):
6767
caffe.set_device(gpus[rank])
6868
caffe.set_solver_count(len(gpus))
6969
caffe.set_solver_rank(rank)
70+
caffe.set_multiprocess(True)
7071

7172
solver = caffe.SGDSolver(proto)
7273
if snapshot and len(snapshot) != 0:

0 commit comments

Comments
 (0)