多 GPU 上的 MVAPICH 导致分段错误
MVAPICH on multi-GPU causes Segmentation fault
我在 Debian 7 机器上使用 MVAPICH2 2.1。拥有多张Tesla K40m卡。代码如下
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <cuda_runtime.h>
#include <mpi.h>
int main(int argc, char** argv) {
MPI_Status status;
int rank;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
cudaSetDevice(0);
if (rank == 0) {
srand(time(0));
float* a;
float num = rand();
cudaMalloc(&a, sizeof(float));
cudaMemcpy(a, &num, sizeof(float), cudaMemcpyDefault);
MPI_Send(a, sizeof(float), MPI_CHAR, 1, 0, MPI_COMM_WORLD);
printf("sent %f\n", num);
} else {
float* a;
float num;
cudaMalloc(&a, sizeof(float));
MPI_Recv(a, sizeof(float), MPI_CHAR, 0, 0, MPI_COMM_WORLD, &status);
cudaMemcpy(&num, a, sizeof(float), cudaMemcpyDefault);
printf("received %f\n", num);
}
cudaSetDevice(1);
if (rank == 0) {
float* a;
float num = rand();
cudaMalloc(&a, sizeof(float));
cudaMemcpy(a, &num, sizeof(float), cudaMemcpyDefault);
MPI_Send(a, sizeof(float), MPI_CHAR, 1, 0, MPI_COMM_WORLD);
printf("sent %f\n", num);
} else {
float* a;
float num;
cudaMalloc(&a, sizeof(float));
MPI_Recv(a, sizeof(float), MPI_CHAR, 0, 0, MPI_COMM_WORLD, &status);
cudaMemcpy(&num, a, sizeof(float), cudaMemcpyDefault);
printf("received %f\n", num);
}
MPI_Finalize();
return 0;
}
总之,我首先将设备设置为GPU 0,发送一些东西。然后我将设备设置为 GPU 1,发送一些东西。
输出结果如下
sent 1778786688.000000
received 1778786688.000000
[debian:mpi_rank_0][error_sighandler] Caught error: Segmentation fault (signal 11)
[debian:mpispawn_0][readline] Unexpected End-Of-File on file descriptor 7. MPI process died?
[debian:mpispawn_0][mtpmi_processops] Error while reading PMI socket. MPI process died?
[debian:mpispawn_0][child_handler] MPI process (rank: 0, pid: 30275) terminated with signal 11 -> abort job
[debian:mpirun_rsh][process_mpispawn_connection] mpispawn_0 from node debian aborted: Error while reading a PMI socket (4)
所以第一次发送就OK了。但是一旦我将我的设备设置为另一个 GPU,然后 MPI 发送,砰!我想知道为什么会这样。
此外,我使用以下命令构建了 MVAPICH。
./configure --enable-cuda --with-cuda=/usr/local/cuda --with-device=ch3:mrail --enable-rdma-cm
我启用了调试并打印了堆栈跟踪。希望这有帮助..
sent 1377447040.000000
received 1377447040.000000
[debian:mpi_rank_0][error_sighandler] Caught error: Segmentation fault (signal 11)
[debian:mpi_rank_0][print_backtrace] 0: /home/lyt/local/lib/libmpi.so.12(print_backtrace+0x1c) [0x7fba26a00b3c]
[debian:mpi_rank_0][print_backtrace] 1: /home/lyt/local/lib/libmpi.so.12(error_sighandler+0x59) [0x7fba26a00c39]
[debian:mpi_rank_0][print_backtrace] 2: /lib/x86_64-linux-gnu/libpthread.so.0(+0xf8d0) [0x7fba23ffe8d0]
[debian:mpi_rank_0][print_backtrace] 3: /usr/lib/libcuda.so.1(+0x21bb30) [0x7fba26fa9b30]
[debian:mpi_rank_0][print_backtrace] 4: /usr/lib/libcuda.so.1(+0x1f6695) [0x7fba26f84695]
[debian:mpi_rank_0][print_backtrace] 5: /usr/lib/libcuda.so.1(+0x205586) [0x7fba26f93586]
[debian:mpi_rank_0][print_backtrace] 6: /usr/lib/libcuda.so.1(+0x17ad88) [0x7fba26f08d88]
[debian:mpi_rank_0][print_backtrace] 7: /usr/lib/libcuda.so.1(cuStreamWaitEvent+0x63) [0x7fba26ed72e3]
[debian:mpi_rank_0][print_backtrace] 8: /usr/local/cuda/lib64/libcudart.so.6.5(+0xa023) [0x7fba27cff023]
[debian:mpi_rank_0][print_backtrace] 9: /usr/local/cuda/lib64/libcudart.so.6.5(cudaStreamWaitEvent+0x1ce) [0x7fba27d2cf3e]
[debian:mpi_rank_0][print_backtrace] 10: /home/lyt/local/lib/libmpi.so.12(MPIDI_CH3_CUDAIPC_Rendezvous_push+0x17f) [0x7fba269f25bf]
[debian:mpi_rank_0][print_backtrace] 11: /home/lyt/local/lib/libmpi.so.12(MPIDI_CH3_Rendezvous_push+0xe3) [0x7fba269a0233]
[debian:mpi_rank_0][print_backtrace] 12: /home/lyt/local/lib/libmpi.so.12(MPIDI_CH3I_MRAILI_Process_rndv+0xa4) [0x7fba269a0334]
[debian:mpi_rank_0][print_backtrace] 13: /home/lyt/local/lib/libmpi.so.12(MPIDI_CH3I_Progress+0x19a) [0x7fba2699aeaa]
[debian:mpi_rank_0][print_backtrace] 14: /home/lyt/local/lib/libmpi.so.12(MPI_Send+0x6ef) [0x7fba268d118f]
[debian:mpi_rank_0][print_backtrace] 15: ./bin/minimal.run() [0x400c15]
[debian:mpi_rank_0][print_backtrace] 16: /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf5) [0x7fba23c67b45]
[debian:mpi_rank_0][print_backtrace] 17: ./bin/minimal.run() [0x400c5c]
[debian:mpispawn_0][readline] Unexpected End-Of-File on file descriptor 6. MPI process died?
[debian:mpispawn_0][mtpmi_processops] Error while reading PMI socket. MPI process died?
[debian:mpispawn_0][child_handler] MPI process (rank: 0, pid: 355) terminated with signal 11 -> abort job
[debian:mpirun_rsh][process_mpispawn_connection] mpispawn_0 from node debian8 aborted: Error while reading a PMI socket (4)
恐怕 MVAPICH 还不支持在同一进程中使用多个 GPU(来源:mailing list)。
高级内存传输操作需要存储特定于设备的结构,因此除非明确支持多个设备,否则恐怕无法使您的代码 运行.
另一方面,您当然可以通过 运行使用多个 GPU 设备
每个设备单独的进程。
我在 Debian 7 机器上使用 MVAPICH2 2.1。拥有多张Tesla K40m卡。代码如下
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <cuda_runtime.h>
#include <mpi.h>
int main(int argc, char** argv) {
MPI_Status status;
int rank;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
cudaSetDevice(0);
if (rank == 0) {
srand(time(0));
float* a;
float num = rand();
cudaMalloc(&a, sizeof(float));
cudaMemcpy(a, &num, sizeof(float), cudaMemcpyDefault);
MPI_Send(a, sizeof(float), MPI_CHAR, 1, 0, MPI_COMM_WORLD);
printf("sent %f\n", num);
} else {
float* a;
float num;
cudaMalloc(&a, sizeof(float));
MPI_Recv(a, sizeof(float), MPI_CHAR, 0, 0, MPI_COMM_WORLD, &status);
cudaMemcpy(&num, a, sizeof(float), cudaMemcpyDefault);
printf("received %f\n", num);
}
cudaSetDevice(1);
if (rank == 0) {
float* a;
float num = rand();
cudaMalloc(&a, sizeof(float));
cudaMemcpy(a, &num, sizeof(float), cudaMemcpyDefault);
MPI_Send(a, sizeof(float), MPI_CHAR, 1, 0, MPI_COMM_WORLD);
printf("sent %f\n", num);
} else {
float* a;
float num;
cudaMalloc(&a, sizeof(float));
MPI_Recv(a, sizeof(float), MPI_CHAR, 0, 0, MPI_COMM_WORLD, &status);
cudaMemcpy(&num, a, sizeof(float), cudaMemcpyDefault);
printf("received %f\n", num);
}
MPI_Finalize();
return 0;
}
总之,我首先将设备设置为GPU 0,发送一些东西。然后我将设备设置为 GPU 1,发送一些东西。
输出结果如下
sent 1778786688.000000
received 1778786688.000000
[debian:mpi_rank_0][error_sighandler] Caught error: Segmentation fault (signal 11)
[debian:mpispawn_0][readline] Unexpected End-Of-File on file descriptor 7. MPI process died?
[debian:mpispawn_0][mtpmi_processops] Error while reading PMI socket. MPI process died?
[debian:mpispawn_0][child_handler] MPI process (rank: 0, pid: 30275) terminated with signal 11 -> abort job
[debian:mpirun_rsh][process_mpispawn_connection] mpispawn_0 from node debian aborted: Error while reading a PMI socket (4)
所以第一次发送就OK了。但是一旦我将我的设备设置为另一个 GPU,然后 MPI 发送,砰!我想知道为什么会这样。
此外,我使用以下命令构建了 MVAPICH。
./configure --enable-cuda --with-cuda=/usr/local/cuda --with-device=ch3:mrail --enable-rdma-cm
我启用了调试并打印了堆栈跟踪。希望这有帮助..
sent 1377447040.000000
received 1377447040.000000
[debian:mpi_rank_0][error_sighandler] Caught error: Segmentation fault (signal 11)
[debian:mpi_rank_0][print_backtrace] 0: /home/lyt/local/lib/libmpi.so.12(print_backtrace+0x1c) [0x7fba26a00b3c]
[debian:mpi_rank_0][print_backtrace] 1: /home/lyt/local/lib/libmpi.so.12(error_sighandler+0x59) [0x7fba26a00c39]
[debian:mpi_rank_0][print_backtrace] 2: /lib/x86_64-linux-gnu/libpthread.so.0(+0xf8d0) [0x7fba23ffe8d0]
[debian:mpi_rank_0][print_backtrace] 3: /usr/lib/libcuda.so.1(+0x21bb30) [0x7fba26fa9b30]
[debian:mpi_rank_0][print_backtrace] 4: /usr/lib/libcuda.so.1(+0x1f6695) [0x7fba26f84695]
[debian:mpi_rank_0][print_backtrace] 5: /usr/lib/libcuda.so.1(+0x205586) [0x7fba26f93586]
[debian:mpi_rank_0][print_backtrace] 6: /usr/lib/libcuda.so.1(+0x17ad88) [0x7fba26f08d88]
[debian:mpi_rank_0][print_backtrace] 7: /usr/lib/libcuda.so.1(cuStreamWaitEvent+0x63) [0x7fba26ed72e3]
[debian:mpi_rank_0][print_backtrace] 8: /usr/local/cuda/lib64/libcudart.so.6.5(+0xa023) [0x7fba27cff023]
[debian:mpi_rank_0][print_backtrace] 9: /usr/local/cuda/lib64/libcudart.so.6.5(cudaStreamWaitEvent+0x1ce) [0x7fba27d2cf3e]
[debian:mpi_rank_0][print_backtrace] 10: /home/lyt/local/lib/libmpi.so.12(MPIDI_CH3_CUDAIPC_Rendezvous_push+0x17f) [0x7fba269f25bf]
[debian:mpi_rank_0][print_backtrace] 11: /home/lyt/local/lib/libmpi.so.12(MPIDI_CH3_Rendezvous_push+0xe3) [0x7fba269a0233]
[debian:mpi_rank_0][print_backtrace] 12: /home/lyt/local/lib/libmpi.so.12(MPIDI_CH3I_MRAILI_Process_rndv+0xa4) [0x7fba269a0334]
[debian:mpi_rank_0][print_backtrace] 13: /home/lyt/local/lib/libmpi.so.12(MPIDI_CH3I_Progress+0x19a) [0x7fba2699aeaa]
[debian:mpi_rank_0][print_backtrace] 14: /home/lyt/local/lib/libmpi.so.12(MPI_Send+0x6ef) [0x7fba268d118f]
[debian:mpi_rank_0][print_backtrace] 15: ./bin/minimal.run() [0x400c15]
[debian:mpi_rank_0][print_backtrace] 16: /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf5) [0x7fba23c67b45]
[debian:mpi_rank_0][print_backtrace] 17: ./bin/minimal.run() [0x400c5c]
[debian:mpispawn_0][readline] Unexpected End-Of-File on file descriptor 6. MPI process died?
[debian:mpispawn_0][mtpmi_processops] Error while reading PMI socket. MPI process died?
[debian:mpispawn_0][child_handler] MPI process (rank: 0, pid: 355) terminated with signal 11 -> abort job
[debian:mpirun_rsh][process_mpispawn_connection] mpispawn_0 from node debian8 aborted: Error while reading a PMI socket (4)
恐怕 MVAPICH 还不支持在同一进程中使用多个 GPU(来源:mailing list)。
高级内存传输操作需要存储特定于设备的结构,因此除非明确支持多个设备,否则恐怕无法使您的代码 运行.
另一方面,您当然可以通过 运行使用多个 GPU 设备 每个设备单独的进程。