diff --git a/cuda_bindings/cuda/bindings/_v2/nvrtc.pyx b/cuda_bindings/cuda/bindings/_v2/nvrtc.pyx index ffa3973e950..1ef516caa55 100644 --- a/cuda_bindings/cuda/bindings/_v2/nvrtc.pyx +++ b/cuda_bindings/cuda/bindings/_v2/nvrtc.pyx @@ -3,14 +3,13 @@ # SPDX-License-Identifier: Apache-2.0 # # This code was automatically generated across versions from 12.9.0 to 13.3.0. Do not modify it directly. -# CYTHON-BINDINGS-GENERATED-DO-NOT-MODIFY-THIS-FILE: format=1; content-sha256=a36c7e54cf29166832dd9aebc1fa71cc3649498794a2846e707396419caebe10 +# CYTHON-BINDINGS-GENERATED-DO-NOT-MODIFY-THIS-FILE: format=1; content-sha256=b73f313203f01d91dab664fb485858edcaab834bc1b5a181db05c2d53d660117 # <<<< PREAMBLE CONTENT >>>> cimport cpython as _cyb_cpython cimport cpython.buffer as _cyb_cpython_buffer -from cython cimport view as _cyb_view from libc.stdint cimport intptr_t from libc.stdlib cimport ( calloc as _cyb_calloc, @@ -657,6 +656,8 @@ cpdef tuple version(): cpdef int get_num_supported_archs() except? -1: """nvrtcGetNumSupportedArchs sets the output parameter ``num_archs`` with the number of architectures supported by NVRTC. This can then be used to pass an array to ``nvrtcGetSupportedArchs`` to get the supported architectures. + see ``nvrtcGetSupportedArchs``. + Returns: int: number of supported architectures. @@ -672,6 +673,8 @@ cpdef int get_num_supported_archs() except? -1: cpdef object get_supported_archs(): """nvrtcGetSupportedArchs populates the array passed via the output parameter ``supported_archs`` with the architectures supported by NVRTC. The array is sorted in the ascending order. The size of the array to be passed can be determined using ``nvrtcGetNumSupportedArchs``. + see ``nvrtcGetNumSupportedArchs``. + Returns: int: sorted array of supported architectures. @@ -681,13 +684,17 @@ cpdef object get_supported_archs(): with nogil: __status__ = nvrtcGetNumSupportedArchs(&numArchs) check_status(__status__) - if numArchs == 0: - return _cyb_view.array(shape=(1,), itemsize=sizeof(int), format="i", mode="c")[:0] - cdef _cyb_view.array supported_archs = _cyb_view.array(shape=(numArchs,), itemsize=sizeof(int), format="i", mode="c") - cdef int *supported_archs_ptr = (supported_archs.data) - with nogil: - __status__ = nvrtcGetSupportedArchs(supported_archs_ptr) - check_status(__status__) + cdef object supported_archs_alloc + cdef intptr_t _supported_archs_data_ + cdef int *supported_archs_ptr + supported_archs_alloc = _numpy.empty(max(numArchs, 1), dtype=_numpy.int32) + supported_archs = supported_archs_alloc[:numArchs] + _supported_archs_data_ = supported_archs_alloc.ctypes.data + supported_archs_ptr = _supported_archs_data_ + if numArchs != 0: + with nogil: + __status__ = nvrtcGetSupportedArchs(supported_archs_ptr) + check_status(__status__) return supported_archs @@ -739,13 +746,12 @@ cpdef bytes get_ptx(intptr_t prog): with nogil: __status__ = nvrtcGetPTXSize(prog, &ptxSizeRet) check_status(__status__) - if ptxSizeRet == 0: - return b"" cdef bytes _ptx_ = bytes(ptxSizeRet) cdef char* ptx = _ptx_ - with nogil: - __status__ = nvrtcGetPTX(prog, ptx) - check_status(__status__) + if ptxSizeRet != 0: + with nogil: + __status__ = nvrtcGetPTX(prog, ptx) + check_status(__status__) return _ptx_ @@ -782,13 +788,12 @@ cpdef bytes get_cubin(intptr_t prog): with nogil: __status__ = nvrtcGetCUBINSize(prog, &cubinSizeRet) check_status(__status__) - if cubinSizeRet == 0: - return b"" cdef bytes _cubin_ = bytes(cubinSizeRet) cdef char* cubin = _cubin_ - with nogil: - __status__ = nvrtcGetCUBIN(prog, cubin) - check_status(__status__) + if cubinSizeRet != 0: + with nogil: + __status__ = nvrtcGetCUBIN(prog, cubin) + check_status(__status__) return _cubin_ @@ -825,13 +830,12 @@ cpdef bytes get_ltoir(intptr_t prog): with nogil: __status__ = nvrtcGetLTOIRSize(prog, <OIRSizeRet) check_status(__status__) - if LTOIRSizeRet == 0: - return b"" cdef bytes _ltoir_ = bytes(LTOIRSizeRet) cdef char* ltoir = _ltoir_ - with nogil: - __status__ = nvrtcGetLTOIR(prog, ltoir) - check_status(__status__) + if LTOIRSizeRet != 0: + with nogil: + __status__ = nvrtcGetLTOIR(prog, ltoir) + check_status(__status__) return _ltoir_ @@ -868,19 +872,21 @@ cpdef bytes get_optix_ir(intptr_t prog): with nogil: __status__ = nvrtcGetOptiXIRSize(prog, &optixirSizeRet) check_status(__status__) - if optixirSizeRet == 0: - return b"" cdef bytes _optixir_ = bytes(optixirSizeRet) cdef char* optixir = _optixir_ - with nogil: - __status__ = nvrtcGetOptiXIR(prog, optixir) - check_status(__status__) + if optixirSizeRet != 0: + with nogil: + __status__ = nvrtcGetOptiXIR(prog, optixir) + check_status(__status__) return _optixir_ cpdef size_t get_program_log_size(intptr_t prog) except? 0: """nvrtcGetProgramLogSize sets ``log_size_ret`` with the size of the log generated by the previous compilation of ``prog`` (including the trailing ``NULL``). + Note that compilation log may be generated with warnings and informative + messages, even when the compilation of ``prog`` succeeds. + Args: prog (intptr_t): CUDA Runtime Compilation program. @@ -912,19 +918,21 @@ cpdef bytes get_program_log(intptr_t prog): with nogil: __status__ = nvrtcGetProgramLogSize(prog, &logSizeRet) check_status(__status__) - if logSizeRet == 0: - return b"" cdef bytes _log_ = bytes(logSizeRet) cdef char* log = _log_ - with nogil: - __status__ = nvrtcGetProgramLog(prog, log) - check_status(__status__) + if logSizeRet != 0: + with nogil: + __status__ = nvrtcGetProgramLog(prog, log) + check_status(__status__) return _log_ cpdef add_name_expression(intptr_t prog, name_expression): """nvrtcAddNameExpression notes the given name expression denoting the address of a global function or device/__constant__ variable. + The identical name expression string must be provided on a subsequent call + to nvrtcGetLoweredName to extract the lowered name. + Args: prog (intptr_t): CUDA Runtime Compilation program. name_expression (str): constant expression denoting the @@ -961,6 +969,10 @@ cpdef size_t get_pch_heap_size() except? 0: cpdef set_pch_heap_size(size_t size): """set the size of the PCH Heap. + The requested size may be rounded up to a platform dependent alignment + (e.g. page size). If the PCH Heap has already been allocated, the heap + memory will be freed and a new PCH Heap will be allocated. + Args: size (size_t): requested size of the PCH Heap, in bytes. @@ -974,6 +986,20 @@ cpdef set_pch_heap_size(size_t size): cpdef int get_pch_create_status(intptr_t prog) except? -1: """returns the PCH creation status. + NVRTC_SUCCESS indicates that the PCH was successfully created. + NVRTC_ERROR_NO_PCH_CREATE_ATTEMPTED indicates that no PCH creation was + attempted, either because PCH functionality was not requested during the + preceding nvrtcCompileProgram call, or automatic PCH processing was + requested, and compiler chose not to create a PCH file. + NVRTC_ERROR_PCH_CREATE_HEAP_EXHAUSTED indicates that a PCH file could + potentially have been created, but the compiler ran out space in the PCH + heap. In this scenario, the :func:`get_pch_heap_size_required` can be used + to query the required heap size, the heap can be reallocated for this size + with :func:`set_pch_heap_size` and PCH creation may be reattempted again + invoking :func:`compile_program` with a new NVRTC program instance. + NVRTC_ERROR_PCH_CREATE indicates that an error condition prevented the PCH + file from being created. + Args: prog (intptr_t): CUDA Runtime Compilation program. @@ -1037,13 +1063,12 @@ cpdef bytes get_tile_ir(intptr_t prog): with nogil: __status__ = nvrtcGetTileIRSize(prog, &TileIRSizeRet) check_status(__status__) - if TileIRSizeRet == 0: - return b"" cdef bytes _tile_ir_ = bytes(TileIRSizeRet) cdef char* tile_ir = _tile_ir_ - with nogil: - __status__ = nvrtcGetTileIR(prog, tile_ir) - check_status(__status__) + if TileIRSizeRet != 0: + with nogil: + __status__ = nvrtcGetTileIR(prog, tile_ir) + check_status(__status__) return _tile_ir_ diff --git a/cuda_bindings/cuda/bindings/cudla.pyx b/cuda_bindings/cuda/bindings/cudla.pyx index 75b1f05f2ca..1ebc4bcea55 100644 --- a/cuda_bindings/cuda/bindings/cudla.pyx +++ b/cuda_bindings/cuda/bindings/cudla.pyx @@ -2,14 +2,14 @@ # SPDX-License-Identifier: Apache-2.0 # This code was automatically generated across versions from 1.5.0 to 13.3.0. Do not modify it directly. -# CYTHON-BINDINGS-GENERATED-DO-NOT-MODIFY-THIS-FILE: format=1; content-sha256=3c177b7a0328c0f6f16067c8c9f4e5a002bd019e8c17c017ba9f77af21da8d75 +# CYTHON-BINDINGS-GENERATED-DO-NOT-MODIFY-THIS-FILE: format=1; content-sha256=5c0d6715f105108fd83cc471fd0978ecab1f1cdfdd78f41ac3bcf7dc1a470ab5 # <<<< PREAMBLE CONTENT >>>> cimport cpython as _cyb_cpython cimport cpython.buffer as _cyb_cpython_buffer -from cython cimport view as _cyb_view +from cpython.memoryview cimport PyMemoryView_FromMemory as _cyb_PyMemoryView_FromMemory from libc.stdint cimport ( intptr_t, uint32_t, @@ -604,9 +604,12 @@ cdef class ModuleTensorDescriptor: @property def stride(self): """~_numpy.uint32: (array of length 8).""" - cdef _cyb_view.array arr = _cyb_view.array(shape=(8,), itemsize=sizeof(uint32_t), format="I", mode="c", allocate_buffer=False) - arr.data = (&(self._ptr[0].stride)) - return _numpy.asarray(arr) + cdef object _mv_ = _cyb_PyMemoryView_FromMemory( + (&(self._ptr[0].stride)), + (sizeof(uint32_t) * (8)), + _cyb_cpython_buffer.PyBUF_WRITE if not self._readonly else _cyb_cpython_buffer.PyBUF_READ, + ) + return _numpy.frombuffer(_mv_, dtype=_numpy.uint32) @stride.setter def stride(self, val): @@ -614,9 +617,8 @@ cdef class ModuleTensorDescriptor: raise ValueError("This ModuleTensorDescriptor instance is read-only") if len(val) != 8: raise ValueError(f"Expected length { 8 } for field stride, got {len(val)}") - cdef _cyb_view.array arr = _cyb_view.array(shape=(8,), itemsize=sizeof(uint32_t), format="I", mode="c") - arr[:] = _numpy.asarray(val, dtype=_numpy.uint32) - _cyb_memcpy((&(self._ptr[0].stride)), (arr.data), sizeof(uint32_t) * len(val)) + _val_ = _numpy.ascontiguousarray(_numpy.asarray(val, dtype=_numpy.uint32)) + _cyb_memcpy((&(self._ptr[0].stride)), (_val_.ctypes.data), sizeof(uint32_t) * (8)) @staticmethod def from_buffer(buffer): @@ -1344,10 +1346,13 @@ cdef class SignalEvents: def dev_ptrs(self): """int: """ if self._ptr[0].devPtrs == NULL or self._ptr[0].numEvents == 0: - return _cyb_view.array(shape=(1,), itemsize=sizeof(intptr_t), format="q", mode="c")[:0] - cdef _cyb_view.array arr = _cyb_view.array(shape=(self._ptr[0].numEvents,), itemsize=sizeof(intptr_t), format="q", mode="c", allocate_buffer=False) - arr.data = (self._ptr[0].devPtrs) - return arr + return _numpy.empty(0, dtype=_numpy.intp) + cdef object _mv_ = _cyb_PyMemoryView_FromMemory( + (self._ptr[0].devPtrs), + (self._ptr[0].numEvents * sizeof(intptr_t)), + _cyb_cpython_buffer.PyBUF_WRITE, + ) + return _numpy.frombuffer(_mv_, dtype=_numpy.intp) @dev_ptrs.setter def dev_ptrs(self, val): @@ -1357,13 +1362,9 @@ cdef class SignalEvents: self._ptr[0].numEvents = _n if _n == 0: return - cdef _cyb_view.array arr = _cyb_view.array(shape=(_n,), itemsize=sizeof(intptr_t), format="q", mode="c") - cdef intptr_t[:] mv = arr - cdef Py_ssize_t i - for i in range(_n): - mv[i] = val[i] - self._ptr[0].devPtrs = (arr.data) - self._refs["dev_ptrs"] = arr + _arr_ = _numpy.ascontiguousarray(_numpy.asarray(val, dtype=_numpy.intp)) + self._ptr[0].devPtrs = _arr_.ctypes.data + self._refs["dev_ptrs"] = _arr_ @property def eof_fences(self): @@ -1530,10 +1531,13 @@ cdef class Task: def output_tensor(self): """int: """ if self._ptr[0].outputTensor == NULL or self._ptr[0].numOutputTensors == 0: - return _cyb_view.array(shape=(1,), itemsize=sizeof(intptr_t), format="q", mode="c")[:0] - cdef _cyb_view.array arr = _cyb_view.array(shape=(self._ptr[0].numOutputTensors,), itemsize=sizeof(intptr_t), format="q", mode="c", allocate_buffer=False) - arr.data = (self._ptr[0].outputTensor) - return arr + return _numpy.empty(0, dtype=_numpy.intp) + cdef object _mv_ = _cyb_PyMemoryView_FromMemory( + (self._ptr[0].outputTensor), + (self._ptr[0].numOutputTensors * sizeof(intptr_t)), + _cyb_cpython_buffer.PyBUF_WRITE, + ) + return _numpy.frombuffer(_mv_, dtype=_numpy.intp) @output_tensor.setter def output_tensor(self, val): @@ -1543,22 +1547,21 @@ cdef class Task: self._ptr[0].numOutputTensors = _n if _n == 0: return - cdef _cyb_view.array arr = _cyb_view.array(shape=(_n,), itemsize=sizeof(intptr_t), format="q", mode="c") - cdef intptr_t[:] mv = arr - cdef Py_ssize_t i - for i in range(_n): - mv[i] = val[i] - self._ptr[0].outputTensor = (arr.data) - self._refs["output_tensor"] = arr + _arr_ = _numpy.ascontiguousarray(_numpy.asarray(val, dtype=_numpy.intp)) + self._ptr[0].outputTensor = _arr_.ctypes.data + self._refs["output_tensor"] = _arr_ @property def input_tensor(self): """int: """ if self._ptr[0].inputTensor == NULL or self._ptr[0].numInputTensors == 0: - return _cyb_view.array(shape=(1,), itemsize=sizeof(intptr_t), format="q", mode="c")[:0] - cdef _cyb_view.array arr = _cyb_view.array(shape=(self._ptr[0].numInputTensors,), itemsize=sizeof(intptr_t), format="q", mode="c", allocate_buffer=False) - arr.data = (self._ptr[0].inputTensor) - return arr + return _numpy.empty(0, dtype=_numpy.intp) + cdef object _mv_ = _cyb_PyMemoryView_FromMemory( + (self._ptr[0].inputTensor), + (self._ptr[0].numInputTensors * sizeof(intptr_t)), + _cyb_cpython_buffer.PyBUF_WRITE, + ) + return _numpy.frombuffer(_mv_, dtype=_numpy.intp) @input_tensor.setter def input_tensor(self, val): @@ -1568,13 +1571,9 @@ cdef class Task: self._ptr[0].numInputTensors = _n if _n == 0: return - cdef _cyb_view.array arr = _cyb_view.array(shape=(_n,), itemsize=sizeof(intptr_t), format="q", mode="c") - cdef intptr_t[:] mv = arr - cdef Py_ssize_t i - for i in range(_n): - mv[i] = val[i] - self._ptr[0].inputTensor = (arr.data) - self._refs["input_tensor"] = arr + _arr_ = _numpy.ascontiguousarray(_numpy.asarray(val, dtype=_numpy.intp)) + self._ptr[0].inputTensor = _arr_.ctypes.data + self._refs["input_tensor"] = _arr_ @property def wait_events(self): diff --git a/cuda_bindings/cuda/bindings/cufile.pyx b/cuda_bindings/cuda/bindings/cufile.pyx index e8127feb6c3..bc880365a5b 100644 --- a/cuda_bindings/cuda/bindings/cufile.pyx +++ b/cuda_bindings/cuda/bindings/cufile.pyx @@ -3,7 +3,7 @@ # SPDX-License-Identifier: Apache-2.0 # # This code was automatically generated across versions from 12.9.1 to 13.3.0. Do not modify it directly. -# CYTHON-BINDINGS-GENERATED-DO-NOT-MODIFY-THIS-FILE: format=1; content-sha256=df46a6921d93f83249134c7705b2809f57145b6fb72f6f40c4657ecd1b443b81 +# CYTHON-BINDINGS-GENERATED-DO-NOT-MODIFY-THIS-FILE: format=1; content-sha256=b46f5a16585b36d52e8bf6a7ca3009d8c2350427cff03f68ab4b558b93c905fc # <<<< PREAMBLE CONTENT >>>> @@ -11,7 +11,7 @@ cimport cpython as _cyb_cpython cimport cpython.buffer as _cyb_cpython_buffer cimport cpython.memoryview as _cyb_cpython_memoryview -from cython cimport view as _cyb_view +from cpython.memoryview cimport PyMemoryView_FromMemory as _cyb_PyMemoryView_FromMemory from libc.stdint cimport ( intptr_t, uint64_t, @@ -2532,9 +2532,12 @@ cdef class StatsLevel2: @property def read_size_kb_hist(self): """~_numpy.uint64: (array of length 32).""" - cdef _cyb_view.array arr = _cyb_view.array(shape=(32,), itemsize=sizeof(uint64_t), format="Q", mode="c", allocate_buffer=False) - arr.data = (&(self._ptr[0].read_size_kb_hist)) - return _numpy.asarray(arr) + cdef object _mv_ = _cyb_PyMemoryView_FromMemory( + (&(self._ptr[0].read_size_kb_hist)), + (sizeof(uint64_t) * (32)), + _cyb_cpython_buffer.PyBUF_WRITE if not self._readonly else _cyb_cpython_buffer.PyBUF_READ, + ) + return _numpy.frombuffer(_mv_, dtype=_numpy.uint64) @read_size_kb_hist.setter def read_size_kb_hist(self, val): @@ -2542,16 +2545,18 @@ cdef class StatsLevel2: raise ValueError("This StatsLevel2 instance is read-only") if len(val) != 32: raise ValueError(f"Expected length { 32 } for field read_size_kb_hist, got {len(val)}") - cdef _cyb_view.array arr = _cyb_view.array(shape=(32,), itemsize=sizeof(uint64_t), format="Q", mode="c") - arr[:] = _numpy.asarray(val, dtype=_numpy.uint64) - _cyb_memcpy((&(self._ptr[0].read_size_kb_hist)), (arr.data), sizeof(uint64_t) * len(val)) + _val_ = _numpy.ascontiguousarray(_numpy.asarray(val, dtype=_numpy.uint64)) + _cyb_memcpy((&(self._ptr[0].read_size_kb_hist)), (_val_.ctypes.data), sizeof(uint64_t) * (32)) @property def write_size_kb_hist(self): """~_numpy.uint64: (array of length 32).""" - cdef _cyb_view.array arr = _cyb_view.array(shape=(32,), itemsize=sizeof(uint64_t), format="Q", mode="c", allocate_buffer=False) - arr.data = (&(self._ptr[0].write_size_kb_hist)) - return _numpy.asarray(arr) + cdef object _mv_ = _cyb_PyMemoryView_FromMemory( + (&(self._ptr[0].write_size_kb_hist)), + (sizeof(uint64_t) * (32)), + _cyb_cpython_buffer.PyBUF_WRITE if not self._readonly else _cyb_cpython_buffer.PyBUF_READ, + ) + return _numpy.frombuffer(_mv_, dtype=_numpy.uint64) @write_size_kb_hist.setter def write_size_kb_hist(self, val): @@ -2559,9 +2564,8 @@ cdef class StatsLevel2: raise ValueError("This StatsLevel2 instance is read-only") if len(val) != 32: raise ValueError(f"Expected length { 32 } for field write_size_kb_hist, got {len(val)}") - cdef _cyb_view.array arr = _cyb_view.array(shape=(32,), itemsize=sizeof(uint64_t), format="Q", mode="c") - arr[:] = _numpy.asarray(val, dtype=_numpy.uint64) - _cyb_memcpy((&(self._ptr[0].write_size_kb_hist)), (arr.data), sizeof(uint64_t) * len(val)) + _val_ = _numpy.ascontiguousarray(_numpy.asarray(val, dtype=_numpy.uint64)) + _cyb_memcpy((&(self._ptr[0].write_size_kb_hist)), (_val_.ctypes.data), sizeof(uint64_t) * (32)) @staticmethod def from_buffer(buffer): diff --git a/cuda_bindings/cuda/bindings/nvml.pxd b/cuda_bindings/cuda/bindings/nvml.pxd index ce3c1db4852..02d0652ca2c 100644 --- a/cuda_bindings/cuda/bindings/nvml.pxd +++ b/cuda_bindings/cuda/bindings/nvml.pxd @@ -3,7 +3,7 @@ # SPDX-License-Identifier: Apache-2.0 # # This code was automatically generated across versions from 12.9.1 to 13.3.0. Do not modify it directly. -# CYTHON-BINDINGS-GENERATED-DO-NOT-MODIFY-THIS-FILE: format=1; content-sha256=b6fe9a4efd0077f8c09ef4f826880ad0a54100455d4465953c4127d3de8c4d91 +# CYTHON-BINDINGS-GENERATED-DO-NOT-MODIFY-THIS-FILE: format=1; content-sha256=c45bc4c9772d2e6fe0163353f54a44655db866a025cc1adab756e44df3b39731 @@ -62,7 +62,6 @@ ctypedef nvmlUnrepairableMemoryStatus_v1_t UnrepairableMemoryStatus_v1 ctypedef nvmlRusdSettings_v1_t RusdSettings_v1 ctypedef nvmlPowerValue_v2_t PowerValue_v2 ctypedef nvmlVgpuTypeMaxInstance_v1_t VgpuTypeMaxInstance_v1 -ctypedef nvmlVgpuProcessUtilizationSample_t VgpuProcessUtilizationSample ctypedef nvmlGpuFabricInfo_t GpuFabricInfo ctypedef nvmlSystemEventSetCreateRequest_v1_t SystemEventSetCreateRequest_v1 ctypedef nvmlSystemEventSetFreeRequest_v1_t SystemEventSetFreeRequest_v1 @@ -163,6 +162,7 @@ cpdef int system_get_cuda_driver_version() except * cpdef int system_get_cuda_driver_version_v2() except 0 cpdef str system_get_process_name(unsigned int pid) cpdef object system_get_hic_version() +cpdef object system_get_topology_gpu_set(unsigned int cpu_number) cpdef unsigned int unit_get_count() except? 0 cpdef intptr_t unit_get_handle_by_index(unsigned int index) except? 0 cpdef object unit_get_unit_info(intptr_t unit) @@ -170,6 +170,7 @@ cpdef object unit_get_led_state(intptr_t unit) cpdef object unit_get_psu_info(intptr_t unit) cpdef unsigned int unit_get_temperature(intptr_t unit, unsigned int type) except? 0 cpdef object unit_get_fan_speed_info(intptr_t unit) +cpdef object unit_get_devices(intptr_t unit) cpdef unsigned int device_get_count_v2() except? 0 cpdef object device_get_attributes_v2(intptr_t device) cpdef intptr_t device_get_handle_by_index_v2(unsigned int index) except? 0 @@ -189,6 +190,7 @@ cpdef device_set_cpu_affinity(intptr_t device) cpdef device_clear_cpu_affinity(intptr_t device) cpdef unsigned int device_get_numa_node_id(intptr_t device) except? 0 cpdef int device_get_topology_common_ancestor(intptr_t device1, intptr_t device2) except? -1 +cpdef object device_get_topology_nearest_gpus(intptr_t device, int level) cpdef int device_get_p2p_status(intptr_t device1, intptr_t device2, int p2p_index) except? -1 cpdef str device_get_uuid(intptr_t device) cpdef unsigned int device_get_minor_number(intptr_t device) except? 0 @@ -271,6 +273,7 @@ cpdef object device_get_graphics_running_processes_v3(intptr_t device) cpdef object device_get_mps_compute_running_processes_v3(intptr_t device) cpdef int device_on_same_board(intptr_t device1, intptr_t device2) except? 0 cpdef int device_get_api_restriction(intptr_t device, int api_type) except? -1 +cpdef tuple device_get_samples(intptr_t device, int type, unsigned long long last_seen_time_stamp) cpdef object device_get_bar1_memory_info(intptr_t device) cpdef unsigned int device_get_irq_num(intptr_t device) except? 0 cpdef unsigned int device_get_num_gpu_cores(intptr_t device) except? 0 @@ -297,6 +300,7 @@ cpdef object device_get_accounting_stats(intptr_t device, unsigned int pid) cpdef object device_get_accounting_pids(intptr_t device) cpdef unsigned int device_get_accounting_buffer_size(intptr_t device) except? 0 cpdef object device_get_retired_pages(intptr_t device, int cause) +cpdef tuple device_get_retired_pages_v2(intptr_t device, int cause) cpdef int device_get_retired_pages_pending_status(intptr_t device) except? -1 cpdef tuple device_get_remapped_rows(intptr_t device) cpdef object device_get_row_remapper_histogram(intptr_t device) @@ -352,6 +356,8 @@ cpdef device_set_vgpu_capabilities(intptr_t device, int capability, int state) cpdef object device_get_grid_licensable_features_v4(intptr_t device) cpdef unsigned int get_vgpu_driver_capabilities(int capability) except? 0 cpdef unsigned int device_get_vgpu_capabilities(intptr_t device, int capability) except? 0 +cpdef object device_get_supported_vgpus(intptr_t device) +cpdef object device_get_creatable_vgpus(intptr_t device) cpdef str vgpu_type_get_class(unsigned int vgpu_type_id) cpdef unsigned int vgpu_type_get_gpu_instance_profile_id(unsigned int vgpu_type_id) except? 0 cpdef tuple vgpu_type_get_device_id(unsigned int vgpu_type_id) @@ -363,6 +369,8 @@ cpdef unsigned int vgpu_type_get_frame_rate_limit(unsigned int vgpu_type_id) exc cpdef unsigned int vgpu_type_get_max_instances(intptr_t device, unsigned int vgpu_type_id) except? 0 cpdef unsigned int vgpu_type_get_max_instances_per_vm(unsigned int vgpu_type_id) except? 0 cpdef object vgpu_type_get_bar1_info(unsigned int vgpu_type_id) +cpdef object device_get_active_vgpus(intptr_t device) +cpdef tuple vgpu_instance_get_vm_id(unsigned int vgpu_instance) cpdef str vgpu_instance_get_uuid(unsigned int vgpu_instance) cpdef str vgpu_instance_get_vm_driver_version(unsigned int vgpu_instance) cpdef unsigned long long vgpu_instance_get_fb_usage(unsigned int vgpu_instance) except? 0 @@ -388,8 +396,10 @@ cpdef object device_get_vgpu_scheduler_log(intptr_t device) cpdef object device_get_vgpu_scheduler_state(intptr_t device) cpdef object device_get_vgpu_scheduler_capabilities(intptr_t device) cpdef device_set_vgpu_scheduler_state(intptr_t device, intptr_t p_scheduler_state) +cpdef tuple get_vgpu_version() cpdef set_vgpu_version(intptr_t vgpu_version) -cpdef tuple device_get_vgpu_process_utilization(intptr_t device, unsigned long long last_seen_time_stamp) +cpdef tuple device_get_vgpu_utilization(intptr_t device, unsigned long long last_seen_time_stamp) +cpdef object device_get_vgpu_process_utilization(intptr_t device, unsigned long long last_seen_time_stamp) cpdef int vgpu_instance_get_accounting_mode(unsigned int vgpu_instance) except? -1 cpdef object vgpu_instance_get_accounting_pids(unsigned int vgpu_instance) cpdef object vgpu_instance_get_accounting_stats(unsigned int vgpu_instance, unsigned int pid) @@ -404,6 +414,7 @@ cpdef unsigned int device_get_gpu_instance_remaining_capacity(intptr_t device, u cpdef intptr_t device_create_gpu_instance(intptr_t device, unsigned int profile_id) except? 0 cpdef intptr_t device_create_gpu_instance_with_placement(intptr_t device, unsigned int profile_id, intptr_t placement) except? 0 cpdef gpu_instance_destroy(intptr_t gpu_instance) +cpdef object device_get_gpu_instances(intptr_t device, unsigned int profile_id) cpdef intptr_t device_get_gpu_instance_by_id(intptr_t device, unsigned int id) except? 0 cpdef object gpu_instance_get_info(intptr_t gpu_instance) cpdef object gpu_instance_get_compute_instance_profile_info_v(intptr_t gpu_instance, unsigned int profile, unsigned int eng_profile) @@ -412,6 +423,7 @@ cpdef object gpu_instance_get_compute_instance_possible_placements(intptr_t gpu_ cpdef intptr_t gpu_instance_create_compute_instance(intptr_t gpu_instance, unsigned int profile_id) except? 0 cpdef intptr_t gpu_instance_create_compute_instance_with_placement(intptr_t gpu_instance, unsigned int profile_id, intptr_t placement) except? 0 cpdef compute_instance_destroy(intptr_t compute_instance) +cpdef object gpu_instance_get_compute_instances(intptr_t gpu_instance, unsigned int profile_id) cpdef intptr_t gpu_instance_get_compute_instance_by_id(intptr_t gpu_instance, unsigned int id) except? 0 cpdef object compute_instance_get_info_v2(intptr_t compute_instance) cpdef unsigned int device_is_mig_device_handle(intptr_t device) except? 0 diff --git a/cuda_bindings/cuda/bindings/nvml.pyx b/cuda_bindings/cuda/bindings/nvml.pyx index 4378e667d06..b733ae368cb 100644 --- a/cuda_bindings/cuda/bindings/nvml.pyx +++ b/cuda_bindings/cuda/bindings/nvml.pyx @@ -3,7 +3,7 @@ # SPDX-License-Identifier: Apache-2.0 # # This code was automatically generated across versions from 12.9.1 to 13.3.0. Do not modify it directly. -# CYTHON-BINDINGS-GENERATED-DO-NOT-MODIFY-THIS-FILE: format=1; content-sha256=9167da2a3d3194c67c44a0fe8d4d34b3dbd3c0f43061c50b7d238d2044c75509 +# CYTHON-BINDINGS-GENERATED-DO-NOT-MODIFY-THIS-FILE: format=1; content-sha256=dc032d886d7592e4b97099b851b448d1448645b69c1f45b95f390d5e5ae65809 # <<<< PREAMBLE CONTENT >>>> @@ -11,7 +11,7 @@ cimport cpython as _cyb_cpython cimport cpython.buffer as _cyb_cpython_buffer cimport cpython.memoryview as _cyb_cpython_memoryview -from cython cimport view as _cyb_view +from cpython.memoryview cimport PyMemoryView_FromMemory as _cyb_PyMemoryView_FromMemory from libc.stdint cimport intptr_t from libc.stdlib cimport ( calloc as _cyb_calloc, @@ -69,7 +69,7 @@ cdef _cyb_from_data(data, dtype_name, expected_dtype, lowpp_type): # <<<< END OF PREAMBLE CONTENT >>>> cimport cython # NOQA -from cython cimport view +import numpy as _numpy cimport cpython from libc.string cimport memcpy @@ -4308,7 +4308,7 @@ cdef _get_value_dtype_offsets(): cdef nvmlValue_t pod return _numpy.dtype({ 'names': ['d_val', 'si_val', 'ui_val', 'ul_val', 'ull_val', 'sll_val', 'us_val'], - 'formats': [_numpy.float64, _numpy.int32, _numpy.uint32, _numpy.uint32, _numpy.uint64, _numpy.int64, _numpy.uint16], + 'formats': [_numpy.float64, _numpy.int32, _numpy.uint32, _numpy.uint, _numpy.uint64, _numpy.int64, _numpy.uint16], 'offsets': [ (&(pod.dVal)) - (&pod), (&(pod.siVal)) - (&pod), @@ -6024,9 +6024,12 @@ cdef class PlatformInfo_v1: @property def ib_guid(self): """~_numpy.uint8: (array of length 16).Infiniband GUID reported by platform (for Blackwell, ibGuid is 8 bytes so indices 8-15 are zero).""" - cdef _cyb_view.array arr = _cyb_view.array(shape=(16,), itemsize=sizeof(unsigned char), format="B", mode="c", allocate_buffer=False) - arr.data = (&(self._ptr[0].ibGuid)) - return _numpy.asarray(arr) + cdef object _mv_ = _cyb_PyMemoryView_FromMemory( + (&(self._ptr[0].ibGuid)), + (sizeof(unsigned char) * (16)), + _cyb_cpython_buffer.PyBUF_WRITE if not self._readonly else _cyb_cpython_buffer.PyBUF_READ, + ) + return _numpy.frombuffer(_mv_, dtype=_numpy.uint8) @ib_guid.setter def ib_guid(self, val): @@ -6034,16 +6037,18 @@ cdef class PlatformInfo_v1: raise ValueError("This PlatformInfo_v1 instance is read-only") if len(val) != 16: raise ValueError(f"Expected length { 16 } for field ib_guid, got {len(val)}") - cdef _cyb_view.array arr = _cyb_view.array(shape=(16,), itemsize=sizeof(unsigned char), format="B", mode="c") - arr[:] = _numpy.asarray(val, dtype=_numpy.uint8) - _cyb_memcpy((&(self._ptr[0].ibGuid)), (arr.data), sizeof(unsigned char) * len(val)) + _val_ = _numpy.ascontiguousarray(_numpy.asarray(val, dtype=_numpy.uint8)) + _cyb_memcpy((&(self._ptr[0].ibGuid)), (_val_.ctypes.data), sizeof(unsigned char) * (16)) @property def rack_guid(self): """~_numpy.uint8: (array of length 16).GUID of the rack containing this GPU (for Blackwell rackGuid is 13 bytes so indices 13-15 are zero).""" - cdef _cyb_view.array arr = _cyb_view.array(shape=(16,), itemsize=sizeof(unsigned char), format="B", mode="c", allocate_buffer=False) - arr.data = (&(self._ptr[0].rackGuid)) - return _numpy.asarray(arr) + cdef object _mv_ = _cyb_PyMemoryView_FromMemory( + (&(self._ptr[0].rackGuid)), + (sizeof(unsigned char) * (16)), + _cyb_cpython_buffer.PyBUF_WRITE if not self._readonly else _cyb_cpython_buffer.PyBUF_READ, + ) + return _numpy.frombuffer(_mv_, dtype=_numpy.uint8) @rack_guid.setter def rack_guid(self, val): @@ -6051,9 +6056,8 @@ cdef class PlatformInfo_v1: raise ValueError("This PlatformInfo_v1 instance is read-only") if len(val) != 16: raise ValueError(f"Expected length { 16 } for field rack_guid, got {len(val)}") - cdef _cyb_view.array arr = _cyb_view.array(shape=(16,), itemsize=sizeof(unsigned char), format="B", mode="c") - arr[:] = _numpy.asarray(val, dtype=_numpy.uint8) - _cyb_memcpy((&(self._ptr[0].rackGuid)), (arr.data), sizeof(unsigned char) * len(val)) + _val_ = _numpy.ascontiguousarray(_numpy.asarray(val, dtype=_numpy.uint8)) + _cyb_memcpy((&(self._ptr[0].rackGuid)), (_val_.ctypes.data), sizeof(unsigned char) * (16)) @property def chassis_physical_slot_number(self): @@ -6251,9 +6255,12 @@ cdef class PlatformInfo_v2: @property def ib_guid(self): """~_numpy.uint8: (array of length 16).Infiniband GUID reported by platform (for Blackwell, ibGuid is 8 bytes so indices 8-15 are zero).""" - cdef _cyb_view.array arr = _cyb_view.array(shape=(16,), itemsize=sizeof(unsigned char), format="B", mode="c", allocate_buffer=False) - arr.data = (&(self._ptr[0].ibGuid)) - return _numpy.asarray(arr) + cdef object _mv_ = _cyb_PyMemoryView_FromMemory( + (&(self._ptr[0].ibGuid)), + (sizeof(unsigned char) * (16)), + _cyb_cpython_buffer.PyBUF_WRITE if not self._readonly else _cyb_cpython_buffer.PyBUF_READ, + ) + return _numpy.frombuffer(_mv_, dtype=_numpy.uint8) @ib_guid.setter def ib_guid(self, val): @@ -6261,16 +6268,18 @@ cdef class PlatformInfo_v2: raise ValueError("This PlatformInfo_v2 instance is read-only") if len(val) != 16: raise ValueError(f"Expected length { 16 } for field ib_guid, got {len(val)}") - cdef _cyb_view.array arr = _cyb_view.array(shape=(16,), itemsize=sizeof(unsigned char), format="B", mode="c") - arr[:] = _numpy.asarray(val, dtype=_numpy.uint8) - _cyb_memcpy((&(self._ptr[0].ibGuid)), (arr.data), sizeof(unsigned char) * len(val)) + _val_ = _numpy.ascontiguousarray(_numpy.asarray(val, dtype=_numpy.uint8)) + _cyb_memcpy((&(self._ptr[0].ibGuid)), (_val_.ctypes.data), sizeof(unsigned char) * (16)) @property def chassis_serial_number(self): """~_numpy.uint8: (array of length 16).Serial number of the chassis containing this GPU (for Blackwell it is 13 bytes so indices 13-15 are zero).""" - cdef _cyb_view.array arr = _cyb_view.array(shape=(16,), itemsize=sizeof(unsigned char), format="B", mode="c", allocate_buffer=False) - arr.data = (&(self._ptr[0].chassisSerialNumber)) - return _numpy.asarray(arr) + cdef object _mv_ = _cyb_PyMemoryView_FromMemory( + (&(self._ptr[0].chassisSerialNumber)), + (sizeof(unsigned char) * (16)), + _cyb_cpython_buffer.PyBUF_WRITE if not self._readonly else _cyb_cpython_buffer.PyBUF_READ, + ) + return _numpy.frombuffer(_mv_, dtype=_numpy.uint8) @chassis_serial_number.setter def chassis_serial_number(self, val): @@ -6278,9 +6287,8 @@ cdef class PlatformInfo_v2: raise ValueError("This PlatformInfo_v2 instance is read-only") if len(val) != 16: raise ValueError(f"Expected length { 16 } for field chassis_serial_number, got {len(val)}") - cdef _cyb_view.array arr = _cyb_view.array(shape=(16,), itemsize=sizeof(unsigned char), format="B", mode="c") - arr[:] = _numpy.asarray(val, dtype=_numpy.uint8) - _cyb_memcpy((&(self._ptr[0].chassisSerialNumber)), (arr.data), sizeof(unsigned char) * len(val)) + _val_ = _numpy.ascontiguousarray(_numpy.asarray(val, dtype=_numpy.uint8)) + _cyb_memcpy((&(self._ptr[0].chassisSerialNumber)), (_val_.ctypes.data), sizeof(unsigned char) * (16)) @property def slot_number(self): @@ -6671,19 +6679,21 @@ cdef class VgpuPlacementList_v2: """int: IN/OUT: Placement IDs for the vGPU type.""" if self._ptr[0].placementIds == NULL: return [] - cdef _cyb_view.array arr = _cyb_view.array(shape=(self._ptr[0].count,), itemsize=sizeof(unsigned int), format="I", mode="c", allocate_buffer=False) - arr.data = (self._ptr[0].placementIds) - return _numpy.asarray(arr) + cdef object _mv_ = _cyb_PyMemoryView_FromMemory( + (self._ptr[0].placementIds), + (self._ptr[0].count * sizeof(unsigned int)), + _cyb_cpython_buffer.PyBUF_WRITE, + ) + return _numpy.frombuffer(_mv_, dtype=_numpy.uint32) @placement_ids.setter def placement_ids(self, val): if self._readonly: raise ValueError("This VgpuPlacementList_v2 instance is read-only") - cdef _cyb_view.array arr = _cyb_view.array(shape=(len(val),), itemsize=sizeof(unsigned int), format="I", mode="c") - arr[:] = _numpy.asarray(val, dtype=_numpy.uint32) - self._ptr[0].placementIds = (arr.data) + _arr_ = _numpy.ascontiguousarray(_numpy.asarray(val, dtype=_numpy.uint32)) + self._ptr[0].placementIds = _arr_.ctypes.data self._ptr[0].count = len(val) - self._refs["placement_ids"] = arr + self._refs["placement_ids"] = _arr_ @property def mode(self): @@ -6881,6 +6891,233 @@ cdef class VgpuTypeBar1Info_v1: return obj +cdef _get_vgpu_process_utilization_sample_dtype_offsets(): + cdef nvmlVgpuProcessUtilizationSample_t pod + return _numpy.dtype({ + 'names': ['vgpu_instance', 'pid', 'process_name', 'time_stamp', 'sm_util', 'mem_util', 'enc_util', 'dec_util'], + 'formats': [_numpy.uint32, _numpy.uint32, (_numpy.int8, 64), _numpy.uint64, _numpy.uint32, _numpy.uint32, _numpy.uint32, _numpy.uint32], + 'offsets': [ + (&(pod.vgpuInstance)) - (&pod), + (&(pod.pid)) - (&pod), + (&(pod.processName)) - (&pod), + (&(pod.timeStamp)) - (&pod), + (&(pod.smUtil)) - (&pod), + (&(pod.memUtil)) - (&pod), + (&(pod.encUtil)) - (&pod), + (&(pod.decUtil)) - (&pod), + ], + 'itemsize': sizeof(nvmlVgpuProcessUtilizationSample_t), + }) + +vgpu_process_utilization_sample_dtype = _get_vgpu_process_utilization_sample_dtype_offsets() + +cdef class VgpuProcessUtilizationSample: + """Empty-initialize an array of `nvmlVgpuProcessUtilizationSample_t`. + The resulting object is of length `size` and of dtype `vgpu_process_utilization_sample_dtype`. + If default-constructed, the instance represents a single struct. + + Args: + size (int): number of structs, default=1. + + .. seealso:: `nvmlVgpuProcessUtilizationSample_t` + """ + cdef: + readonly object _data + object _owner + + def __init__(self, size=1): + arr = _numpy.empty(size, dtype=vgpu_process_utilization_sample_dtype) + self._data = arr.view(_numpy.recarray) + assert self._data.itemsize == sizeof(nvmlVgpuProcessUtilizationSample_t), \ + f"itemsize {self._data.itemsize} mismatches struct size { sizeof(nvmlVgpuProcessUtilizationSample_t) }" + + def __repr__(self): + if self._data.size > 1: + return f"<{__name__}.VgpuProcessUtilizationSample_Array_{self._data.size} object at {hex(id(self))}>" + else: + return f"<{__name__}.VgpuProcessUtilizationSample object at {hex(id(self))}>" + + @property + def ptr(self): + """Get the pointer address to the data as Python :class:`int`.""" + return self._data.ctypes.data + + cdef intptr_t _get_ptr(self): + return self._data.ctypes.data + + def __int__(self): + if self._data.size > 1: + raise TypeError("int() argument must be a bytes-like object of size 1. " + "To get the pointer address of an array, use .ptr") + return self._data.ctypes.data + + def __len__(self): + return self._data.size + + def __eq__(self, other): + cdef object self_data = self._data + if (not isinstance(other, VgpuProcessUtilizationSample)) or self_data.size != other._data.size or self_data.dtype != other._data.dtype: + return False + return bool((self_data == other._data).all()) + + def __getbuffer__(self, Py_buffer *buffer, int flags): + _cyb_cpython.PyObject_GetBuffer(self._data, buffer, flags) + + def __releasebuffer__(self, Py_buffer *buffer): + _cyb_cpython.PyBuffer_Release(buffer) + + @property + def vgpu_instance(self): + """Union[~_numpy.uint32, int]: """ + if self._data.size == 1: + return int(self._data.vgpu_instance[0]) + return self._data.vgpu_instance + + @vgpu_instance.setter + def vgpu_instance(self, val): + self._data.vgpu_instance = val + + @property + def pid(self): + """Union[~_numpy.uint32, int]: """ + if self._data.size == 1: + return int(self._data.pid[0]) + return self._data.pid + + @pid.setter + def pid(self, val): + self._data.pid = val + + @property + def process_name(self): + """~_numpy.int8: (array of length 64).""" + return self._data.process_name + + @process_name.setter + def process_name(self, val): + self._data.process_name = val + + @property + def time_stamp(self): + """Union[~_numpy.uint64, int]: """ + if self._data.size == 1: + return int(self._data.time_stamp[0]) + return self._data.time_stamp + + @time_stamp.setter + def time_stamp(self, val): + self._data.time_stamp = val + + @property + def sm_util(self): + """Union[~_numpy.uint32, int]: """ + if self._data.size == 1: + return int(self._data.sm_util[0]) + return self._data.sm_util + + @sm_util.setter + def sm_util(self, val): + self._data.sm_util = val + + @property + def mem_util(self): + """Union[~_numpy.uint32, int]: """ + if self._data.size == 1: + return int(self._data.mem_util[0]) + return self._data.mem_util + + @mem_util.setter + def mem_util(self, val): + self._data.mem_util = val + + @property + def enc_util(self): + """Union[~_numpy.uint32, int]: """ + if self._data.size == 1: + return int(self._data.enc_util[0]) + return self._data.enc_util + + @enc_util.setter + def enc_util(self, val): + self._data.enc_util = val + + @property + def dec_util(self): + """Union[~_numpy.uint32, int]: """ + if self._data.size == 1: + return int(self._data.dec_util[0]) + return self._data.dec_util + + @dec_util.setter + def dec_util(self, val): + self._data.dec_util = val + + def __getitem__(self, key): + cdef ssize_t key_ + cdef ssize_t size + if isinstance(key, int): + key_ = key + size = self._data.size + if key_ >= size or key_ <= -(size+1): + raise IndexError("index is out of bounds") + if key_ < 0: + key_ += size + return VgpuProcessUtilizationSample.from_data(self._data[key_:key_+1]) + out = self._data[key] + if isinstance(out, _numpy.recarray) and out.dtype == vgpu_process_utilization_sample_dtype: + return VgpuProcessUtilizationSample.from_data(out) + return out + + def __setitem__(self, key, val): + self._data[key] = val + + @staticmethod + def from_buffer(buffer): + """Create an VgpuProcessUtilizationSample instance with the memory from the given buffer.""" + return VgpuProcessUtilizationSample.from_data(_numpy.frombuffer(buffer, dtype=vgpu_process_utilization_sample_dtype)) + + @staticmethod + def from_data(data): + """Create an VgpuProcessUtilizationSample instance wrapping the given NumPy array. + + Args: + data (_numpy.ndarray): a 1D array of dtype `vgpu_process_utilization_sample_dtype` holding the data. + """ + cdef VgpuProcessUtilizationSample obj = VgpuProcessUtilizationSample.__new__(VgpuProcessUtilizationSample) + if not isinstance(data, _numpy.ndarray): + raise TypeError("data argument must be a NumPy ndarray") + if data.ndim != 1: + raise ValueError("data array must be 1D") + if data.dtype != vgpu_process_utilization_sample_dtype: + raise ValueError("data array must be of dtype vgpu_process_utilization_sample_dtype") + obj._data = data.view(_numpy.recarray) + + return obj + + @staticmethod + def from_ptr(intptr_t ptr, size_t size=1, bint readonly=False, object owner=None): + """Create an VgpuProcessUtilizationSample instance wrapping the given pointer. + + Args: + ptr (intptr_t): pointer address as Python :class:`int` to the data. + size (int): number of structs, default=1. + readonly (bool): whether the data is read-only (to the user). default is `False`. + owner (object): object that owns the memory at *ptr*. A strong reference is + kept so the backing storage outlives this wrapper. + """ + if ptr == 0: + raise ValueError("ptr must not be null (0)") + cdef VgpuProcessUtilizationSample obj = VgpuProcessUtilizationSample.__new__(VgpuProcessUtilizationSample) + cdef flag = _cyb_cpython_buffer.PyBUF_READ if readonly else _cyb_cpython_buffer.PyBUF_WRITE + cdef object buf = _cyb_cpython_memoryview.PyMemoryView_FromMemory( + ptr, sizeof(nvmlVgpuProcessUtilizationSample_t) * size, flag) + data = _numpy.ndarray(size, buffer=buf, dtype=vgpu_process_utilization_sample_dtype) + obj._data = data.view(_numpy.recarray) + obj._owner = owner + + return obj + + cdef _get_vgpu_process_utilization_info_v1_dtype_offsets(): cdef nvmlVgpuProcessUtilizationInfo_v1_t pod return _numpy.dtype({ @@ -7974,9 +8211,12 @@ cdef class VgpuSchedulerCapabilities: @property def supported_schedulers(self): """~_numpy.uint32: (array of length 3).""" - cdef _cyb_view.array arr = _cyb_view.array(shape=(3,), itemsize=sizeof(unsigned int), format="I", mode="c", allocate_buffer=False) - arr.data = (&(self._ptr[0].supportedSchedulers)) - return _numpy.asarray(arr) + cdef object _mv_ = _cyb_PyMemoryView_FromMemory( + (&(self._ptr[0].supportedSchedulers)), + (sizeof(unsigned int) * (3)), + _cyb_cpython_buffer.PyBUF_WRITE if not self._readonly else _cyb_cpython_buffer.PyBUF_READ, + ) + return _numpy.frombuffer(_mv_, dtype=_numpy.uint32) @supported_schedulers.setter def supported_schedulers(self, val): @@ -7984,9 +8224,8 @@ cdef class VgpuSchedulerCapabilities: raise ValueError("This VgpuSchedulerCapabilities instance is read-only") if len(val) != 3: raise ValueError(f"Expected length { 3 } for field supported_schedulers, got {len(val)}") - cdef _cyb_view.array arr = _cyb_view.array(shape=(3,), itemsize=sizeof(unsigned int), format="I", mode="c") - arr[:] = _numpy.asarray(val, dtype=_numpy.uint32) - _cyb_memcpy((&(self._ptr[0].supportedSchedulers)), (arr.data), sizeof(unsigned int) * len(val)) + _val_ = _numpy.ascontiguousarray(_numpy.asarray(val, dtype=_numpy.uint32)) + _cyb_memcpy((&(self._ptr[0].supportedSchedulers)), (_val_.ctypes.data), sizeof(unsigned int) * (3)) @property def max_timeslice(self): @@ -8611,19 +8850,21 @@ cdef class VgpuTypeIdInfo_v1: """int: OUT: List of vGPU type IDs.""" if self._ptr[0].vgpuTypeIds == NULL: return [] - cdef _cyb_view.array arr = _cyb_view.array(shape=(self._ptr[0].vgpuCount,), itemsize=sizeof(unsigned int), format="I", mode="c", allocate_buffer=False) - arr.data = (self._ptr[0].vgpuTypeIds) - return _numpy.asarray(arr) + cdef object _mv_ = _cyb_PyMemoryView_FromMemory( + (self._ptr[0].vgpuTypeIds), + (self._ptr[0].vgpuCount * sizeof(unsigned int)), + _cyb_cpython_buffer.PyBUF_WRITE, + ) + return _numpy.frombuffer(_mv_, dtype=_numpy.uint32) @vgpu_type_ids.setter def vgpu_type_ids(self, val): if self._readonly: raise ValueError("This VgpuTypeIdInfo_v1 instance is read-only") - cdef _cyb_view.array arr = _cyb_view.array(shape=(len(val),), itemsize=sizeof(unsigned int), format="I", mode="c") - arr[:] = _numpy.asarray(val, dtype=_numpy.uint32) - self._ptr[0].vgpuTypeIds = (arr.data) + _arr_ = _numpy.ascontiguousarray(_numpy.asarray(val, dtype=_numpy.uint32)) + self._ptr[0].vgpuTypeIds = _arr_.ctypes.data self._ptr[0].vgpuCount = len(val) - self._refs["vgpu_type_ids"] = arr + self._refs["vgpu_type_ids"] = _arr_ @staticmethod def from_buffer(buffer): @@ -8766,19 +9007,21 @@ cdef class ActiveVgpuInstanceInfo_v1: """int: IN/OUT: list of active vGPU instances.""" if self._ptr[0].vgpuInstances == NULL: return [] - cdef _cyb_view.array arr = _cyb_view.array(shape=(self._ptr[0].vgpuCount,), itemsize=sizeof(unsigned int), format="I", mode="c", allocate_buffer=False) - arr.data = (self._ptr[0].vgpuInstances) - return _numpy.asarray(arr) + cdef object _mv_ = _cyb_PyMemoryView_FromMemory( + (self._ptr[0].vgpuInstances), + (self._ptr[0].vgpuCount * sizeof(unsigned int)), + _cyb_cpython_buffer.PyBUF_WRITE, + ) + return _numpy.frombuffer(_mv_, dtype=_numpy.uint32) @vgpu_instances.setter def vgpu_instances(self, val): if self._readonly: raise ValueError("This ActiveVgpuInstanceInfo_v1 instance is read-only") - cdef _cyb_view.array arr = _cyb_view.array(shape=(len(val),), itemsize=sizeof(unsigned int), format="I", mode="c") - arr[:] = _numpy.asarray(val, dtype=_numpy.uint32) - self._ptr[0].vgpuInstances = (arr.data) + _arr_ = _numpy.ascontiguousarray(_numpy.asarray(val, dtype=_numpy.uint32)) + self._ptr[0].vgpuInstances = _arr_.ctypes.data self._ptr[0].vgpuCount = len(val) - self._refs["vgpu_instances"] = arr + self._refs["vgpu_instances"] = _arr_ @staticmethod def from_buffer(buffer): @@ -8945,19 +9188,21 @@ cdef class VgpuCreatablePlacementInfo_v1: """int: IN/OUT: Placement IDs for the vGPU type.""" if self._ptr[0].placementIds == NULL: return [] - cdef _cyb_view.array arr = _cyb_view.array(shape=(self._ptr[0].placementSize,), itemsize=sizeof(unsigned int), format="I", mode="c", allocate_buffer=False) - arr.data = (self._ptr[0].placementIds) - return _numpy.asarray(arr) + cdef object _mv_ = _cyb_PyMemoryView_FromMemory( + (self._ptr[0].placementIds), + (self._ptr[0].placementSize * sizeof(unsigned int)), + _cyb_cpython_buffer.PyBUF_WRITE, + ) + return _numpy.frombuffer(_mv_, dtype=_numpy.uint32) @placement_ids.setter def placement_ids(self, val): if self._readonly: raise ValueError("This VgpuCreatablePlacementInfo_v1 instance is read-only") - cdef _cyb_view.array arr = _cyb_view.array(shape=(len(val),), itemsize=sizeof(unsigned int), format="I", mode="c") - arr[:] = _numpy.asarray(val, dtype=_numpy.uint32) - self._ptr[0].placementIds = (arr.data) + _arr_ = _numpy.ascontiguousarray(_numpy.asarray(val, dtype=_numpy.uint32)) + self._ptr[0].placementIds = _arr_.ctypes.data self._ptr[0].placementSize = len(val) - self._refs["placement_ids"] = arr + self._refs["placement_ids"] = _arr_ @staticmethod def from_buffer(buffer): @@ -11710,9 +11955,12 @@ cdef class ConfComputeGpuCertificate: """~_numpy.uint8: (array of length 4096).""" if self._ptr[0].certChainSize == 0: return _numpy.array([]) - cdef _cyb_view.array arr = _cyb_view.array(shape=(self._ptr[0].certChainSize,), itemsize=sizeof(unsigned char), format="B", mode="c", allocate_buffer=False) - arr.data = (&(self._ptr[0].certChain)) - return _numpy.asarray(arr) + cdef object _mv_ = _cyb_PyMemoryView_FromMemory( + (&(self._ptr[0].certChain)), + (sizeof(unsigned char) * (self._ptr[0].certChainSize)), + _cyb_cpython_buffer.PyBUF_WRITE if not self._readonly else _cyb_cpython_buffer.PyBUF_READ, + ) + return _numpy.frombuffer(_mv_, dtype=_numpy.uint8) @cert_chain.setter def cert_chain(self, val): @@ -11723,18 +11971,20 @@ cdef class ConfComputeGpuCertificate: self._ptr[0].certChainSize = len(val) if len(val) == 0: return - cdef _cyb_view.array arr = _cyb_view.array(shape=(self._ptr[0].certChainSize,), itemsize=sizeof(unsigned char), format="B", mode="c") - arr[:] = _numpy.asarray(val, dtype=_numpy.uint8) - _cyb_memcpy((&(self._ptr[0].certChain)), (arr.data), sizeof(unsigned char) * len(val)) + _val_ = _numpy.ascontiguousarray(_numpy.asarray(val, dtype=_numpy.uint8)) + _cyb_memcpy((&(self._ptr[0].certChain)), (_val_.ctypes.data), sizeof(unsigned char) * (self._ptr[0].certChainSize)) @property def attestation_cert_chain(self): """~_numpy.uint8: (array of length 5120).""" if self._ptr[0].attestationCertChainSize == 0: return _numpy.array([]) - cdef _cyb_view.array arr = _cyb_view.array(shape=(self._ptr[0].attestationCertChainSize,), itemsize=sizeof(unsigned char), format="B", mode="c", allocate_buffer=False) - arr.data = (&(self._ptr[0].attestationCertChain)) - return _numpy.asarray(arr) + cdef object _mv_ = _cyb_PyMemoryView_FromMemory( + (&(self._ptr[0].attestationCertChain)), + (sizeof(unsigned char) * (self._ptr[0].attestationCertChainSize)), + _cyb_cpython_buffer.PyBUF_WRITE if not self._readonly else _cyb_cpython_buffer.PyBUF_READ, + ) + return _numpy.frombuffer(_mv_, dtype=_numpy.uint8) @attestation_cert_chain.setter def attestation_cert_chain(self, val): @@ -11745,9 +11995,8 @@ cdef class ConfComputeGpuCertificate: self._ptr[0].attestationCertChainSize = len(val) if len(val) == 0: return - cdef _cyb_view.array arr = _cyb_view.array(shape=(self._ptr[0].attestationCertChainSize,), itemsize=sizeof(unsigned char), format="B", mode="c") - arr[:] = _numpy.asarray(val, dtype=_numpy.uint8) - _cyb_memcpy((&(self._ptr[0].attestationCertChain)), (arr.data), sizeof(unsigned char) * len(val)) + _val_ = _numpy.ascontiguousarray(_numpy.asarray(val, dtype=_numpy.uint8)) + _cyb_memcpy((&(self._ptr[0].attestationCertChain)), (_val_.ctypes.data), sizeof(unsigned char) * (self._ptr[0].attestationCertChainSize)) @staticmethod def from_buffer(buffer): @@ -11888,9 +12137,12 @@ cdef class ConfComputeGpuAttestationReport: @property def nonce(self): """~_numpy.uint8: (array of length 32).""" - cdef _cyb_view.array arr = _cyb_view.array(shape=(32,), itemsize=sizeof(unsigned char), format="B", mode="c", allocate_buffer=False) - arr.data = (&(self._ptr[0].nonce)) - return _numpy.asarray(arr) + cdef object _mv_ = _cyb_PyMemoryView_FromMemory( + (&(self._ptr[0].nonce)), + (sizeof(unsigned char) * (32)), + _cyb_cpython_buffer.PyBUF_WRITE if not self._readonly else _cyb_cpython_buffer.PyBUF_READ, + ) + return _numpy.frombuffer(_mv_, dtype=_numpy.uint8) @nonce.setter def nonce(self, val): @@ -11898,18 +12150,20 @@ cdef class ConfComputeGpuAttestationReport: raise ValueError("This ConfComputeGpuAttestationReport instance is read-only") if len(val) != 32: raise ValueError(f"Expected length { 32 } for field nonce, got {len(val)}") - cdef _cyb_view.array arr = _cyb_view.array(shape=(32,), itemsize=sizeof(unsigned char), format="B", mode="c") - arr[:] = _numpy.asarray(val, dtype=_numpy.uint8) - _cyb_memcpy((&(self._ptr[0].nonce)), (arr.data), sizeof(unsigned char) * len(val)) + _val_ = _numpy.ascontiguousarray(_numpy.asarray(val, dtype=_numpy.uint8)) + _cyb_memcpy((&(self._ptr[0].nonce)), (_val_.ctypes.data), sizeof(unsigned char) * (32)) @property def attestation_report(self): """~_numpy.uint8: (array of length 8192).""" if self._ptr[0].attestationReportSize == 0: return _numpy.array([]) - cdef _cyb_view.array arr = _cyb_view.array(shape=(self._ptr[0].attestationReportSize,), itemsize=sizeof(unsigned char), format="B", mode="c", allocate_buffer=False) - arr.data = (&(self._ptr[0].attestationReport)) - return _numpy.asarray(arr) + cdef object _mv_ = _cyb_PyMemoryView_FromMemory( + (&(self._ptr[0].attestationReport)), + (sizeof(unsigned char) * (self._ptr[0].attestationReportSize)), + _cyb_cpython_buffer.PyBUF_WRITE if not self._readonly else _cyb_cpython_buffer.PyBUF_READ, + ) + return _numpy.frombuffer(_mv_, dtype=_numpy.uint8) @attestation_report.setter def attestation_report(self, val): @@ -11920,18 +12174,20 @@ cdef class ConfComputeGpuAttestationReport: self._ptr[0].attestationReportSize = len(val) if len(val) == 0: return - cdef _cyb_view.array arr = _cyb_view.array(shape=(self._ptr[0].attestationReportSize,), itemsize=sizeof(unsigned char), format="B", mode="c") - arr[:] = _numpy.asarray(val, dtype=_numpy.uint8) - _cyb_memcpy((&(self._ptr[0].attestationReport)), (arr.data), sizeof(unsigned char) * len(val)) + _val_ = _numpy.ascontiguousarray(_numpy.asarray(val, dtype=_numpy.uint8)) + _cyb_memcpy((&(self._ptr[0].attestationReport)), (_val_.ctypes.data), sizeof(unsigned char) * (self._ptr[0].attestationReportSize)) @property def cec_attestation_report(self): """~_numpy.uint8: (array of length 4096).""" if self._ptr[0].cecAttestationReportSize == 0: return _numpy.array([]) - cdef _cyb_view.array arr = _cyb_view.array(shape=(self._ptr[0].cecAttestationReportSize,), itemsize=sizeof(unsigned char), format="B", mode="c", allocate_buffer=False) - arr.data = (&(self._ptr[0].cecAttestationReport)) - return _numpy.asarray(arr) + cdef object _mv_ = _cyb_PyMemoryView_FromMemory( + (&(self._ptr[0].cecAttestationReport)), + (sizeof(unsigned char) * (self._ptr[0].cecAttestationReportSize)), + _cyb_cpython_buffer.PyBUF_WRITE if not self._readonly else _cyb_cpython_buffer.PyBUF_READ, + ) + return _numpy.frombuffer(_mv_, dtype=_numpy.uint8) @cec_attestation_report.setter def cec_attestation_report(self, val): @@ -11942,9 +12198,8 @@ cdef class ConfComputeGpuAttestationReport: self._ptr[0].cecAttestationReportSize = len(val) if len(val) == 0: return - cdef _cyb_view.array arr = _cyb_view.array(shape=(self._ptr[0].cecAttestationReportSize,), itemsize=sizeof(unsigned char), format="B", mode="c") - arr[:] = _numpy.asarray(val, dtype=_numpy.uint8) - _cyb_memcpy((&(self._ptr[0].cecAttestationReport)), (arr.data), sizeof(unsigned char) * len(val)) + _val_ = _numpy.ascontiguousarray(_numpy.asarray(val, dtype=_numpy.uint8)) + _cyb_memcpy((&(self._ptr[0].cecAttestationReport)), (_val_.ctypes.data), sizeof(unsigned char) * (self._ptr[0].cecAttestationReportSize)) @staticmethod def from_buffer(buffer): @@ -12085,9 +12340,12 @@ cdef class GpuFabricInfo_v2: @property def cluster_uuid(self): """~_numpy.uint8: (array of length 16).Uuid of the cluster to which this GPU belongs.""" - cdef _cyb_view.array arr = _cyb_view.array(shape=(16,), itemsize=sizeof(unsigned char), format="B", mode="c", allocate_buffer=False) - arr.data = (&(self._ptr[0].clusterUuid)) - return _numpy.asarray(arr) + cdef object _mv_ = _cyb_PyMemoryView_FromMemory( + (&(self._ptr[0].clusterUuid)), + (sizeof(unsigned char) * (16)), + _cyb_cpython_buffer.PyBUF_WRITE if not self._readonly else _cyb_cpython_buffer.PyBUF_READ, + ) + return _numpy.frombuffer(_mv_, dtype=_numpy.uint8) @cluster_uuid.setter def cluster_uuid(self, val): @@ -12095,9 +12353,8 @@ cdef class GpuFabricInfo_v2: raise ValueError("This GpuFabricInfo_v2 instance is read-only") if len(val) != 16: raise ValueError(f"Expected length { 16 } for field cluster_uuid, got {len(val)}") - cdef _cyb_view.array arr = _cyb_view.array(shape=(16,), itemsize=sizeof(unsigned char), format="B", mode="c") - arr[:] = _numpy.asarray(val, dtype=_numpy.uint8) - _cyb_memcpy((&(self._ptr[0].clusterUuid)), (arr.data), sizeof(unsigned char) * len(val)) + _val_ = _numpy.ascontiguousarray(_numpy.asarray(val, dtype=_numpy.uint8)) + _cyb_memcpy((&(self._ptr[0].clusterUuid)), (_val_.ctypes.data), sizeof(unsigned char) * (16)) @property def status(self): @@ -12281,9 +12538,12 @@ cdef class NvlinkSupportedBwModes_v1: """~_numpy.uint8: (array of length 23).""" if self._ptr[0].totalBwModes == 0: return _numpy.array([]) - cdef _cyb_view.array arr = _cyb_view.array(shape=(self._ptr[0].totalBwModes,), itemsize=sizeof(unsigned char), format="B", mode="c", allocate_buffer=False) - arr.data = (&(self._ptr[0].bwModes)) - return _numpy.asarray(arr) + cdef object _mv_ = _cyb_PyMemoryView_FromMemory( + (&(self._ptr[0].bwModes)), + (sizeof(unsigned char) * (self._ptr[0].totalBwModes)), + _cyb_cpython_buffer.PyBUF_WRITE if not self._readonly else _cyb_cpython_buffer.PyBUF_READ, + ) + return _numpy.frombuffer(_mv_, dtype=_numpy.uint8) @bw_modes.setter def bw_modes(self, val): @@ -12294,9 +12554,8 @@ cdef class NvlinkSupportedBwModes_v1: self._ptr[0].totalBwModes = len(val) if len(val) == 0: return - cdef _cyb_view.array arr = _cyb_view.array(shape=(self._ptr[0].totalBwModes,), itemsize=sizeof(unsigned char), format="B", mode="c") - arr[:] = _numpy.asarray(val, dtype=_numpy.uint8) - _cyb_memcpy((&(self._ptr[0].bwModes)), (arr.data), sizeof(unsigned char) * len(val)) + _val_ = _numpy.ascontiguousarray(_numpy.asarray(val, dtype=_numpy.uint8)) + _cyb_memcpy((&(self._ptr[0].bwModes)), (_val_.ctypes.data), sizeof(unsigned char) * (self._ptr[0].totalBwModes)) @staticmethod def from_buffer(buffer): @@ -15059,9 +15318,12 @@ cdef class GpuFabricInfo_v3: @property def cluster_uuid(self): """~_numpy.uint8: (array of length 16).Uuid of the cluster to which this GPU belongs.""" - cdef _cyb_view.array arr = _cyb_view.array(shape=(16,), itemsize=sizeof(unsigned char), format="B", mode="c", allocate_buffer=False) - arr.data = (&(self._ptr[0].clusterUuid)) - return _numpy.asarray(arr) + cdef object _mv_ = _cyb_PyMemoryView_FromMemory( + (&(self._ptr[0].clusterUuid)), + (sizeof(unsigned char) * (16)), + _cyb_cpython_buffer.PyBUF_WRITE if not self._readonly else _cyb_cpython_buffer.PyBUF_READ, + ) + return _numpy.frombuffer(_mv_, dtype=_numpy.uint8) @cluster_uuid.setter def cluster_uuid(self, val): @@ -15069,9 +15331,8 @@ cdef class GpuFabricInfo_v3: raise ValueError("This GpuFabricInfo_v3 instance is read-only") if len(val) != 16: raise ValueError(f"Expected length { 16 } for field cluster_uuid, got {len(val)}") - cdef _cyb_view.array arr = _cyb_view.array(shape=(16,), itemsize=sizeof(unsigned char), format="B", mode="c") - arr[:] = _numpy.asarray(val, dtype=_numpy.uint8) - _cyb_memcpy((&(self._ptr[0].clusterUuid)), (arr.data), sizeof(unsigned char) * len(val)) + _val_ = _numpy.ascontiguousarray(_numpy.asarray(val, dtype=_numpy.uint8)) + _cyb_memcpy((&(self._ptr[0].clusterUuid)), (_val_.ctypes.data), sizeof(unsigned char) * (16)) @property def status(self): @@ -22909,14 +23170,43 @@ cpdef object system_get_hic_version(): check_status_size(__status__) cdef HwbcEntry hwbc_entries = HwbcEntry(hwbc_count[0]) cdef nvmlHwbcEntry_t *hwbc_entries_ptr = (hwbc_entries._get_ptr()) - if hwbc_count[0] == 0: - return hwbc_entries - with nogil: - __status__ = nvmlSystemGetHicVersion(hwbc_count, hwbc_entries_ptr) - check_status(__status__) + if hwbc_count[0] != 0: + with nogil: + __status__ = nvmlSystemGetHicVersion(hwbc_count, hwbc_entries_ptr) + check_status(__status__) return hwbc_entries +cpdef object system_get_topology_gpu_set(unsigned int cpu_number): + """Retrieve the set of GPUs that have a CPU affinity with the given CPU number For all products. Supported on Linux only. + + Args: + cpu_number (unsigned int): The CPU number. + + Returns: + intptr_t: An array of device handles for GPUs found with + affinity to ``cpu_number``. + + .. seealso:: `nvmlSystemGetTopologyGpuSet` + """ + cdef unsigned int[1] count = [0] + with nogil: + __status__ = nvmlSystemGetTopologyGpuSet(cpu_number, count, NULL) + check_status_size(__status__) + cdef object device_array_alloc + cdef intptr_t _device_array_data_ + cdef intptr_t *device_array_ptr + device_array_alloc = _numpy.empty(max(count[0], 1), dtype=_numpy.intp) + device_array = device_array_alloc[:count[0]] + _device_array_data_ = device_array_alloc.ctypes.data + device_array_ptr = _device_array_data_ + if count[0] != 0: + with nogil: + __status__ = nvmlSystemGetTopologyGpuSet(cpu_number, count, device_array_ptr) + check_status(__status__) + return device_array + + cpdef unsigned int unit_get_count() except? 0: """Retrieves the number of units in the system. @@ -23052,6 +23342,36 @@ cpdef object unit_get_fan_speed_info(intptr_t unit): return fan_speeds_py +cpdef object unit_get_devices(intptr_t unit): + """Retrieves the set of GPU devices that are attached to the specified unit. + + Args: + unit (intptr_t): The identifier of the target unit. + + Returns: + intptr_t: Reference in which to return the references to the + attached GPU devices. + + .. seealso:: `nvmlUnitGetDevices` + """ + cdef unsigned int[1] device_count = [0] + with nogil: + __status__ = nvmlUnitGetDevices(unit, device_count, NULL) + check_status_size(__status__) + cdef object devices_alloc + cdef intptr_t _devices_data_ + cdef intptr_t *devices_ptr + devices_alloc = _numpy.empty(max(device_count[0], 1), dtype=_numpy.intp) + devices = devices_alloc[:device_count[0]] + _devices_data_ = devices_alloc.ctypes.data + devices_ptr = _devices_data_ + if device_count[0] != 0: + with nogil: + __status__ = nvmlUnitGetDevices(unit, device_count, devices_ptr) + check_status(__status__) + return devices + + cpdef unsigned int device_get_count_v2() except? 0: """Retrieves the number of compute devices in the system. A compute device is a single GPU. @@ -23307,10 +23627,13 @@ cpdef object device_get_memory_affinity(intptr_t device, unsigned int node_set_s .. seealso:: `nvmlDeviceGetMemoryAffinity` """ - if node_set_size == 0: - return _cyb_view.array(shape=(1,), itemsize=sizeof(unsigned long), format="L", mode="c")[:0] - cdef _cyb_view.array node_set = _cyb_view.array(shape=(node_set_size,), itemsize=sizeof(unsigned long), format="L", mode="c") - cdef unsigned long *node_set_ptr = (node_set.data) + cdef object node_set_alloc + cdef intptr_t _node_set_data_ + cdef unsigned long *node_set_ptr + node_set_alloc = _numpy.empty(max(node_set_size, 1), dtype=_numpy.uint) + node_set = node_set_alloc[:node_set_size] + _node_set_data_ = node_set_alloc.ctypes.data + node_set_ptr = _node_set_data_ with nogil: __status__ = nvmlDeviceGetMemoryAffinity(device, node_set_size, node_set_ptr, scope) check_status(__status__) @@ -23333,10 +23656,13 @@ cpdef object device_get_cpu_affinity_within_scope(intptr_t device, unsigned int .. seealso:: `nvmlDeviceGetCpuAffinityWithinScope` """ - if cpu_set_size == 0: - return _cyb_view.array(shape=(1,), itemsize=sizeof(unsigned long), format="L", mode="c")[:0] - cdef _cyb_view.array cpu_set = _cyb_view.array(shape=(cpu_set_size,), itemsize=sizeof(unsigned long), format="L", mode="c") - cdef unsigned long *cpu_set_ptr = (cpu_set.data) + cdef object cpu_set_alloc + cdef intptr_t _cpu_set_data_ + cdef unsigned long *cpu_set_ptr + cpu_set_alloc = _numpy.empty(max(cpu_set_size, 1), dtype=_numpy.uint) + cpu_set = cpu_set_alloc[:cpu_set_size] + _cpu_set_data_ = cpu_set_alloc.ctypes.data + cpu_set_ptr = _cpu_set_data_ with nogil: __status__ = nvmlDeviceGetCpuAffinityWithinScope(device, cpu_set_size, cpu_set_ptr, scope) check_status(__status__) @@ -23358,10 +23684,13 @@ cpdef object device_get_cpu_affinity(intptr_t device, unsigned int cpu_set_size) .. seealso:: `nvmlDeviceGetCpuAffinity` """ - if cpu_set_size == 0: - return _cyb_view.array(shape=(1,), itemsize=sizeof(unsigned long), format="L", mode="c")[:0] - cdef _cyb_view.array cpu_set = _cyb_view.array(shape=(cpu_set_size,), itemsize=sizeof(unsigned long), format="L", mode="c") - cdef unsigned long *cpu_set_ptr = (cpu_set.data) + cdef object cpu_set_alloc + cdef intptr_t _cpu_set_data_ + cdef unsigned long *cpu_set_ptr + cpu_set_alloc = _numpy.empty(max(cpu_set_size, 1), dtype=_numpy.uint) + cpu_set = cpu_set_alloc[:cpu_set_size] + _cpu_set_data_ = cpu_set_alloc.ctypes.data + cpu_set_ptr = _cpu_set_data_ with nogil: __status__ = nvmlDeviceGetCpuAffinity(device, cpu_set_size, cpu_set_ptr) check_status(__status__) @@ -23431,22 +23760,54 @@ cpdef int device_get_topology_common_ancestor(intptr_t device1, intptr_t device2 return path_info -cpdef int device_get_p2p_status(intptr_t device1, intptr_t device2, int p2p_index) except? -1: - """Retrieve the status for a given p2p capability index between a given pair of GPU. +cpdef object device_get_topology_nearest_gpus(intptr_t device, int level): + """Retrieve the set of GPUs that are nearest to a given device at a specific interconnectivity level For all products. Supported on Linux only. Args: - device1 (intptr_t): The first device. - device2 (intptr_t): The second device. - p2p_index (GpuP2PCapsIndex): p2p Capability Index being looked - for between ``device1`` and ``device2``. + device (intptr_t): The identifier of the first device. + level (GpuTopologyLevel): The ``nvmlGpuTopologyLevel_t`` level + to search for other GPUs. Returns: - int: Reference in which to return the status of the - ``p2p_index`` between ``device1`` and ``device2``. + intptr_t: An array of device handles for GPUs found at + ``level``. - .. seealso:: `nvmlDeviceGetP2PStatus` + .. seealso:: `nvmlDeviceGetTopologyNearestGpus` """ - cdef _GpuP2PStatus p2p_status + cdef unsigned int[1] count = [0] + with nogil: + __status__ = nvmlDeviceGetTopologyNearestGpus(device, <_GpuTopologyLevel>level, count, NULL) + check_status_size(__status__) + cdef object device_array_alloc + cdef intptr_t _device_array_data_ + cdef intptr_t *device_array_ptr + device_array_alloc = _numpy.empty(max(count[0], 1), dtype=_numpy.intp) + device_array = device_array_alloc[:count[0]] + _device_array_data_ = device_array_alloc.ctypes.data + device_array_ptr = _device_array_data_ + if count[0] != 0: + with nogil: + __status__ = nvmlDeviceGetTopologyNearestGpus(device, <_GpuTopologyLevel>level, count, device_array_ptr) + check_status(__status__) + return device_array + + +cpdef int device_get_p2p_status(intptr_t device1, intptr_t device2, int p2p_index) except? -1: + """Retrieve the status for a given p2p capability index between a given pair of GPU. + + Args: + device1 (intptr_t): The first device. + device2 (intptr_t): The second device. + p2p_index (GpuP2PCapsIndex): p2p Capability Index being looked + for between ``device1`` and ``device2``. + + Returns: + int: Reference in which to return the status of the + ``p2p_index`` between ``device1`` and ``device2``. + + .. seealso:: `nvmlDeviceGetP2PStatus` + """ + cdef _GpuP2PStatus p2p_status with nogil: __status__ = nvmlDeviceGetP2PStatus(device1, device2, <_GpuP2PCapsIndex>p2p_index, &p2p_status) check_status(__status__) @@ -23945,13 +24306,17 @@ cpdef object device_get_supported_memory_clocks(intptr_t device): with nogil: __status__ = nvmlDeviceGetSupportedMemoryClocks(device, count, NULL) check_status_size(__status__) - if count[0] == 0: - return _cyb_view.array(shape=(1,), itemsize=sizeof(unsigned int), format="I", mode="c")[:0] - cdef _cyb_view.array clocks_m_hz = _cyb_view.array(shape=(count[0],), itemsize=sizeof(unsigned int), format="I", mode="c") - cdef unsigned int *clocks_m_hz_ptr = (clocks_m_hz.data) - with nogil: - __status__ = nvmlDeviceGetSupportedMemoryClocks(device, count, clocks_m_hz_ptr) - check_status(__status__) + cdef object clocks_m_hz_alloc + cdef intptr_t _clocks_m_hz_data_ + cdef unsigned int *clocks_m_hz_ptr + clocks_m_hz_alloc = _numpy.empty(max(count[0], 1), dtype=_numpy.uint32) + clocks_m_hz = clocks_m_hz_alloc[:count[0]] + _clocks_m_hz_data_ = clocks_m_hz_alloc.ctypes.data + clocks_m_hz_ptr = _clocks_m_hz_data_ + if count[0] != 0: + with nogil: + __status__ = nvmlDeviceGetSupportedMemoryClocks(device, count, clocks_m_hz_ptr) + check_status(__status__) return clocks_m_hz @@ -23972,13 +24337,17 @@ cpdef object device_get_supported_graphics_clocks(intptr_t device, unsigned int with nogil: __status__ = nvmlDeviceGetSupportedGraphicsClocks(device, memory_clock_m_hz, count, NULL) check_status_size(__status__) - if count[0] == 0: - return _cyb_view.array(shape=(1,), itemsize=sizeof(unsigned int), format="I", mode="c")[:0] - cdef _cyb_view.array clocks_m_hz = _cyb_view.array(shape=(count[0],), itemsize=sizeof(unsigned int), format="I", mode="c") - cdef unsigned int *clocks_m_hz_ptr = (clocks_m_hz.data) - with nogil: - __status__ = nvmlDeviceGetSupportedGraphicsClocks(device, memory_clock_m_hz, count, clocks_m_hz_ptr) - check_status(__status__) + cdef object clocks_m_hz_alloc + cdef intptr_t _clocks_m_hz_data_ + cdef unsigned int *clocks_m_hz_ptr + clocks_m_hz_alloc = _numpy.empty(max(count[0], 1), dtype=_numpy.uint32) + clocks_m_hz = clocks_m_hz_alloc[:count[0]] + _clocks_m_hz_data_ = clocks_m_hz_alloc.ctypes.data + clocks_m_hz_ptr = _clocks_m_hz_data_ + if count[0] != 0: + with nogil: + __status__ = nvmlDeviceGetSupportedGraphicsClocks(device, memory_clock_m_hz, count, clocks_m_hz_ptr) + check_status(__status__) return clocks_m_hz @@ -24829,11 +25198,10 @@ cpdef object device_get_encoder_sessions(intptr_t device): check_status_size(__status__) cdef EncoderSessionInfo session_infos = EncoderSessionInfo(session_count[0]) cdef nvmlEncoderSessionInfo_t *session_infos_ptr = (session_infos._get_ptr()) - if session_count[0] == 0: - return session_infos - with nogil: - __status__ = nvmlDeviceGetEncoderSessions(device, session_count, session_infos_ptr) - check_status(__status__) + if session_count[0] != 0: + with nogil: + __status__ = nvmlDeviceGetEncoderSessions(device, session_count, session_infos_ptr) + check_status(__status__) return session_infos @@ -24947,11 +25315,10 @@ cpdef object device_get_fbc_sessions(intptr_t device): check_status_size(__status__) cdef FBCSessionInfo session_info = FBCSessionInfo(session_count[0]) cdef nvmlFBCSessionInfo_t *session_info_ptr = (session_info._get_ptr()) - if session_count[0] == 0: - return session_info - with nogil: - __status__ = nvmlDeviceGetFBCSessions(device, session_count, session_info_ptr) - check_status(__status__) + if session_count[0] != 0: + with nogil: + __status__ = nvmlDeviceGetFBCSessions(device, session_count, session_info_ptr) + check_status(__status__) return session_info @@ -25034,11 +25401,10 @@ cpdef object device_get_compute_running_processes_v3(intptr_t device): check_status_size(__status__) cdef ProcessInfo infos = ProcessInfo(info_count[0]) cdef nvmlProcessInfo_t *infos_ptr = (infos._get_ptr()) - if info_count[0] == 0: - return infos - with nogil: - __status__ = nvmlDeviceGetComputeRunningProcesses_v3(device, info_count, infos_ptr) - check_status(__status__) + if info_count[0] != 0: + with nogil: + __status__ = nvmlDeviceGetComputeRunningProcesses_v3(device, info_count, infos_ptr) + check_status(__status__) return infos @@ -25060,11 +25426,10 @@ cpdef object device_get_graphics_running_processes_v3(intptr_t device): check_status_size(__status__) cdef ProcessInfo infos = ProcessInfo(info_count[0]) cdef nvmlProcessInfo_t *infos_ptr = (infos._get_ptr()) - if info_count[0] == 0: - return infos - with nogil: - __status__ = nvmlDeviceGetGraphicsRunningProcesses_v3(device, info_count, infos_ptr) - check_status(__status__) + if info_count[0] != 0: + with nogil: + __status__ = nvmlDeviceGetGraphicsRunningProcesses_v3(device, info_count, infos_ptr) + check_status(__status__) return infos @@ -25086,11 +25451,10 @@ cpdef object device_get_mps_compute_running_processes_v3(intptr_t device): check_status_size(__status__) cdef ProcessInfo infos = ProcessInfo(info_count[0]) cdef nvmlProcessInfo_t *infos_ptr = (infos._get_ptr()) - if info_count[0] == 0: - return infos - with nogil: - __status__ = nvmlDeviceGetMPSComputeRunningProcesses_v3(device, info_count, infos_ptr) - check_status(__status__) + if info_count[0] != 0: + with nogil: + __status__ = nvmlDeviceGetMPSComputeRunningProcesses_v3(device, info_count, infos_ptr) + check_status(__status__) return infos @@ -25136,6 +25500,38 @@ cpdef int device_get_api_restriction(intptr_t device, int api_type) except? -1: return is_restricted +cpdef tuple device_get_samples(intptr_t device, int type, unsigned long long last_seen_time_stamp): + """Gets recent samples for the GPU. + + Args: + device (intptr_t): The identifier for the target device. + type (SamplingType): Type of sampling event. + last_seen_time_stamp (unsigned long long): Return only samples + with timestamp greater than last_seen_time_stamp. + + Returns: + A 2-tuple containing: + + - int: Output parameter to represent the type of sample value as + described in nvmlSampleVal_t. + - nvmlSample_t: Reference in which samples are returned. + + .. seealso:: `nvmlDeviceGetSamples` + """ + cdef _ValueType sample_val_type + cdef unsigned int[1] sample_count = [0] + with nogil: + __status__ = nvmlDeviceGetSamples(device, <_SamplingType>type, last_seen_time_stamp, &sample_val_type, sample_count, NULL) + check_status_size(__status__) + cdef Sample samples = Sample(sample_count[0]) + cdef nvmlSample_t *samples_ptr = (samples._get_ptr()) + if not (sample_count[0] == 0): + with nogil: + __status__ = nvmlDeviceGetSamples(device, <_SamplingType>type, last_seen_time_stamp, &sample_val_type, sample_count, samples_ptr) + check_status(__status__) + return (sample_val_type, samples) + + cpdef object device_get_bar1_memory_info(intptr_t device): """Gets Total, Available and Used size of BAR1 memory. @@ -25576,13 +25972,17 @@ cpdef object device_get_accounting_pids(intptr_t device): with nogil: __status__ = nvmlDeviceGetAccountingPids(device, count, NULL) check_status_size(__status__) - if count[0] == 0: - return _cyb_view.array(shape=(1,), itemsize=sizeof(unsigned int), format="I", mode="c")[:0] - cdef _cyb_view.array pids = _cyb_view.array(shape=(count[0],), itemsize=sizeof(unsigned int), format="I", mode="c") - cdef unsigned int *pids_ptr = (pids.data) - with nogil: - __status__ = nvmlDeviceGetAccountingPids(device, count, pids_ptr) - check_status(__status__) + cdef object pids_alloc + cdef intptr_t _pids_data_ + cdef unsigned int *pids_ptr + pids_alloc = _numpy.empty(max(count[0], 1), dtype=_numpy.uint32) + pids = pids_alloc[:count[0]] + _pids_data_ = pids_alloc.ctypes.data + pids_ptr = _pids_data_ + if count[0] != 0: + with nogil: + __status__ = nvmlDeviceGetAccountingPids(device, count, pids_ptr) + check_status(__status__) return pids @@ -25623,16 +26023,62 @@ cpdef object device_get_retired_pages(intptr_t device, int cause): with nogil: __status__ = nvmlDeviceGetRetiredPages(device, <_PageRetirementCause>cause, page_count, NULL) check_status_size(__status__) - if page_count[0] == 0: - return _cyb_view.array(shape=(1,), itemsize=sizeof(unsigned long long), format="Q", mode="c")[:0] - cdef _cyb_view.array addresses = _cyb_view.array(shape=(page_count[0],), itemsize=sizeof(unsigned long long), format="Q", mode="c") - cdef unsigned long long *addresses_ptr = (addresses.data) - with nogil: - __status__ = nvmlDeviceGetRetiredPages(device, <_PageRetirementCause>cause, page_count, addresses_ptr) - check_status(__status__) + cdef object addresses_alloc + cdef intptr_t _addresses_data_ + cdef unsigned long long *addresses_ptr + addresses_alloc = _numpy.empty(max(page_count[0], 1), dtype=_numpy.uint64) + addresses = addresses_alloc[:page_count[0]] + _addresses_data_ = addresses_alloc.ctypes.data + addresses_ptr = _addresses_data_ + if page_count[0] != 0: + with nogil: + __status__ = nvmlDeviceGetRetiredPages(device, <_PageRetirementCause>cause, page_count, addresses_ptr) + check_status(__status__) return addresses +cpdef tuple device_get_retired_pages_v2(intptr_t device, int cause): + """Returns the list of retired pages by source, including pages that are pending retirement The address information provided from this API is the hardware address of the page that was retired. Note that this does not match the virtual address used in CUDA, but will match the address information in Xid 63. + + Args: + device (intptr_t): The identifier of the target device. + cause (PageRetirementCause): Filter page addresses by cause of + retirement. + + Returns: + A 2-tuple containing: + + - unsigned long long: Buffer to write the page addresses into. + - unsigned long long: Buffer to write the timestamps of page + retirement, additional for _v2. + + .. seealso:: `nvmlDeviceGetRetiredPages_v2` + """ + cdef unsigned int[1] page_count = [0] + with nogil: + __status__ = nvmlDeviceGetRetiredPages_v2(device, <_PageRetirementCause>cause, page_count, NULL, NULL) + check_status_size(__status__) + cdef object addresses_alloc + cdef intptr_t _addresses_data_ + cdef unsigned long long *addresses_ptr + addresses_alloc = _numpy.empty(max(page_count[0], 1), dtype=_numpy.uint64) + addresses = addresses_alloc[:page_count[0]] + _addresses_data_ = addresses_alloc.ctypes.data + addresses_ptr = _addresses_data_ + cdef object timestamps_alloc + cdef intptr_t _timestamps_data_ + cdef unsigned long long *timestamps_ptr + timestamps_alloc = _numpy.empty(max(page_count[0], 1), dtype=_numpy.uint64) + timestamps = timestamps_alloc[:page_count[0]] + _timestamps_data_ = timestamps_alloc.ctypes.data + timestamps_ptr = _timestamps_data_ + if not (page_count[0] == 0): + with nogil: + __status__ = nvmlDeviceGetRetiredPages_v2(device, <_PageRetirementCause>cause, page_count, addresses_ptr, timestamps_ptr) + check_status(__status__) + return (addresses, timestamps) + + cpdef int device_get_retired_pages_pending_status(intptr_t device) except? -1: """Check if any pages are pending retirement and need a reboot to fully retire. @@ -25760,11 +26206,10 @@ cpdef object device_get_process_utilization(intptr_t device, unsigned long long check_status_size(__status__) cdef ProcessUtilizationSample utilization = ProcessUtilizationSample(process_samples_count[0]) cdef nvmlProcessUtilizationSample_t *utilization_ptr = (utilization._get_ptr()) - if process_samples_count[0] == 0: - return utilization - with nogil: - __status__ = nvmlDeviceGetProcessUtilization(device, utilization_ptr, process_samples_count, last_seen_time_stamp) - check_status(__status__) + if process_samples_count[0] != 0: + with nogil: + __status__ = nvmlDeviceGetProcessUtilization(device, utilization_ptr, process_samples_count, last_seen_time_stamp) + check_status(__status__) return utilization @@ -26591,6 +27036,66 @@ cpdef unsigned int device_get_vgpu_capabilities(intptr_t device, int capability) return cap_result +cpdef object device_get_supported_vgpus(intptr_t device): + """Retrieve the supported vGPU types on a physical GPU (device). + + Args: + device (intptr_t): The identifier of the target device. + + Returns: + unsigned int: Pointer to caller-supplied array in which to + return list of vGPU types. + + .. seealso:: `nvmlDeviceGetSupportedVgpus` + """ + cdef unsigned int[1] vgpu_count = [0] + with nogil: + __status__ = nvmlDeviceGetSupportedVgpus(device, vgpu_count, NULL) + check_status_size(__status__) + cdef object vgpu_type_ids_alloc + cdef intptr_t _vgpu_type_ids_data_ + cdef nvmlVgpuTypeId_t *vgpu_type_ids_ptr + vgpu_type_ids_alloc = _numpy.empty(max(vgpu_count[0], 1), dtype=_numpy.uint32) + vgpu_type_ids = vgpu_type_ids_alloc[:vgpu_count[0]] + _vgpu_type_ids_data_ = vgpu_type_ids_alloc.ctypes.data + vgpu_type_ids_ptr = _vgpu_type_ids_data_ + if vgpu_count[0] != 0: + with nogil: + __status__ = nvmlDeviceGetSupportedVgpus(device, vgpu_count, vgpu_type_ids_ptr) + check_status(__status__) + return vgpu_type_ids + + +cpdef object device_get_creatable_vgpus(intptr_t device): + """Retrieve the currently creatable vGPU types on a physical GPU (device). + + Args: + device (intptr_t): The identifier of the target device. + + Returns: + unsigned int: Pointer to caller-supplied array in which to + return list of vGPU types. + + .. seealso:: `nvmlDeviceGetCreatableVgpus` + """ + cdef unsigned int[1] vgpu_count = [0] + with nogil: + __status__ = nvmlDeviceGetCreatableVgpus(device, vgpu_count, NULL) + check_status_size(__status__) + cdef object vgpu_type_ids_alloc + cdef intptr_t _vgpu_type_ids_data_ + cdef nvmlVgpuTypeId_t *vgpu_type_ids_ptr + vgpu_type_ids_alloc = _numpy.empty(max(vgpu_count[0], 1), dtype=_numpy.uint32) + vgpu_type_ids = vgpu_type_ids_alloc[:vgpu_count[0]] + _vgpu_type_ids_data_ = vgpu_type_ids_alloc.ctypes.data + vgpu_type_ids_ptr = _vgpu_type_ids_data_ + if vgpu_count[0] != 0: + with nogil: + __status__ = nvmlDeviceGetCreatableVgpus(device, vgpu_count, vgpu_type_ids_ptr) + check_status(__status__) + return vgpu_type_ids + + cpdef str vgpu_type_get_class(unsigned int vgpu_type_id): """Retrieve the class of a vGPU type. It will not exceed 64 characters in length (including the NUL terminator). See nvmlConstants::NVML_DEVICE_NAME_BUFFER_SIZE. @@ -26606,13 +27111,12 @@ cpdef str vgpu_type_get_class(unsigned int vgpu_type_id): with nogil: __status__ = nvmlVgpuTypeGetClass(vgpu_type_id, NULL, size) check_status_size(__status__) - if size[0] == 0: - return "" cdef bytes _vgpu_type_class_ = bytes(size[0]) cdef char* vgpu_type_class = _vgpu_type_class_ - with nogil: - __status__ = nvmlVgpuTypeGetClass(vgpu_type_id, vgpu_type_class, size) - check_status(__status__) + if size[0] != 0: + with nogil: + __status__ = nvmlVgpuTypeGetClass(vgpu_type_id, vgpu_type_class, size) + check_status(__status__) return _cyb_cpython.PyUnicode_FromString(vgpu_type_class) @@ -26817,6 +27321,60 @@ cpdef object vgpu_type_get_bar1_info(unsigned int vgpu_type_id): return bar1info_py +cpdef object device_get_active_vgpus(intptr_t device): + """Retrieve the active vGPU instances on a device. + + Args: + device (intptr_t): The identifier of the target device. + + Returns: + unsigned int: Pointer to array in which to return list of vGPU + instances. + + .. seealso:: `nvmlDeviceGetActiveVgpus` + """ + cdef unsigned int[1] vgpu_count = [0] + with nogil: + __status__ = nvmlDeviceGetActiveVgpus(device, vgpu_count, NULL) + check_status_size(__status__) + cdef object vgpu_instances_alloc + cdef intptr_t _vgpu_instances_data_ + cdef nvmlVgpuInstance_t *vgpu_instances_ptr + vgpu_instances_alloc = _numpy.empty(max(vgpu_count[0], 1), dtype=_numpy.uint32) + vgpu_instances = vgpu_instances_alloc[:vgpu_count[0]] + _vgpu_instances_data_ = vgpu_instances_alloc.ctypes.data + vgpu_instances_ptr = _vgpu_instances_data_ + if vgpu_count[0] != 0: + with nogil: + __status__ = nvmlDeviceGetActiveVgpus(device, vgpu_count, vgpu_instances_ptr) + check_status(__status__) + return vgpu_instances + + +cpdef tuple vgpu_instance_get_vm_id(unsigned int vgpu_instance): + """Retrieve the VM ID associated with a vGPU instance. + + Args: + vgpu_instance (unsigned int): Identifier of the target vGPU + instance. + + Returns: + A 2-tuple containing: + + - char: Pointer to caller-supplied buffer to hold VM ID. + - int: Pointer to hold VM ID type. + + .. seealso:: `nvmlVgpuInstanceGetVmID` + """ + cdef unsigned int size = 80 + cdef char[80] vm_id + cdef _VgpuVmIdType vm_id_type + with nogil: + __status__ = nvmlVgpuInstanceGetVmID(vgpu_instance, vm_id, size, &vm_id_type) + check_status(__status__) + return (_cyb_cpython.PyUnicode_FromString(vm_id), vm_id_type) + + cpdef str vgpu_instance_get_uuid(unsigned int vgpu_instance): """Retrieve the UUID of a vGPU instance. @@ -27035,11 +27593,10 @@ cpdef object vgpu_instance_get_encoder_sessions(unsigned int vgpu_instance): check_status_size(__status__) cdef EncoderSessionInfo session_info = EncoderSessionInfo(session_count[0]) cdef nvmlEncoderSessionInfo_t *session_info_ptr = (session_info._get_ptr()) - if session_count[0] == 0: - return session_info - with nogil: - __status__ = nvmlVgpuInstanceGetEncoderSessions(vgpu_instance, session_count, session_info_ptr) - check_status(__status__) + if session_count[0] != 0: + with nogil: + __status__ = nvmlVgpuInstanceGetEncoderSessions(vgpu_instance, session_count, session_info_ptr) + check_status(__status__) return session_info @@ -27083,11 +27640,10 @@ cpdef object vgpu_instance_get_fbc_sessions(unsigned int vgpu_instance): check_status_size(__status__) cdef FBCSessionInfo session_info = FBCSessionInfo(session_count[0]) cdef nvmlFBCSessionInfo_t *session_info_ptr = (session_info._get_ptr()) - if session_count[0] == 0: - return session_info - with nogil: - __status__ = nvmlVgpuInstanceGetFBCSessions(vgpu_instance, session_count, session_info_ptr) - check_status(__status__) + if session_count[0] != 0: + with nogil: + __status__ = nvmlVgpuInstanceGetFBCSessions(vgpu_instance, session_count, session_info_ptr) + check_status(__status__) return session_info @@ -27126,13 +27682,12 @@ cpdef str vgpu_instance_get_gpu_pci_id(unsigned int vgpu_instance): with nogil: __status__ = nvmlVgpuInstanceGetGpuPciId(vgpu_instance, NULL, length) check_status_size(__status__) - if length[0] == 0: - return "" cdef bytes _vgpu_pci_id_ = bytes(length[0]) cdef char* vgpu_pci_id = _vgpu_pci_id_ - with nogil: - __status__ = nvmlVgpuInstanceGetGpuPciId(vgpu_instance, vgpu_pci_id, length) - check_status(__status__) + if length[0] != 0: + with nogil: + __status__ = nvmlVgpuInstanceGetGpuPciId(vgpu_instance, vgpu_pci_id, length) + check_status(__status__) return _cyb_cpython.PyUnicode_FromString(vgpu_pci_id) @@ -27251,13 +27806,12 @@ cpdef str device_get_pgpu_metadata_string(intptr_t device): with nogil: __status__ = nvmlDeviceGetPgpuMetadataString(device, NULL, buffer_size) check_status_size(__status__) - if buffer_size[0] == 0: - return "" cdef bytes _pgpu_metadata_ = bytes(buffer_size[0]) cdef char* pgpu_metadata = _pgpu_metadata_ - with nogil: - __status__ = nvmlDeviceGetPgpuMetadataString(device, pgpu_metadata, buffer_size) - check_status(__status__) + if buffer_size[0] != 0: + with nogil: + __status__ = nvmlDeviceGetPgpuMetadataString(device, pgpu_metadata, buffer_size) + check_status(__status__) return _cyb_cpython.PyUnicode_FromString(pgpu_metadata) @@ -27336,6 +27890,31 @@ cpdef device_set_vgpu_scheduler_state(intptr_t device, intptr_t p_scheduler_stat check_status(__status__) +cpdef tuple get_vgpu_version(): + """Query the ranges of supported vGPU versions. + + Returns: + A 2-tuple containing: + + - nvmlVgpuVersion_t: Pointer to the structure in which the + preset range of vGPU versions supported by the NVIDIA vGPU + Manager is written. + - nvmlVgpuVersion_t: Pointer to the structure in which the range + of supported vGPU versions set by an administrator is + written. + + .. seealso:: `nvmlGetVgpuVersion` + """ + cdef VgpuVersion supported_py = VgpuVersion() + cdef nvmlVgpuVersion_t *supported = (supported_py._get_ptr()) + cdef VgpuVersion current_py = VgpuVersion() + cdef nvmlVgpuVersion_t *current = (current_py._get_ptr()) + with nogil: + __status__ = nvmlGetVgpuVersion(supported, current) + check_status(__status__) + return (supported_py, current_py) + + cpdef set_vgpu_version(intptr_t vgpu_version): """Override the preset range of vGPU versions supported by the NVIDIA vGPU Manager with a range set by an administrator. @@ -27350,8 +27929,8 @@ cpdef set_vgpu_version(intptr_t vgpu_version): check_status(__status__) -cpdef tuple device_get_vgpu_process_utilization(intptr_t device, unsigned long long last_seen_time_stamp): - """Retrieves current utilization for processes running on vGPUs on a physical GPU (device). +cpdef tuple device_get_vgpu_utilization(intptr_t device, unsigned long long last_seen_time_stamp): + """Retrieves current utilization for vGPUs on a physical GPU (device). Args: device (intptr_t): The identifier for the target device. @@ -27361,20 +27940,54 @@ cpdef tuple device_get_vgpu_process_utilization(intptr_t device, unsigned long l Returns: A 2-tuple containing: - - unsigned int: Pointer to caller-supplied array size, and - returns number of processes running on vGPU instances. - - nvmlVgpuProcessUtilizationSample_t: Pointer to caller-supplied + - int: Pointer to caller-supplied buffer to hold the type of + returned sample values. + - nvmlVgpuInstanceUtilizationSample_t: Pointer to caller- + supplied buffer in which vGPU utilization samples are + returned. + + .. seealso:: `nvmlDeviceGetVgpuUtilization` + """ + cdef _ValueType sample_val_type + cdef unsigned int[1] vgpu_instance_samples_count = [0] + with nogil: + __status__ = nvmlDeviceGetVgpuUtilization(device, last_seen_time_stamp, &sample_val_type, vgpu_instance_samples_count, NULL) + check_status_size(__status__) + cdef VgpuInstanceUtilizationSample utilization_samples = VgpuInstanceUtilizationSample(vgpu_instance_samples_count[0]) + cdef nvmlVgpuInstanceUtilizationSample_t *utilization_samples_ptr = (utilization_samples._get_ptr()) + if not (vgpu_instance_samples_count[0] == 0): + with nogil: + __status__ = nvmlDeviceGetVgpuUtilization(device, last_seen_time_stamp, &sample_val_type, vgpu_instance_samples_count, utilization_samples_ptr) + check_status(__status__) + return (sample_val_type, utilization_samples) + + +cpdef object device_get_vgpu_process_utilization(intptr_t device, unsigned long long last_seen_time_stamp): + """Retrieves current utilization for processes running on vGPUs on a physical GPU (device). + + Args: + device (intptr_t): The identifier for the target device. + last_seen_time_stamp (unsigned long long): Return only samples + with timestamp greater than last_seen_time_stamp. + + Returns: + nvmlVgpuProcessUtilizationSample_t: Pointer to caller-supplied buffer in which vGPU sub process utilization samples are returned. .. seealso:: `nvmlDeviceGetVgpuProcessUtilization` """ - cdef unsigned int vgpu_process_samples_count - cdef nvmlVgpuProcessUtilizationSample_t utilization_samples + cdef unsigned int[1] vgpu_process_samples_count = [0] with nogil: - __status__ = nvmlDeviceGetVgpuProcessUtilization(device, last_seen_time_stamp, &vgpu_process_samples_count, &utilization_samples) - check_status(__status__) - return (vgpu_process_samples_count, utilization_samples) + __status__ = nvmlDeviceGetVgpuProcessUtilization(device, last_seen_time_stamp, vgpu_process_samples_count, NULL) + check_status_size(__status__) + cdef VgpuProcessUtilizationSample utilization_samples = VgpuProcessUtilizationSample(vgpu_process_samples_count[0]) + cdef nvmlVgpuProcessUtilizationSample_t *utilization_samples_ptr = (utilization_samples._get_ptr()) + if vgpu_process_samples_count[0] != 0: + with nogil: + __status__ = nvmlDeviceGetVgpuProcessUtilization(device, last_seen_time_stamp, vgpu_process_samples_count, utilization_samples_ptr) + check_status(__status__) + return utilization_samples cpdef int vgpu_instance_get_accounting_mode(unsigned int vgpu_instance) except? -1: @@ -27413,13 +28026,17 @@ cpdef object vgpu_instance_get_accounting_pids(unsigned int vgpu_instance): with nogil: __status__ = nvmlVgpuInstanceGetAccountingPids(vgpu_instance, count, NULL) check_status_size(__status__) - if count[0] == 0: - return _cyb_view.array(shape=(1,), itemsize=sizeof(unsigned int), format="I", mode="c")[:0] - cdef _cyb_view.array pids = _cyb_view.array(shape=(count[0],), itemsize=sizeof(unsigned int), format="I", mode="c") - cdef unsigned int *pids_ptr = (pids.data) - with nogil: - __status__ = nvmlVgpuInstanceGetAccountingPids(vgpu_instance, count, pids_ptr) - check_status(__status__) + cdef object pids_alloc + cdef intptr_t _pids_data_ + cdef unsigned int *pids_ptr + pids_alloc = _numpy.empty(max(count[0], 1), dtype=_numpy.uint32) + pids = pids_alloc[:count[0]] + _pids_data_ = pids_alloc.ctypes.data + pids_ptr = _pids_data_ + if count[0] != 0: + with nogil: + __status__ = nvmlVgpuInstanceGetAccountingPids(vgpu_instance, count, pids_ptr) + check_status(__status__) return pids @@ -27585,11 +28202,10 @@ cpdef object device_get_gpu_instance_possible_placements_v2(intptr_t device, uns check_status_size(__status__) cdef GpuInstancePlacement placements = GpuInstancePlacement(count[0]) cdef nvmlGpuInstancePlacement_t *placements_ptr = (placements._get_ptr()) - if count[0] == 0: - return placements - with nogil: - __status__ = nvmlDeviceGetGpuInstancePossiblePlacements_v2(device, profile_id, placements_ptr, count) - check_status(__status__) + if count[0] != 0: + with nogil: + __status__ = nvmlDeviceGetGpuInstancePossiblePlacements_v2(device, profile_id, placements_ptr, count) + check_status(__status__) return placements @@ -27669,6 +28285,39 @@ cpdef gpu_instance_destroy(intptr_t gpu_instance): check_status(__status__) +cpdef object device_get_gpu_instances(intptr_t device, unsigned int profile_id): + """Get GPU instances for given profile ID. + + Args: + device (intptr_t): The identifier of the target device. + profile_id (unsigned int): The GPU instance profile ID. See + ``nvmlDeviceGetGpuInstanceProfileInfo``. + + Returns: + intptr_t: Returns pre-exiting GPU instances, the buffer must + be large enough to accommodate the instances supported by + the profile. See ``nvmlDeviceGetGpuInstanceProfileInfo``. + + .. seealso:: `nvmlDeviceGetGpuInstances` + """ + cdef unsigned int[1] count = [0] + with nogil: + __status__ = nvmlDeviceGetGpuInstances(device, profile_id, NULL, count) + check_status_size(__status__) + cdef object gpu_instances_alloc + cdef intptr_t _gpu_instances_data_ + cdef intptr_t *gpu_instances_ptr + gpu_instances_alloc = _numpy.empty(max(count[0], 1), dtype=_numpy.intp) + gpu_instances = gpu_instances_alloc[:count[0]] + _gpu_instances_data_ = gpu_instances_alloc.ctypes.data + gpu_instances_ptr = _gpu_instances_data_ + if count[0] != 0: + with nogil: + __status__ = nvmlDeviceGetGpuInstances(device, profile_id, gpu_instances_ptr, count) + check_status(__status__) + return gpu_instances + + cpdef intptr_t device_get_gpu_instance_by_id(intptr_t device, unsigned int id) except? 0: """Get GPU instances for given instance ID. @@ -27779,11 +28428,10 @@ cpdef object gpu_instance_get_compute_instance_possible_placements(intptr_t gpu_ check_status_size(__status__) cdef ComputeInstancePlacement placements = ComputeInstancePlacement(count[0]) cdef nvmlComputeInstancePlacement_t *placements_ptr = (placements._get_ptr()) - if count[0] == 0: - return placements - with nogil: - __status__ = nvmlGpuInstanceGetComputeInstancePossiblePlacements(gpu_instance, profile_id, placements_ptr, count) - check_status(__status__) + if count[0] != 0: + with nogil: + __status__ = nvmlGpuInstanceGetComputeInstancePossiblePlacements(gpu_instance, profile_id, placements_ptr, count) + check_status(__status__) return placements @@ -27844,6 +28492,41 @@ cpdef compute_instance_destroy(intptr_t compute_instance): check_status(__status__) +cpdef object gpu_instance_get_compute_instances(intptr_t gpu_instance, unsigned int profile_id): + """Get compute instances for given profile ID. + + Args: + gpu_instance (intptr_t): The identifier of the target GPU + instance. + profile_id (unsigned int): The compute instance profile ID. + See ``nvmlGpuInstanceGetComputeInstanceProfileInfo``. + + Returns: + intptr_t: Returns pre-exiting compute instances, the buffer + must be large enough to accommodate the instances + supported by the profile. See + ``nvmlGpuInstanceGetComputeInstanceProfileInfo``. + + .. seealso:: `nvmlGpuInstanceGetComputeInstances` + """ + cdef unsigned int[1] count = [0] + with nogil: + __status__ = nvmlGpuInstanceGetComputeInstances(gpu_instance, profile_id, NULL, count) + check_status_size(__status__) + cdef object compute_instances_alloc + cdef intptr_t _compute_instances_data_ + cdef intptr_t *compute_instances_ptr + compute_instances_alloc = _numpy.empty(max(count[0], 1), dtype=_numpy.intp) + compute_instances = compute_instances_alloc[:count[0]] + _compute_instances_data_ = compute_instances_alloc.ctypes.data + compute_instances_ptr = _compute_instances_data_ + if count[0] != 0: + with nogil: + __status__ = nvmlGpuInstanceGetComputeInstances(gpu_instance, profile_id, compute_instances_ptr, count) + check_status(__status__) + return compute_instances + + cpdef intptr_t gpu_instance_get_compute_instance_by_id(intptr_t gpu_instance, unsigned int id) except? 0: """Get compute instance for given instance ID. @@ -28321,28 +29004,6 @@ cpdef object device_get_remapped_rows_v2(intptr_t device): return info_py -cpdef object system_get_topology_gpu_set(unsigned int cpuNumber): - """Retrieve the set of GPUs that have a CPU affinity with the given CPU number - - Args: - cpuNumber (unsigned int): The CPU number - - Returns: - array: An array of device handles for GPUs found with affinity to cpuNumber - """ - cdef unsigned int[1] count = [0] - with nogil: - __status__ = nvmlSystemGetTopologyGpuSet(cpuNumber, count, NULL) - check_status_size(__status__) - if count[0] == 0: - return view.array(shape=(1,), itemsize=sizeof(intptr_t), format="P", mode="c")[:0] - cdef view.array deviceArray = view.array(shape=(count[0],), itemsize=sizeof(intptr_t), format="P", mode="c") - with nogil: - __status__ = nvmlSystemGetTopologyGpuSet(cpuNumber, count, deviceArray.data) - check_status(__status__) - return deviceArray - - cpdef str system_get_driver_branch(): """Retrieves the driver branch of the NVIDIA driver installed on the system. @@ -28361,61 +29022,6 @@ cpdef str system_get_driver_branch(): return cpython.PyUnicode_FromString(info.branch) -cpdef object unit_get_devices(intptr_t unit): - """Retrieves the set of GPU devices that are attached to the specified unit. - - Args: - unit (Unit): The identifier of the target unit. - - Returns: - array: An array of device handles for GPUs attached to the unit. - """ - cdef unsigned int[1] deviceCount = [0] - with nogil: - __status__ = nvmlUnitGetDevices(unit, deviceCount, NULL) - check_status_size(__status__) - if deviceCount[0] == 0: - return view.array(shape=(1,), itemsize=sizeof(intptr_t), format="P", mode="c")[:0] - cdef view.array deviceArray = view.array(shape=(deviceCount[0],), itemsize=sizeof(intptr_t), format="P", mode="c") - with nogil: - __status__ = nvmlUnitGetDevices(unit, deviceCount, deviceArray.data) - check_status(__status__) - return deviceArray - - -cpdef object device_get_topology_nearest_gpus(intptr_t device, unsigned int level): - """Retrieve the set of GPUs that are nearest to a given device at a specific interconnectivity level - - Args: - device (Device): The identifier of the first device - level (GpuTopologyLevel): The level to search for other GPUs - - Returns: - array: An array of device handles for GPUs found at level - """ - cdef unsigned int[1] count = [0] - with nogil: - __status__ = nvmlDeviceGetTopologyNearestGpus( - device, - level, - count, - NULL - ) - check_status_size(__status__) - if count[0] == 0: - return view.array(shape=(1,), itemsize=sizeof(intptr_t), format="P", mode="c")[:0] - cdef view.array deviceArray = view.array(shape=(count[0],), itemsize=sizeof(intptr_t), format="P", mode="c") - with nogil: - __status__ = nvmlDeviceGetTopologyNearestGpus( - device, - level, - count, - deviceArray.data - ) - check_status(__status__) - return deviceArray - - cpdef int device_get_temperature_v(intptr_t device, nvmlTemperatureSensors_t sensorType): """Retrieves the current temperature readings (in degrees C) for the given device. @@ -28444,14 +29050,16 @@ cpdef object device_get_supported_performance_states(intptr_t device): device (Device): The identifier of the target device. """ cdef int size = 16 # NVML_MAX_GPU_PERF_STATES - cdef view.array pstates = view.array(shape=(size,), itemsize=sizeof(unsigned int), format="I", mode="c") + cdef object pstates = _numpy.empty(size, dtype=_numpy.uint32) + cdef intptr_t _pstates_data_ = pstates.ctypes.data + cdef nvmlPstates_t *pstates_ptr = _pstates_data_ # The header says "size is the size of the pstates array in bytes". # The size of an enum in C is implementation-defined, so we multiply by `sizeof(nvmlPstates_t)` here. with nogil: __status__ = nvmlDeviceGetSupportedPerformanceStates( device, - pstates.data, + pstates_ptr, size * sizeof(nvmlPstates_t) ) check_status(__status__) @@ -28490,58 +29098,6 @@ cpdef object device_get_running_process_detail_list(intptr_t device, unsigned in return plist -cpdef tuple device_get_samples(intptr_t device, int type, unsigned long long last_seen_time_stamp): - """Gets recent samples for the GPU. - - Args: - device (intptr_t): The identifier for the target device. - type (SamplingType): Type of sampling event. - last_seen_time_stamp (unsigned long long): Return only samples with timestamp greater than last_seen_time_stamp. - - .. seealso:: `nvmlDeviceGetSamples` - """ - cdef unsigned int[1] sample_count = [0] - cdef unsigned int[1] sample_val_type = [0] - with nogil: - __status__ = nvmlDeviceGetSamples(device, <_SamplingType>type, last_seen_time_stamp, <_ValueType*>sample_val_type, sample_count, NULL) - check_status_size(__status__) - cdef Sample samples = Sample(sample_count[0]) - cdef nvmlSample_t *samples_ptr = samples._get_ptr() - if sample_count[0] == 0: - return samples - with nogil: - __status__ = nvmlDeviceGetSamples(device, <_SamplingType>type, last_seen_time_stamp, <_ValueType*>sample_val_type, sample_count, samples_ptr) - check_status(__status__) - return (sample_val_type[0], samples) - - -cpdef tuple device_get_retired_pages_v2(intptr_t device, int cause): - """Returns the list of retired pages by source, including pages that are pending retirement - - Args: - device (Device): The identifier of the target device. - cause (PageRetirementCause): Filter page addresses by cause of retirement. - - Returns: - tuple: A tuple of two arrays (addresses, timestamps). - """ - cdef unsigned int[1] page_count = [0] - with nogil: - __status__ = nvmlDeviceGetRetiredPages_v2(device, <_PageRetirementCause>cause, page_count, NULL, NULL) - check_status_size(__status__) - if page_count[0] == 0: - return ( - view.array(shape=(1,), itemsize=sizeof(unsigned long long), format="Q", mode="c")[:0], - view.array(shape=(1,), itemsize=sizeof(unsigned long long), format="Q", mode="c")[:0] - ) - cdef view.array addresses = view.array(shape=(page_count[0],), itemsize=sizeof(unsigned long long), format="Q", mode="c") - cdef view.array timestamps = view.array(shape=(page_count[0],), itemsize=sizeof(unsigned long long), format="Q", mode="c") - with nogil: - __status__ = nvmlDeviceGetRetiredPages_v2(device, <_PageRetirementCause>cause, page_count, addresses.data, timestamps.data) - check_status(__status__) - return (addresses, timestamps) - - cpdef object device_get_processes_utilization_info(intptr_t device, unsigned long long last_seen_time_stamp): """Retrieves the recent utilization and process ID for all running processes @@ -28685,90 +29241,6 @@ cpdef device_clear_field_values(intptr_t device, values): check_status(__status__) -cpdef object device_get_supported_vgpus(intptr_t device): - """Retrieve the supported vGPU types on a physical GPU (device). - - Args: - device (Device): The identifier of the target device. - - Returns: - array: An array of supported vGPU type IDs. - """ - cdef unsigned int[1] vgpuCount = [0] - with nogil: - __status__ = nvmlDeviceGetSupportedVgpus(device, vgpuCount, NULL) - check_status_size(__status__) - if vgpuCount[0] == 0: - return view.array(shape=(1,), itemsize=sizeof(unsigned int), format="I", mode="c")[:0] - cdef view.array vgpuTypeIds = view.array(shape=(deviceCount[0],), itemsize=sizeof(unsigned int), format="I", mode="c") - with nogil: - __status__ = nvmlDeviceGetSupportedVgpus(device, vgpuCount, vgpuTypeIds.data) - check_status(__status__) - return vgpuTypeIds - - -cpdef object device_get_creatable_vgpus(intptr_t device): - """Retrieve the currently creatable vGPU types on a physical GPU (device). - - Args: - device (Device): The identifier of the target device. - - Returns: - array: An array of createable vGPU type IDs. - """ - cdef unsigned int[1] vgpuCount = [0] - with nogil: - __status__ = nvmlDeviceGetCreatableVgpus(device, vgpuCount, NULL) - check_status_size(__status__) - if vgpuCount[0] == 0: - return view.array(shape=(1,), itemsize=sizeof(unsigned int), format="I", mode="c")[:0] - cdef view.array vgpuTypeIds = view.array(shape=(deviceCount[0],), itemsize=sizeof(unsigned int), format="I", mode="c") - with nogil: - __status__ = nvmlDeviceGetCreatableVgpus(device, vgpuCount, vgpuTypeIds.data) - check_status(__status__) - return vgpuTypeIds - - -cpdef object device_get_active_vgpus(intptr_t device): - """Retrieve the active vGPU instances on a device. - - Args: - device (Device): The identifier of the target device. - - Returns: - array: An array of active vGPU instance IDs. - """ - cdef unsigned int[1] vgpuCount = [0] - with nogil: - __status__ = nvmlDeviceGetActiveVgpus(device, vgpuCount, NULL) - check_status_size(__status__) - if vgpuCount[0] == 0: - return view.array(shape=(1,), itemsize=sizeof(unsigned int), format="I", mode="c")[:0] - cdef view.array vgpuInstances = view.array(shape=(deviceCount[0],), itemsize=sizeof(unsigned int), format="I", mode="c") - with nogil: - __status__ = nvmlDeviceGetActiveVgpus(device, vgpuCount, vgpuInstances.data) - check_status(__status__) - return vgpuInstances - - -cpdef tuple vgpu_instance_get_vm_id(unsigned int vgpu_instance): - """Retrieve the VM ID associated with a vGPU instance. - - Args: - vgpu_instance (unsigned int): The identifier of the target vGPU instance. - - Returns: - tuple[str, VgpuVmIdType]: A tuple of (id, id_type). - """ - cdef unsigned int size = 80 - cdef char[80] vmId - cdef nvmlVgpuVmIdType_t[1] vmIdType - with nogil: - __status__ = nvmlVgpuInstanceGetVmID(vgpu_instance, vmId, size, vmIdType) - check_status(__status__) - return (cpython.PyUnicode_FromString(vmId), vmIdType[0]) - - cpdef object gpu_instance_get_creatable_vgpus(intptr_t gpu_instance): """Query the currently creatable vGPU types on a specific GPU Instance. @@ -28793,7 +29265,7 @@ cpdef object gpu_instance_get_creatable_vgpus(intptr_t gpu_instance): if ptr.vgpuCount == 0: return pVgpus - cdef view.array vgpuTypeIds = view.array(shape=(ptr.vgpuCount,), itemsize=sizeof(unsigned int), format="I", mode="c") + cdef object vgpuTypeIds = _numpy.empty(ptr.vgpuCount, dtype=_numpy.uint32) pVgpus.vgpu_type_ids = vgpuTypeIds with nogil: @@ -28825,7 +29297,7 @@ cpdef object gpu_instance_get_active_vgpus(intptr_t gpu_instance): if ptr.vgpuCount == 0: return activeVgpuInfo - cdef view.array vgpuInstances = view.array(shape=(ptr.vgpuCount,), itemsize=sizeof(unsigned int), format="I", mode="c") + cdef object vgpuInstances = _numpy.empty(ptr.vgpuCount, dtype=_numpy.uint32) activeVgpuInfo.vgpu_instances = vgpuInstances with nogil: @@ -28861,7 +29333,7 @@ cpdef object gpu_instance_get_vgpu_type_creatable_placements(intptr_t gpu_instan if ptr.count == 0: return pCreatablePlacementInfo - cdef view.array placementIds = view.array(shape=(ptr.count,), itemsize=sizeof(unsigned int), format="I", mode="c") + cdef object placementIds = _numpy.empty(ptr.count, dtype=_numpy.uint32) pCreatablePlacementInfo.placement_ids = placementIds with nogil: @@ -28898,7 +29370,7 @@ cpdef object device_get_vgpu_type_creatable_placements(intptr_t device, unsigned if ptr.count == 0: return pPlacementList - cdef view.array placementIds = view.array(shape=(ptr.count,), itemsize=sizeof(unsigned int), format="I", mode="c") + cdef object placementIds = _numpy.empty(ptr.count, dtype=_numpy.uint32) pPlacementList.placement_ids = placementIds with nogil: @@ -28976,24 +29448,6 @@ cpdef object get_vgpu_compatibility(VgpuMetadata vgpu_metadata, VgpuPgpuMetadata return compatibilityInfo -cpdef tuple get_vgpu_version(): - """Query the ranges of supported vGPU versions. - - Returns: - tuple: A tuple of (VgpuVersion supported, VgpuVersion current). - """ - cdef VgpuVersion supported = VgpuVersion() - cdef nvmlVgpuVersion_t *supported_ptr = supported._get_ptr() - cdef VgpuVersion current = VgpuVersion() - cdef nvmlVgpuVersion_t *current_ptr = current._get_ptr() - - with nogil: - __status__ = nvmlGetVgpuVersion(supported_ptr, current_ptr) - - check_status(__status__) - return (supported, current) - - cpdef object device_get_vgpu_instances_utilization_info(intptr_t device): """ Retrieves recent utilization for vGPU instances running on a physical GPU (device). @@ -29061,58 +29515,6 @@ cpdef object device_get_vgpu_processes_utilization_info(intptr_t device, unsigne return vgpuProcUtilInfo -cpdef object device_get_gpu_instances(intptr_t device, unsigned int profile_id): - """Get GPU instances for given profile ID. - - Args: - device (Device): The identifier of the target device. - profile_id (unsigned int): The GPU instance profile ID. See device_get_gpu_instance_profile_info(). - - Returns: - array: An array of GPU instance handles. - """ - cdef unsigned int[1] count = [0] - with nogil: - __status__ = nvmlDeviceGetGpuInstances(device, profile_id, NULL, count) - check_status_size(__status__) - - if count[0] == 0: - view.array(shape=(1,), itemsize=sizeof(intptr_t), format="P", mode="c")[:0] - - cdef view.array gpuInstances = view.array(shape=(count[0],), itemsize=sizeof(intptr_t), format="P", mode="c") - with nogil: - __status__ = nvmlDeviceGetGpuInstances(device, profile_id, gpuInstances.data, count) - check_status(__status__) - - return gpuInstances - - -cpdef object gpu_instance_get_compute_instances(intptr_t gpu_instance, unsigned int profile_id): - """Get Compute instances for given profile ID. - - Args: - gpu_instance (GpuInstance): The identifier of the target GPU Instance. - profile_id (unsigned int): The Compute instance profile ID. - - Returns: - array: An array of Compute instance handles. - """ - cdef unsigned int[1] count = [0] - with nogil: - __status__ = nvmlGpuInstanceGetComputeInstances(gpu_instance, profile_id, NULL, count) - check_status_size(__status__) - - if count[0] == 0: - view.array(shape=(1,), itemsize=sizeof(intptr_t), format="P", mode="c")[:0] - - cdef view.array computeInstances = view.array(shape=(count[0],), itemsize=sizeof(intptr_t), format="P", mode="c") - with nogil: - __status__ = nvmlGpuInstanceGetComputeInstances(gpu_instance, profile_id, computeInstances.data, count) - check_status(__status__) - - return computeInstances - - cpdef object device_get_sram_unique_uncorrected_ecc_error_counts(intptr_t device): """Retrieves the counts of SRAM unique uncorrected ECC errors @@ -29395,7 +29797,7 @@ cpdef object device_get_vgpu_type_supported_placements(intptr_t device, unsigned if p_placement_list.count == 0: return p_placement_list_py - cdef view.array placement_ids = view.array(shape=(p_placement_list.count,), itemsize=sizeof(unsigned int), format="I", mode="c") + cdef object placement_ids = _numpy.empty(p_placement_list.count, dtype=_numpy.uint32) p_placement_list_py.placement_ids = placement_ids with nogil: @@ -29710,55 +30112,6 @@ cpdef gpu_instance_set_vgpu_heterogeneous_mode(intptr_t gpu_instance, unsigned i check_status(__status__) -cpdef tuple device_get_vgpu_utilization(intptr_t device, unsigned long long last_seen_time_stamp): - """Retrieves current utilization for vGPUs on a physical GPU (device). - - Args: - device (intptr_t): The identifier for the target device. - last_seen_time_stamp (unsigned long long): Return only samples with timestamp greater than last_seen_time_stamp. - - Returns: - A 2-tuple containing: - - - samples: Returned sample values. - - utilizationSamples: Utilization samples. - - .. seealso:: `nvmlDeviceGetVgpuUtilization` - """ - cdef unsigned int vgpu_instance_samples_count - with nogil: - __status__ = nvmlDeviceGetVgpuUtilization( - device, - last_seen_time_stamp, - NULL, - &vgpu_instance_samples_count, - NULL - ) - check_status_size(__status__) - - if vgpu_instance_samples_count == 0: - return ( - view.array(shape=(1,), itemsize=sizeof(int), format="I", mode="c")[:0], - VgpuInstanceUtilizationSample(0) - ) - - cdef view.array arr = view.array(shape=(vgpu_instance_samples_count,), itemsize=sizeof(int), format="I", mode="c") - cdef VgpuInstanceUtilizationSample utilization_samples_py = VgpuInstanceUtilizationSample(vgpu_instance_samples_count) - cdef nvmlVgpuInstanceUtilizationSample_t *ptr = utilization_samples_py._get_ptr() - - with nogil: - __status__ = nvmlDeviceGetVgpuUtilization( - device, - last_seen_time_stamp, - arr.data, - &vgpu_instance_samples_count, - ptr - ) - check_status(__status__) - - return (arr, utilization_samples_py) - - cpdef object device_read_prm_counters_v1(intptr_t device, PRMCounter_v1 counters): """Read a list of GPU PRM Counters.