510.39.01 NVML Bug: nvmlDeviceGetMemoryInfo_v2 always returns error 13(NVML_ERROR_FUNCTION_NOT_FOUND)

Hi,

The function “nvmlDeviceGetMemoryInfo_v2” that was introduced in 510.39.01 always returns value 13(NVML_ERROR_FUNCTION_NOT_FOUND). The application I’m trying to use the new functions in is written in Java utilizing Project Panama. The normal “nvmlDeviceGetMemoryInfo” function has no issues. Here is the code to reproduce:

         // load library
        System.load("/usr/lib/libnvidia-ml.so");
        
        // function descriptors
        FunctionDescriptor INIT_V2_DESCRIPTOR = FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.JAVA_INT);
        
        FunctionDescriptor GET_GPU_BY_INDEX_DESCRIPTOR = FunctionDescriptor.of(ValueLayout.JAVA_INT,
                ValueLayout.JAVA_INT, ValueLayout.ADDRESS);
        
        FunctionDescriptor GET_MEMORY_INFO_V2_DESCRIPTOR = FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS, ValueLayout.ADDRESS);
        
        
        // function lookups
        NativeSymbol INIT_V2_SYMBOL = SymbolLookup.loaderLookup().lookup("nvmlInit_v2").get();
        
        NativeSymbol GET_HANDLE_BY_INDEX_SYMBOL = SymbolLookup.loaderLookup().lookup("nvmlDeviceGetHandleByIndex").get();
        
        NativeSymbol GET_MEMORY_INFO_V2_SYMBOL = SymbolLookup.loaderLookup().lookup("nvmlDeviceGetMemoryInfo_v2").get();
        
        // handles to actually invoke the function
        MethodHandle INIT_V2_HANDLE = CLinker.systemCLinker().downcallHandle(INIT_V2_SYMBOL, INIT_V2_DESCRIPTOR);
        
        MethodHandle GET_HANDLE_BY_INDEX_HANDLE = CLinker.systemCLinker().downcallHandle(GET_HANDLE_BY_INDEX_SYMBOL, GET_GPU_BY_INDEX_DESCRIPTOR);
        
        MethodHandle GET_MEMORY_INFO_V2_HANDLE = CLinker.systemCLinker().downcallHandle(GET_MEMORY_INFO_V2_SYMBOL, GET_MEMORY_INFO_V2_DESCRIPTOR);
        
        // segments for invoking the functions
        MemorySegment gpuPointer = MemorySegment.allocateNative(8, ResourceScope.newSharedScope());
        
        MemorySegment infoStruct = MemorySegment.allocateNative(40, ResourceScope.newSharedScope());
        
        System.out.println(INIT_V2_HANDLE.invoke(0));
        
        System.out.println(GET_HANDLE_BY_INDEX_HANDLE.invoke(0, gpuPointer.address()));
        
        System.out.println(GET_MEMORY_INFO_V2_HANDLE.invoke(gpuPointer.get(ValueLayout.ADDRESS, 0), infoStruct.address()));

Interestingly invoking nvidia-smi via the command line shows the new reserved memory field just fine.