Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not enable peer access in case of the GPUs are located over QPI #3319

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions src/caffe/parallel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <sys/mman.h>
#include <sys/stat.h>

#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
Expand Down Expand Up @@ -232,7 +233,19 @@ P2PSync<Dtype>::P2PSync(shared_ptr<Solver<Dtype> > root_solver,
int access;
CUDA_CHECK(cudaDeviceCanAccessPeer(&access, self, peer));
if (access) {
CUDA_CHECK(cudaDeviceEnablePeerAccess(peer, 0));
cudaDeviceProp a, b;
CUDA_CHECK(cudaGetDeviceProperties(&a, self));
CUDA_CHECK(cudaGetDeviceProperties(&b, peer));
const int pci_bus_id_offset = 0x80;
if (std::max(a.pciBusID, b.pciBusID) < pci_bus_id_offset ||
std::min(a.pciBusID, b.pciBusID) >= pci_bus_id_offset) {
CUDA_CHECK(cudaDeviceEnablePeerAccess(peer, 0));
} else {
LOG(INFO) << "This will result in poor memcpy performance over QPI, "
<< "if enables peer to peer access from GPU "
<< self << " (pciBusID " << a.pciBusID << ") to GPU "
<< peer << " (pciBusID " << b.pciBusID << ")";
}
} else {
LOG(INFO)<< "GPU " << self << " does not have p2p access to GPU " << peer;
}
Expand Down Expand Up @@ -262,7 +275,14 @@ P2PSync<Dtype>::~P2PSync() {
int access;
CUDA_CHECK(cudaDeviceCanAccessPeer(&access, self, peer));
if (access) {
CUDA_CHECK(cudaDeviceDisablePeerAccess(peer));
cudaDeviceProp a, b;
CUDA_CHECK(cudaGetDeviceProperties(&a, self));
CUDA_CHECK(cudaGetDeviceProperties(&b, peer));
const int pci_bus_id_offset = 0x80;
if (std::max(a.pciBusID, b.pciBusID) < pci_bus_id_offset ||
std::min(a.pciBusID, b.pciBusID) >= pci_bus_id_offset) {
CUDA_CHECK(cudaDeviceDisablePeerAccess(peer));
}
}
}

Expand Down