[Bug] fix green context's incompatibility with cuda < 12.4 (#8701)
This commit is contained in:
@@ -7,6 +7,8 @@
|
|||||||
#include "cuda_utils.h"
|
#include "cuda_utils.h"
|
||||||
#include "greenctx_stream.h"
|
#include "greenctx_stream.h"
|
||||||
|
|
||||||
|
#if CUDA_VERSION >= 12040
|
||||||
|
|
||||||
static std::vector<int64_t> create_greenctx_stream_fallback(CUgreenCtx gctx[2]) {
|
static std::vector<int64_t> create_greenctx_stream_fallback(CUgreenCtx gctx[2]) {
|
||||||
CUstream streamA, streamB;
|
CUstream streamA, streamB;
|
||||||
CUcontext ctx;
|
CUcontext ctx;
|
||||||
@@ -94,3 +96,18 @@ std::vector<int64_t> create_greenctx_stream_by_value(int64_t smA, int64_t smB, i
|
|||||||
|
|
||||||
return vec;
|
return vec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
std::vector<int64_t> create_greenctx_stream_by_value(int64_t smA, int64_t smB, int64_t device) {
|
||||||
|
TORCH_CHECK(
|
||||||
|
false,
|
||||||
|
"Green Contexts feature requires CUDA Toolkit 12.4 or newer. Current CUDA version: " +
|
||||||
|
std::to_string(CUDA_VERSION));
|
||||||
|
|
||||||
|
// This is a stub function that should never be reached
|
||||||
|
// Return empty vector to satisfy return type requirement
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
@@ -14,6 +14,11 @@ def create_greenctx_stream_by_value(
|
|||||||
Returns:
|
Returns:
|
||||||
tuple[ExternalStream, ExternalStream]: The two streams.
|
tuple[ExternalStream, ExternalStream]: The two streams.
|
||||||
"""
|
"""
|
||||||
|
if torch.version.cuda < "12.4":
|
||||||
|
raise RuntimeError(
|
||||||
|
"Green Contexts feature requires CUDA Toolkit 12.4 or newer."
|
||||||
|
)
|
||||||
|
|
||||||
if device_id is None:
|
if device_id is None:
|
||||||
device_id = torch.cuda.current_device()
|
device_id = torch.cuda.current_device()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user