disallow PythonLayer in Multi-GPU training
authorRonghang Hu <huronghang@hotmail.com>
Fri, 4 Sep 2015 21:16:31 +0000 (14:16 -0700)
committerRonghang Hu <huronghang@hotmail.com>
Sat, 5 Sep 2015 02:28:47 +0000 (19:28 -0700)
include/caffe/python_layer.hpp

index c43c1e8..b839d52 100644 (file)
@@ -18,6 +18,12 @@ class PythonLayer : public Layer<Dtype> {
 
   virtual void LayerSetUp(const vector<Blob<Dtype>*>& bottom,
       const vector<Blob<Dtype>*>& top) {
+    // Disallow PythonLayer in MultiGPU training stage, due to GIL issues
+    // Details: https://github.com/BVLC/caffe/issues/2936
+    if (this->phase_ == TRAIN && Caffe::solver_count() > 1
+        && !ShareInParallel()) {
+      LOG(FATAL) << "PythonLayer is not implemented in Multi-GPU training";
+    }
     self_.attr("param_str") = bp::str(
         this->layer_param_.python_param().param_str());
     self_.attr("setup")(bottom, top);