caffe2 icon indicating copy to clipboard operation
caffe2 copied to clipboard

MPI build fails

Open thatguymike opened this issue 9 years ago • 5 comments

In file included from /home/mhouston/caffe2/caffe2/mpi/mpi_ops.h:7:0, from /home/mhouston/caffe2/caffe2/mpi/mpi_ops.cc:1: /home/mhouston/caffe2/caffe2/mpi/mpi_ops.h: In instantiation of ‘bool caffe2::MPISendTensorOp::RunOnDevice() [with Context = caffe2::CPUContext]’: /home/mhouston/caffe2/caffe2/mpi/mpi_ops.cc:27:1: required from here /home/mhouston/caffe2/caffe2/mpi/mpi_ops.h:176:71: error: invalid conversion from ‘const void*’ to ‘void*’ [-fpermissive] input.raw_data(), input.nbytes(), MPI_CHAR, dst_, tag_, comm)); ^ /home/mhouston/caffe2/caffe2/mpi/mpi_common.h:37:18: note: in definition of macro ‘MPI_CHECK’ int error = (condition);
^ In file included from /home/mhouston/caffe2/caffe2/mpi/mpi_ops.h:4:0, from /home/mhouston/caffe2/caffe2/mpi/mpi_ops.cc:1: /usr/lib/openmpi/include/mpi.h:1384:20: error: initializing argument 1 of ‘int MPI_Send(void*, int, MPI_Datatype, int, int, MPI_Comm)’ [-fpermissive] OMPI_DECLSPEC int MPI_Send(void *buf, int count, MPI_Datatype datatype, int dest,

thatguymike avatar Feb 17 '17 17:02 thatguymike

I don't like the simple workaround, changing tesor.h:raw_data() from const void* to void*. I assume there was a some reason for that to be const. One would think based on documentation that we should be using raw_mutable_data() here but a different problem of "this" now being of the wrong type.

Suggestions on desired path to fix?

thatguymike avatar Feb 18 '17 01:02 thatguymike

What MPI are you using? OpenMPI has the function definition with src as const void *, as does MPICH

slayton58 avatar Feb 20 '17 00:02 slayton58

Hmm, this seems to pass the contbuild so I think there might be a specific MPI version that causes the bug. In any case, if we trust that MPI_Send won't change the data, I guess we can use const_cast<void*> to go around that issue - we do it in e.g. the nervana engine, and blindly trust the other software (which might not be the best solution):

https://github.com/caffe2/caffe2/blob/master/caffe2/contrib/nervana/nervana_math_gpu.cc#L25

Yangqing avatar Feb 21 '17 18:02 Yangqing

@slayton58 I installed the packages as listed in the README.md

I'll check what exactly I have later today. This was on 2 different Ubuntu 14.04 installs.

thatguymike avatar Feb 21 '17 18:02 thatguymike

From googling, 14.04 includes OpenMPI 1.6.x, and that has the non-const function signature. 1.7 and beyond have the const void * as C2 expects. Looks like we can use MPI_Get_version to handle this.

slayton58 avatar Feb 21 '17 19:02 slayton58