File tree Expand file tree Collapse file tree 2 files changed +4
-3
lines changed Expand file tree Collapse file tree 2 files changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -9568,6 +9568,10 @@ static ggml_backend_buffer_type_i ggml_backend_cuda_buffer_type_interface = {
9568
9568
9569
9569
ggml_backend_buffer_type_t ggml_backend_cuda_buffer_type(int device) {
9570
9570
// FIXME: this is not thread safe
9571
+ if (device >= ggml_backend_cuda_get_device_count()) {
9572
+ return nullptr;
9573
+ }
9574
+
9571
9575
static struct ggml_backend_buffer_type ggml_backend_cuda_buffer_types[GGML_CUDA_MAX_DEVICES];
9572
9576
9573
9577
static bool ggml_backend_cuda_buffer_type_initialized = false;
@@ -9793,7 +9797,6 @@ ggml_backend_buffer_type_t ggml_backend_cuda_split_buffer_type(const float * ten
9793
9797
// FIXME: this is not thread safe
9794
9798
static std::map<std::array<float, GGML_CUDA_MAX_DEVICES>, struct ggml_backend_buffer_type> buft_map;
9795
9799
9796
-
9797
9800
std::array<float, GGML_CUDA_MAX_DEVICES> tensor_split_arr = {};
9798
9801
9799
9802
bool all_zero = tensor_split == nullptr || std::all_of(tensor_split, tensor_split + GGML_CUDA_MAX_DEVICES, [](float x) { return x == 0.0f; });
Original file line number Diff line number Diff line change @@ -47,8 +47,6 @@ GGML_API int ggml_backend_cuda_get_device_count(void);
47
47
GGML_API void ggml_backend_cuda_get_device_description (int device , char * description , size_t description_size );
48
48
GGML_API void ggml_backend_cuda_get_device_memory (int device , size_t * free , size_t * total );
49
49
50
-
51
-
52
50
#ifdef __cplusplus
53
51
}
54
52
#endif
You can’t perform that action at this time.
0 commit comments