Skip to content

Commit 8649481

Browse files
CUDA: enable peer access between devices
1 parent 230d46c commit 8649481

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

ggml-cuda.cu

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5091,6 +5091,28 @@ void ggml_init_cublas() {
50915091
CUBLAS_CHECK(cublasSetMathMode(g_cublas_handles[id], CUBLAS_TF32_TENSOR_OP_MATH));
50925092
}
50935093

5094+
#ifdef NDEBUG
5095+
for (int id = 0; id < g_device_count; ++id) {
5096+
CUDA_CHECK(cudaSetDevice(id));
5097+
5098+
for (int id_other = 0; id_other < g_device_count; ++id_other) {
5099+
if (id == id_other) {
5100+
continue;
5101+
}
5102+
if (id != g_main_device && id_other != g_main_device) {
5103+
continue;
5104+
}
5105+
5106+
int canAccessPeer;
5107+
CUDA_CHECK(cudaDeviceCanAccessPeer(&canAccessPeer, id, id_other));
5108+
if (canAccessPeer) {
5109+
// FIXME for some reason enabling peer access makes prompt processing slightly slower
5110+
CUDA_CHECK(cudaDeviceEnablePeerAccess(id_other, 0));
5111+
}
5112+
}
5113+
}
5114+
#endif // NDEBUG
5115+
50945116
// configure logging to stdout
50955117
// CUBLAS_CHECK(cublasLoggerConfigure(1, 1, 0, nullptr));
50965118

0 commit comments

Comments
 (0)