Skip to content

Commit 8e39ee1

Browse files
matteoservaJohannesGaessler
authored andcommitted
ggml-cuda: Adding support for unified memory (llama/8035)
* Adding support for unified memory * adding again the documentation about unified memory * refactoring: Moved the unified memory code in the correct location. * Fixed compilation error when using hipblas * cleaning up the documentation * Updating the documentation Co-authored-by: Johannes Gäßler <[email protected]> * adding one more case where the PR should not be enabled --------- Co-authored-by: matteo serva <[email protected]> Co-authored-by: Johannes Gäßler <[email protected]>
1 parent d26250f commit 8e39ee1

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

ggml/src/ggml-cuda.cu

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,22 @@ static cudaError_t ggml_cuda_device_malloc(void ** ptr, size_t size, int device)
130130
}
131131
return res;
132132
#else
133+
134+
#if !defined(GGML_USE_HIPBLAS) && !defined(GGML_USE_MUSA)
135+
cudaError_t err;
136+
if (getenv("GGML_CUDA_ENABLE_UNIFIED_MEMORY") != nullptr)
137+
{
138+
err = cudaMallocManaged(ptr, size);
139+
}
140+
else
141+
{
142+
err = cudaMalloc(ptr, size);
143+
}
144+
return err;
145+
#else
133146
return cudaMalloc(ptr, size);
147+
#endif // !defined(GGML_USE_HIPBLAS) && !defined(GGML_USE_MUSA)
148+
134149
#endif
135150
}
136151

0 commit comments

Comments
 (0)