### Install License File Source: https://github.com/nvidia/dcgm/blob/master/CMakeLists.txt Installs the LICENSE file to the documentation directory. ```cmake install( FILES LICENSE DESTINATION "${CMAKE_INSTALL_DOCDIR}" COMPONENT Core) ``` -------------------------------- ### DCGM Reader Example (Python) Source: https://github.com/nvidia/dcgm/blob/master/scripts/verify_package_contents/datacenter-gpu-manager-dev_arm64.deb.txt A Python script demonstrating how to read GPU information using DCGM. Requires Python and DCGM installation. ```python # DcgmReaderExample.py # This script demonstrates reading GPU information using DCGM. import pydcgm def main(): try: # Initialize DCGM pydcgm.dcgmInit() # Get a handle to the local DCGM client handle = pydcgm.dcgmOpenLocalClient() # Get the number of devices num_devices = pydcgm.dcgmDeviceGetCount(handle) print(f"Found {num_devices} GPUs.") # Get device IDs device_ids = list(range(num_devices)) # Get GPU utilization field ID field_id = pydcgm.DCGM_FI_DEV_FB_UTILIZATION # Get field values for GPU utilization field_values = pydcgm.dcgmGetFieldValues(handle, num_devices, device_ids, 1, field_id) # Print the results for i in range(num_devices): gpu_id = field_values[i]['deviceId'] utilization = field_values[i]['value']['ui64'] print(f"GPU {gpu_id} FB Utilization: {utilization} %") except pydcgm.DcgmError as e: print(f"DCGM Error: {e}") finally: # Shut down DCGM pydcgm.dcgmShutdown() if __name__ == "__main__": main() ``` -------------------------------- ### DCGM Example Configuration Files Source: https://github.com/nvidia/dcgm/blob/master/scripts/verify_package_contents/datacenter-gpu-manager-core_amd64.deb.txt Example configuration files for DCGM collectd plugin and NVVS. ```bash ./usr/share/doc/datacenter-gpu-manager-/examples/dcgm-collectd-example.conf ./usr/share/doc/datacenter-gpu-manager-/examples/nvvs.conf ``` -------------------------------- ### DCGM Python SDK Example: Main Source: https://github.com/nvidia/dcgm/blob/master/scripts/verify_package_contents/datacenter-gpu-manager-devel_aarch64.rpm.txt A general example script for interacting with DCGM using Python bindings. This script serves as a starting point for DCGM Python development. ```python import pydcgm # ... (rest of the code for dcgm_example.py) ``` -------------------------------- ### Setting Installation Directories Source: https://github.com/nvidia/dcgm/blob/master/CMakeLists.txt Defines installation paths for DCGM plugins, tests, and test applications based on CMake installation variables. ```cmake set(DCGM_NVVS_PLUGINS_INSTALL_DIR "${CMAKE_INSTALL_LIBEXECDIR}/${PROJECT_NAME}/plugins") set(DCGM_TESTS_INSTALL_DIR "${CMAKE_INSTALL_DATADIR}/dcgm_tests") set(DCGM_TESTS_APP_DIR "${CMAKE_INSTALL_DATADIR}/dcgm_tests/apps/${DCGM_TESTS_ARCH}") ``` -------------------------------- ### Install Development Libraries and Binaries Source: https://github.com/nvidia/dcgm/blob/master/CMakeLists.txt Installs development-specific targets like dcgm_stub and nvml_injection. ```cmake install( TARGETS dcgm_stub nvml_injection ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT Development LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT Development RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT Development) ``` -------------------------------- ### DCGM Collectd Example Configuration Source: https://github.com/nvidia/dcgm/blob/master/scripts/verify_package_contents/datacenter-gpu-manager-core_x86_64.rpm.txt An example configuration file for integrating DCGM with collectd. Shows how to set up metric collection. ```config /usr/share/doc/datacenter-gpu-manager-/examples/dcgm-collectd-example.conf ``` -------------------------------- ### DCGM Configuration Sample (C++) Source: https://github.com/nvidia/dcgm/blob/master/scripts/verify_package_contents/datacenter-gpu-manager-dev_arm64.deb.txt Demonstrates how to configure DCGM settings programmatically. Requires DCGM to be installed. ```cpp #include #include #include #include #include #include #include // CMakeLists.txt for configuration_sample ``` ```cpp cmake_minimum_required(VERSION 3.10) project(configuration_sample) find_package(DCGM REQUIRED) add_executable(configuration_sample configuration_sample.cpp) target_link_libraries(configuration_sample PRIVATE DCGM::DCGM) ``` ```cpp // configuration_sample.cpp // This sample demonstrates how to configure DCGM. // It is a basic example and does not cover all possible configurations. #include #include #include #include #include #include #include // Function to initialize DCGM dcgmReturn_t InitializeDCGM() { dcgmInit(); return DCGM_ST_OK; } // Function to shut down DCGM void ShutdownDCGM() { dcgmShutdown(); } int main() { dcgmReturn_t result; // Initialize DCGM result = InitializeDCGM(); if (result != DCGM_ST_OK) { std::cerr << "Failed to initialize DCGM: " << dcgmErrorString(result) << std::endl; return 1; } std::cout << "DCGM Initialized Successfully." << std::endl; // Example: Get a field group and configure it (placeholder) // In a real scenario, you would create or get a field group ID // and then use dcgmFieldGroupSetConstraints or similar functions. std::cout << "Configuration examples would go here." << std::endl; // Shutdown DCGM ShutdownDCGM(); std::cout << "DCGM Shutdown Successfully." << std::endl; return 0; } ``` -------------------------------- ### DCGM Modules Sample (C++) Source: https://github.com/nvidia/dcgm/blob/master/scripts/verify_package_contents/datacenter-gpu-manager-dev_arm64.deb.txt Demonstrates how to interact with DCGM modules. Requires DCGM to be installed. ```cpp #include #include #include #include #include #include #include // CMakeLists.txt for modules_sample ``` ```cpp cmake_minimum_required(VERSION 3.10) project(modules_sample) find_package(DCGM REQUIRED) add_executable(modules_sample modules_sample.cpp) target_link_libraries(modules_sample PRIVATE DCGM::DCGM) ``` ```cpp // modules_sample.cpp // This sample demonstrates how to interact with DCGM modules. #include #include #include #include #include #include #include #include // Function to initialize DCGM dcgmReturn_t InitializeDCGM() { dcgmInit(); return DCGM_ST_OK; } // Function to shut down DCGM void ShutdownDCGM() { dcgmShutdown(); } int main() { dcgmReturn_t result; dcgmHandle_t dcgmHandle; // Initialize DCGM result = InitializeDCGM(); if (result != DCGM_ST_OK) { std::cerr << "Failed to initialize DCGM: " << dcgmErrorString(result) << std::endl; return 1; } // Get DCGM handle result = dcgmOpenLocalClient(&dcgmHandle); if (result != DCGM_ST_OK) { std::cerr << "Failed to get DCGM handle: " << dcgmErrorString(result) << std::endl; ShutdownDCGM(); return 1; } // Example: List available modules (placeholder) // In a real scenario, you would use functions like dcgmModuleGetInfo // to query and interact with specific modules. std::cout << "Module interaction examples would go here." << std::endl; // Close client and shut down DCGM dcgmCloseClient(dcgmHandle); ShutdownDCGM(); return 0; } ``` -------------------------------- ### NVVS Example Configuration Source: https://github.com/nvidia/dcgm/blob/master/scripts/verify_package_contents/datacenter-gpu-manager-core_x86_64.rpm.txt An example configuration file for NVVS (NVIDIA Virtual GPU software). Used for configuring vGPU settings. ```config /usr/share/doc/datacenter-gpu-manager-/examples/nvvs.conf ``` -------------------------------- ### DCGM Process Stats Sample (C++) Source: https://github.com/nvidia/dcgm/blob/master/scripts/verify_package_contents/datacenter-gpu-manager-dev_arm64.deb.txt Demonstrates how to retrieve process statistics for GPUs. Requires DCGM to be installed. ```cpp #include #include #include #include #include #include #include // CMakeLists.txt for process_stats_sample ``` ```cpp cmake_minimum_required(VERSION 3.10) project(process_stats_sample) find_package(DCGM REQUIRED) add_executable(process_stats_sample process_stats_sample.cpp) target_link_libraries(process_stats_sample PRIVATE DCGM::DCGM) ``` ```cpp // process_stats_sample.cpp // This sample demonstrates how to get process statistics for GPUs. #include #include #include #include #include #include #include #include // Function to initialize DCGM dcgmReturn_t InitializeDCGM() { dcgmInit(); return DCGM_ST_OK; } // Function to shut down DCGM void ShutdownDCGM() { dcgmShutdown(); } int main() { dcgmReturn_t result; dcgmHandle_t dcgmHandle; int numDevices; std::vector devices; // Initialize DCGM result = InitializeDCGM(); if (result != DCGM_ST_OK) { std::cerr << "Failed to initialize DCGM: " << dcgmErrorString(result) << std::endl; return 1; } // Get DCGM handle result = dcgmOpenLocalClient(&dcgmHandle); if (result != DCGM_ST_OK) { std::cerr << "Failed to get DCGM handle: " << dcgmErrorString(result) << std::endl; ShutdownDCGM(); return 1; } // Get number of devices result = dcgmDeviceGetCount(dcgmHandle, &numDevices); if (result != DCGM_ST_OK) { std::cerr << "Failed to get device count: " << dcgmErrorString(result) << std::endl; dcgmCloseClient(dcgmHandle); ShutdownDCGM(); return 1; } devices.resize(numDevices); for (int i = 0; i < numDevices; ++i) { devices[i] = i; } // Get process statistics for all devices dcgmProcessUtilization_t processUtil[numDevices]; for (int i = 0; i < numDevices; ++i) { processUtil[i].version = dcgmProcessUtilization_v1_CURRENT_VERSION; processUtil[i].numProcesses = 0; // DCGM will fill this processUtil[i].processInfo = nullptr; // DCGM will allocate if needed } result = dcgmGetProcessUtilization(dcgmHandle, numDevices, devices.data(), DCGM_PROCESS_UTILIZATION_V1, processUtil); if (result != DCGM_ST_OK) { std::cerr << "Failed to get process utilization: " << dcgmErrorString(result) << std::endl; dcgmCloseClient(dcgmHandle); ShutdownDCGM(); return 1; } // Print process statistics for (int i = 0; i < numDevices; ++i) { std::cout << "GPU " << i << " has " << processUtil[i].numProcesses << " processes running." << std::endl; // You can iterate through processUtil[i].processInfo to get details // Remember to free processUtil[i].processInfo if DCGM allocated it } // Close client and shut down DCGM dcgmCloseClient(dcgmHandle); ShutdownDCGM(); return 0; } ``` -------------------------------- ### DCGM Policy Sample (C++) Source: https://github.com/nvidia/dcgm/blob/master/scripts/verify_package_contents/datacenter-gpu-manager-dev_arm64.deb.txt Demonstrates how to manage DCGM policies. Requires DCGM to be installed. ```cpp #include #include #include #include #include #include #include // CMakeLists.txt for policy_sample ``` ```cpp cmake_minimum_required(VERSION 3.10) project(policy_sample) find_package(DCGM REQUIRED) add_executable(policy_sample policy_sample.cpp) target_link_libraries(policy_sample PRIVATE DCGM::DCGM) ``` ```cpp // policy_sample.cpp // This sample demonstrates how to manage DCGM policies. #include #include #include #include #include #include #include #include // Function to initialize DCGM dcgmReturn_t InitializeDCGM() { dcgmInit(); return DCGM_ST_OK; } // Function to shut down DCGM void ShutdownDCGM() { dcgmShutdown(); } int main() { dcgmReturn_t result; dcgmHandle_t dcgmHandle; // Initialize DCGM result = InitializeDCGM(); if (result != DCGM_ST_OK) { std::cerr << "Failed to initialize DCGM: " << dcgmErrorString(result) << std::endl; return 1; } // Get DCGM handle result = dcgmOpenLocalClient(&dcgmHandle); if (result != DCGM_ST_OK) { std::cerr << "Failed to get DCGM handle: " << dcgmErrorString(result) << std::endl; ShutdownDCGM(); return 1; } // Example: Set a policy (placeholder) // In a real scenario, you would use functions like dcgmPolicySet // to configure various policies. std::cout << "Policy management examples would go here." << std::endl; // Close client and shut down DCGM dcgmCloseClient(dcgmHandle); ShutdownDCGM(); return 0; } ``` -------------------------------- ### Install DCGM Profiler Tester Kernels Source: https://github.com/nvidia/dcgm/blob/master/dcgmproftester/CMakeLists.txt Installs the DcgmProfTesterKernels.ptx file to the appropriate locations for core and test components. This ensures the necessary kernel files are available after installation. ```cmake install( FILES DcgmProfTesterKernels.ptx DESTINATION "${CMAKE_INSTALL_LIBEXECDIR}/${PROJECT_NAME}" COMPONENT Core) install( FILES DcgmProfTesterKernels.ptx DESTINATION "${CMAKE_INSTALL_DATADIR}/dcgm_tests/apps/${CMAKE_INSTALL_LIBEXECDIR}/${PROJECT_NAME}" COMPONENT Tests) ``` -------------------------------- ### DCGM C++ SDK Sample: Configuration Source: https://github.com/nvidia/dcgm/blob/master/scripts/verify_package_contents/datacenter-gpu-manager-devel_aarch64.rpm.txt Example demonstrating how to configure DCGM settings. This requires linking against the DCGM library. ```cpp #include #include #include #include #include // ... (rest of the code for configuration_sample.cpp) ``` ```cmake cmake_minimum_required(VERSION 3.10) project(configuration_sample) find_package(DCGM REQUIRED) add_executable(configuration_sample configuration_sample.cpp) target_link_libraries(configuration_sample PRIVATE Dcgm::dcgm) ``` -------------------------------- ### Install Core DCGM Libraries and Binaries Source: https://github.com/nvidia/dcgm/blob/master/CMakeLists.txt Installs the main DCGM libraries and executables to their respective locations. ```cmake install( TARGETS dcgm dcgm_interface EXPORT dcgm-export ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT Development LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT Core NAMELINK_COMPONENT Development RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT Core) ``` -------------------------------- ### Install Multinode Module Source: https://github.com/nvidia/dcgm/blob/master/CMakeLists.txt Installs the dcgmmodulemndiag for multinode functionality. ```cmake install( TARGETS dcgmmodulemndiag LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT Multinode NAMELINK_SKIP) ``` -------------------------------- ### Install NVVS Target Source: https://github.com/nvidia/dcgm/blob/master/CMakeLists.txt Installs the nvvs target to the core execution directory. ```cmake install( TARGETS nvvs RUNTIME DESTINATION "${CMAKE_INSTALL_LIBEXECDIR}/${PROJECT_NAME}" COMPONENT Core) ``` -------------------------------- ### Install DCGM Source and Script Directories Source: https://github.com/nvidia/dcgm/blob/master/sdk_samples/CMakeLists.txt Installs the C source files, scripts, and DCGM diagnostic configuration files to the development source directory. This is part of the development component installation. ```cmake install( DIRECTORY c_src scripts dcgm_diag_configs DESTINATION "src/${PROJECT_NAME}/sdk_samples" COMPONENT Development) ``` -------------------------------- ### Install Empty Component for Metapackages Source: https://github.com/nvidia/dcgm/blob/master/CMakeLists.txt Establishes an empty install component used for dependency management in package systems. ```cmake install(FILES DESTINATION . COMPONENT Cuda_All) ``` -------------------------------- ### Example SHA256 Hashes for Requirements Source: https://github.com/nvidia/dcgm/blob/master/dcgmbuild/container-images/common-host-software/requirements.txt A list of SHA256 hashes for various Python packages, used to verify the integrity of installed packages when using pip-compile. ```text --hash=sha256:0cce65db0cd8c750a378639900d56f89f7d6af11cd5eda72fde054d27c54b8ce \ --hash=sha256:0d21c9cacb6a889cbb8eeb46c77ef2c1dd529cde10443fdeb1de847b3193c541 \ --hash=sha256:0ef8cd44a080bfb92776047d11ab64875faf76e0d8be20ea3ff0c1e67b3fc9cb \ --hash=sha256:10a72e456319b030b3dd900df6b1f19d89adf06ebb688821636dc406788cf6ac \ --hash=sha256:11a052cbd013b7140bbbb38a14e2329b6192478344c99097e378c691b7119551 \ --hash=sha256:1bce45a2c32032afddbd84ed8ab092130649acb935536ef7a9559636ce7ffd4a \ --hash=sha256:1beca37c6e7a4ddd1ca24829e2c6cb60b5aad0d6936283b5b9909a7496bd97af \ --hash=sha256:1dc13405bf315d008fe02b1472d2a9d65ee1c73c0a06de5f5a45e6e404d9a1c0 \ --hash=sha256:1e9dc2b9f1586e7cd77753eae81f8d76220eed9b768f337dc83a3f675f2f0cf9 \ --hash=sha256:1ebbf2d9775be149235abebdecae88fe3b3dd06b1797cd0f6dffe6948e85309d \ --hash=sha256:207ae0d5f0f03b30f95e649a6fa22aa73f5825667fee9c7ec6854d30e19f2ed8 \ --hash=sha256:21300d8c1bbcc38925aabd4b3c2d6a8b09878daf9e8f2035f09b5b002bcddd66 \ --hash=sha256:21344d29c82ca8547ea23023bb8e7538fa5d4615a1773b991edf8176a870c1ea \ --hash=sha256:21e364e1bb731489e3f4d51db416f991a5d5da5d88184728d80ecfb0904b1d68 \ --hash=sha256:2287fadaa12418a813b05095485c286c47ea58155930cfbd98c590d25770e225 \ --hash=sha256:2516acc6947ecd3c41a4a4564242a87c6786376989307284ddb115f6a99d927f \ --hash=sha256:2719e42acda8f3444a0d88204fd90665116dda7331934da4d479dd9296c33ce2 \ --hash=sha256:2834377b0145a471a654d699bdb3a2155312de492142ef5a1d426af2c60a0a31 \ --hash=sha256:299a790d403335a6a057ade46f92612ebab87b223e4e8c5308059f2dc36f45ed \ --hash=sha256:29b0e849ec7030e3ecb6112564c9f7ad6881e3b2375dd4a0c486c5c1f3a33859 \ --hash=sha256:2b3a882ebf27dd026df3801a87cf49ff791336e0f94b0fad195db77e01240690 \ --hash=sha256:2e2b0e042e1408bbb1c5f3cfcb0f571ff4ac98d8e73f4bf37c5dd179276beedd \ --hash=sha256:32297b09ed4b17f7b3f448de87a92fb31bb8747496623483788e9f27c98c0f00 \ --hash=sha256:33b862c7e3bbeb4ba2c96f3a039f925c640eeba9087a4dc7a572ec0f19d89392 \ --hash=sha256:36c8fa7e177649470bc3dcf7eae6bee1e4984aaee496b9ccbf30e97ac4127fa2 \ --hash=sha256:3b38e20c578149fdbba1fd3f36cb1928a3aaca4b011dfd41ba09d11fb396e1b9 \ --hash=sha256:405e7cf9dbdbb52722c231e0f1257214202dfa192327fab3de45fd62e0554082 \ --hash=sha256:42897fe8cb097274087fafc8251a39b4cf8d64a7396d49479bdc00b3587331cb \ --hash=sha256:433ab647dad6a9fb31418ccd3075dcb4405ece75dced998789fe14a8e1e3785c \ --hash=sha256:445f2cee71c404ab4259bc21e20339a859f75383ba2d7fb97dfe7c163994287b \ --hash=sha256:4588806a721552692310ebe9f90c17ac6c7c5dac438cd93e3d74dd60531c3211 \ --hash=sha256:45cbc92f9d22c28cd3b97f8d07fcefa42e569fbd587dfdac76852b16a4924277 \ --hash=sha256:45fdd0415a0c3d91640b5d7a650a8f37410966a2e9afebb35979d06166fd010e \ --hash=sha256:47ab1aff82a95a07d96c1eff4eaebec84f823e0dfb4d9501b1fbf9621270c1d3 \ --hash=sha256:485eda5d81bb7358db96a83546949c5fe7474bec6c68ef3fa1fb61a584b00eea \ --hash=sha256:48c8d335d8ab72f9265e7ba598ae5105a8272437403f4032107dbcb96d3f0b29 \ --hash=sha256:48da704672f6f9c461e9a73250440c647638cc6ff9567ead4c3b1f189a604ee8 \ --hash=sha256:50b5e54f6a9461b1e9c08b4a3420415b538d4773bd9df996b9abcbfe95f4f1fd \ --hash=sha256:51bd5d1a9796ca253db6045ab45ca882c09c071deafffc22e06975b7ace36300 \ --hash=sha256:537b6cf1c5ab88cfd159195d412edb3e434fee880f206cbe68dff9c40e17a68a \ --hash=sha256:57478424ac4c9170eabf540237125e8d30fad1940648924c058e7bc9fb9cf6dd \ --hash=sha256:57744270a512a93416a149f8b6ea1dbbbee127f5edcbcd5adf28e44b6ff02f33 \ --hash=sha256:5c17e70c82fd777df586c12114bbe56e4e6f823a971814fd40dec9c0de518772 \ --hash=sha256:5d08e0f1af6916267bb7eff21c09fa105620f07712424aaae09e8cb5dd4164d1 \ --hash=sha256:615bb6c73fed7929e3a477a3297a797892846b253d59c84a62c98bdce3849a0a \ --hash=sha256:620869f2a3ec1475d000b608024f63259af8d200684de380ccb9650fbc14d1bb \ --hash=sha256:64fac7a05ebb3737b79fd89fe5a5b6c5546aac35cfcfd9208eb6e5d13215771c \ --hash=sha256:6f393e10685b37f15b1daef8aa0d734ec61860bb679ec447afa0001a31e7253f \ --hash=sha256:70f540c229a8c0a770dcaf6d5af56a5295e0fc314fc7ef4399d543328054bcea \ --hash=sha256:74555e2da7c1636e30bff4e6e38d862a634cf020ffa591f1f63da96bf8b34772 \ --hash=sha256:7587ac5e000e1594e62278422c5783b34a82b22f27688b1074d71376424b73e8 \ --hash=sha256:7a3ec1373f7d3f519de595032d4dcafae396c29407cfd5073f42d267ba32440d \ --hash=sha256:7a44a5fb1edd11b3a65c12c23e1049c8ae49d90a24253ff18efbcb6aa042d012 \ --hash=sha256:7c23fd8c839708d368e406282d7953cee5134f4592ef4900026d84566d2b4c88 \ --hash=sha256:7e18224ea241b657a157c85e9cac82c2b113ec90876e01e1f127312006233756 \ --hash=sha256:7f36e4a2439d134b8e70f92ff27ada6fb685966de385668e21c708021733ead1 \ --hash=sha256:7fd70681aeed83b196482d42a9b0dc5b13bab55668d09ad75ed26dff3be5a2f5 \ --hash=sha256:8466faa66b0353802fb7c054a400ac17ce2cf416e3ad8516eadeff9cba85b741 ``` -------------------------------- ### Install Cudaless Plugin Source: https://github.com/nvidia/dcgm/blob/master/CMakeLists.txt Installs the pluginCommon target to the cudaless plugin directory. ```cmake install( TARGETS pluginCommon LIBRARY DESTINATION "${CMAKE_INSTALL_LIBEXECDIR}/${PROJECT_NAME}/plugins/cudaless" COMPONENT Core NAMELINK_SKIP) LIBRARY DESTINATION "${CMAKE_INSTALL_LIBEXECDIR}/${PROJECT_NAME}/plugins/cudaless" COMPONENT Core) ``` -------------------------------- ### Install CUDA 12 Cublas Proxy and Profiler Source: https://github.com/nvidia/dcgm/blob/master/CMakeLists.txt Installs CUDA 12 specific cublas proxy and profiler targets. ```cmake install( TARGETS dcgm_cublas_proxy12 dcgmproftester12 LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT Cuda12 NAMELINK_SKIP RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT Cuda12) ``` -------------------------------- ### Link DCGM Library to Configuration Sample Source: https://github.com/nvidia/dcgm/blob/master/sdk_samples/c_src/configuration_sample/CMakeLists.txt Links the DCGM library to the 'configuration_sample' executable. Ensure DCGM is correctly installed or available in the build environment for this to succeed. ```cmake target_link_libraries(configuration_sample PRIVATE DCGM::dcgm) ``` -------------------------------- ### DCGM Diagnostic Configuration Example (YAML) Source: https://github.com/nvidia/dcgm/blob/master/scripts/verify_package_contents/datacenter-gpu-manager-devel_x86_64.rpm.txt An example YAML configuration file for DCGM diagnostics. This file specifies the tests to be run and their parameters. ```yaml --- # DCGM diagnostic configuration file # This file specifies the tests to be run and their parameters. # # Example: Production test configuration # List of tests to run tests: - name: "gpu_burn_in" parameters: duration_sec: 300 max_temp_c: 85 - name: "memory_test" parameters: iterations: 10 max_ecc_errors: 0 - name: "nvlink_test" parameters: iterations: 5 # List of GPUs to run diagnostics on (optional, defaults to all GPUs) # gpus: # - uuid: "GPU-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" # - index: 0 ``` -------------------------------- ### Install Core DCGM Modules and Host Engine Source: https://github.com/nvidia/dcgm/blob/master/CMakeLists.txt Installs various DCGM modules and the host engine to core runtime locations. ```cmake install( TARGETS dcgmi dcgmmoduleconfig dcgmmodulediag dcgmmodulehealth dcgmmoduleintrospect dcgmmodulenvswitch dcgmmodulepolicy dcgmmodulesysmon nv-hostengine LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT Core NAMELINK_SKIP RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT Core) ``` -------------------------------- ### Install CUDA 13 Cublas Proxy and Profiler Source: https://github.com/nvidia/dcgm/blob/master/CMakeLists.txt Installs CUDA 13 specific cublas proxy and profiler targets. ```cmake install( TARGETS dcgm_cublas_proxy13 dcgmproftester13 LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT Cuda13 NAMELINK_SKIP RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT Cuda13) ``` -------------------------------- ### DCGM Field Value Sample (C++) Source: https://github.com/nvidia/dcgm/blob/master/scripts/verify_package_contents/datacenter-gpu-manager-dev_arm64.deb.txt Demonstrates how to retrieve field values for GPUs. Requires DCGM to be installed. ```cpp #include #include #include #include #include #include #include // CMakeLists.txt for field_value_sample ``` ```cpp cmake_minimum_required(VERSION 3.10) project(field_value_sample) find_package(DCGM REQUIRED) add_executable(field_value_sample field_value_sample.cpp) target_link_libraries(field_value_sample PRIVATE DCGM::DCGM) ``` ```cpp // field_value_sample.cpp // This sample demonstrates how to get field values for GPUs. #include #include #include #include #include #include #include #include // Function to initialize DCGM dcgmReturn_t InitializeDCGM() { dcgmInit(); return DCGM_ST_OK; } // Function to shut down DCGM void ShutdownDCGM() { dcgmShutdown(); } int main() { dcgmReturn_t result; dcgmHandle_t dcgmHandle; int numDevices; std::vector devices; // Initialize DCGM result = InitializeDCGM(); if (result != DCGM_ST_OK) { std::cerr << "Failed to initialize DCGM: " << dcgmErrorString(result) << std::endl; return 1; } // Get DCGM handle result = dcgmOpenLocalClient(&dcgmHandle); if (result != DCGM_ST_OK) { std::cerr << "Failed to get DCGM handle: " << dcgmErrorString(result) << std::endl; ShutdownDCGM(); return 1; } // Get number of devices result = dcgmDeviceGetCount(dcgmHandle, &numDevices); if (result != DCGM_ST_OK) { std::cerr << "Failed to get device count: " << dcgmErrorString(result) << std::endl; dcgmCloseClient(dcgmHandle); ShutdownDCGM(); return 1; } devices.resize(numDevices); for (int i = 0; i < numDevices; ++i) { devices[i] = i; } // Get field values for GPU utilization dcgmFieldValue_v2 fieldValues[numDevices]; for (int i = 0; i < numDevices; ++i) { fieldValues[i].version = dcgmFieldValue_v2_CURRENT_VERSION; fieldValues[i].fieldId = DCGM_FI_DEV_FB_UTILIZATION; fieldValues[i].status = 0; } result = dcgmGetFieldValues(dcgmHandle, numDevices, devices.data(), 1, &fieldValues[0]); if (result != DCGM_ST_OK) { std::cerr << "Failed to get field values: " << dcgmErrorString(result) << std::endl; dcgmCloseClient(dcgmHandle); ShutdownDCGM(); return 1; } // Print field values for (int i = 0; i < numDevices; ++i) { std::cout << "GPU " << i << " FB Utilization: " << fieldValues[i].value.ui64 << " %" << std::endl; } // Close client and shut down DCGM dcgmCloseClient(dcgmHandle); ShutdownDCGM(); return 0; } ``` -------------------------------- ### Install CUDA 11 Cublas Proxy and Profiler Source: https://github.com/nvidia/dcgm/blob/master/CMakeLists.txt Installs CUDA 11 specific cublas proxy and profiler targets. ```cmake install( TARGETS dcgm_cublas_proxy11 dcgmproftester11 LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT Cuda11 NAMELINK_SKIP RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT Cuda11) ``` -------------------------------- ### Install DCGM Package Configuration Source: https://github.com/nvidia/dcgm/blob/master/CMakeLists.txt Installs the DCGMConfig.cmake and DCGMConfigVersion.cmake files for package management. ```cmake install( EXPORT dcgm-export FILE DCGMConfig.cmake NAMESPACE DCGM:: DESTINATION "${CMAKE_INSTALL_DATADIR}/cmake/DCGM" COMPONENT Development) write_basic_package_version_file( DCGMConfigVersion.cmake COMPATIBILITY SameMajorVersion) install( FILES "${PROJECT_BINARY_DIR}/DCGMConfigVersion.cmake" DESTINATION "${CMAKE_INSTALL_DATADIR}/cmake/DCGM" COMPONENT Development) ``` -------------------------------- ### Install DCGM Python Bindings Source: https://github.com/nvidia/dcgm/blob/master/testing/CMakeLists.txt Installs various DCGM Python module files to the specified destination directory. This component is part of the Core installation. ```cmake install( FILES python3/dcgm_agent.py python3/dcgm_fields.py python3/dcgm_fields_collectd.py python3/dcgm_fields_internal.py python3/dcgm_structs.py python3/dcgmvalue.py python3/DcgmDiag.py python3/DcgmMnDiag.py python3/DcgmGroup.py python3/DcgmHandle.py python3/DcgmJsonReader.py python3/DcgmLogging.py python3/DcgmReader.py python3/DcgmStatus.py python3/DcgmSystem.py python3/DcgmFieldGroup.py python3/pydcgm.py python3/dcgm_field_helpers.py python3/dcgm_errors.py python3/dcgm_collectd_plugin.py python3/dcgm_fluentd.py python3/dcgm_telegraf.py python3/denylist_recommendations.py DESTINATION "${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/bindings/python3" COMPONENT Core) install( FILES python3/common/__init__.py python3/common/dcgm_client_cli_parser.py python3/common/dcgm_client_main.py DESTINATION "${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/bindings/python3/common" COMPONENT Core) ``` -------------------------------- ### DCGM Health Sample (C++) Source: https://github.com/nvidia/dcgm/blob/master/scripts/verify_package_contents/datacenter-gpu-manager-dev_arm64.deb.txt Demonstrates how to check the health status of GPUs. Requires DCGM to be installed. ```cpp #include #include #include #include #include #include #include // CMakeLists.txt for health_sample ``` ```cpp cmake_minimum_required(VERSION 3.10) project(health_sample) find_package(DCGM REQUIRED) add_executable(health_sample health_sample.cpp) target_link_libraries(health_sample PRIVATE DCGM::DCGM) ``` ```cpp // health_sample.cpp // This sample demonstrates how to check the health of GPUs. #include #include #include #include #include #include #include #include // Function to initialize DCGM dcgmReturn_t InitializeDCGM() { dcgmInit(); return DCGM_ST_OK; } // Function to shut down DCGM void ShutdownDCGM() { dcgmShutdown(); } int main() { dcgmReturn_t result; dcgmHandle_t dcgmHandle; int numDevices; std::vector devices; // Initialize DCGM result = InitializeDCGM(); if (result != DCGM_ST_OK) { std::cerr << "Failed to initialize DCGM: " << dcgmErrorString(result) << std::endl; return 1; } // Get DCGM handle result = dcgmOpenLocalClient(&dcgmHandle); if (result != DCGM_ST_OK) { std::cerr << "Failed to get DCGM handle: " << dcgmErrorString(result) << std::endl; ShutdownDCGM(); return 1; } // Get number of devices result = dcgmDeviceGetCount(dcgmHandle, &numDevices); if (result != DCGM_ST_OK) { std::cerr << "Failed to get device count: " << dcgmErrorString(result) << std::endl; dcgmCloseClient(dcgmHandle); ShutdownDCGM(); return 1; } devices.resize(numDevices); for (int i = 0; i < numDevices; ++i) { devices[i] = i; } // Check health of all devices dcgmHealth_t healthStatus; for (int i = 0; i < numDevices; ++i) { result = dcgmDeviceGetHealth(dcgmHandle, devices[i], &healthStatus); if (result != DCGM_ST_OK) { std::cerr << "Failed to get health for GPU " << i << ": " << dcgmErrorString(result) << std::endl; } else { std::cout << "GPU " << i << " Health: " << healthStatus << std::endl; // You can interpret the healthStatus value based on DCGM documentation } } // Close client and shut down DCGM dcgmCloseClient(dcgmHandle); ShutdownDCGM(); return 0; } ``` -------------------------------- ### DCGM C++ SDK Sample: Policy Source: https://github.com/nvidia/dcgm/blob/master/scripts/verify_package_contents/datacenter-gpu-manager-devel_aarch64.rpm.txt Example for managing GPU policies using the DCGM API. Link against the DCGM library. ```cpp #include #include #include #include #include // ... (rest of the code for policy_sample.cpp) ``` ```cmake cmake_minimum_required(VERSION 3.10) project(policy_sample) find_package(DCGM REQUIRED) add_executable(policy_sample policy_sample.cpp) target_link_libraries(policy_sample PRIVATE Dcgm::dcgm) ``` -------------------------------- ### Install DCGM Decode DB Source: https://github.com/nvidia/dcgm/blob/master/CMakeLists.txt Installs the generated dcgm_decode_db.txt file to the data directory for tests. ```cmake install( FILES "${PROJECT_BINARY_DIR}/dcgm_decode_db.txt" DESTINATION ${DCGM_TESTS_INSTALL_DIR}/data COMPONENT Tests) ``` -------------------------------- ### Add Executable and Sources for DCGM Sample Source: https://github.com/nvidia/dcgm/blob/master/sdk_samples/c_src/configuration_sample/CMakeLists.txt Defines an executable target named 'configuration_sample' and associates it with the source file 'configuration_sample.cpp'. This is a standard CMake setup for building a C++ application. ```cmake add_executable(configuration_sample) target_sources(configuration_sample PRIVATE configuration_sample.cpp) ``` -------------------------------- ### DCGM Diagnostic Configuration Example (YAML) Source: https://github.com/nvidia/dcgm/blob/master/scripts/verify_package_contents/datacenter-gpu-manager-dev_amd64.deb.txt Example of a DCGM diagnostic configuration file in YAML format. Used for defining diagnostic tests and parameters. ```yaml --- # This is an example DCGM diagnostic configuration file. # It defines parameters for running diagnostics. # Example: Define a test case TestCases: - Name: "GPU_Memory_Test" Parameters: MaxMemoryBandwidth: "95%" MinMemoryBandwidth: "85%" Duration: "60s" # Example: Define a diagnostic run profile DiagnosticProfile: Name: "Production_Test" Tests: - "GPU_Memory_Test" Repetitions: 3 Parallel: true ```