diff --git a/include/aidge/utils/sys_info/CudaVersionInfo.hpp b/include/aidge/utils/sys_info/CudaVersionInfo.hpp new file mode 100644 index 0000000000000000000000000000000000000000..f67b07199c9d4931b36efa62ce6654b1dd654043 --- /dev/null +++ b/include/aidge/utils/sys_info/CudaVersionInfo.hpp @@ -0,0 +1,42 @@ +#ifndef AIDGE_UTILS_SYS_INFO_CUDA_VERSION_INFO_H +#define AIDGE_UTILS_SYS_INFO_CUDA_VERSION_INFO_H + +#include "aidge/backend/cuda/utils/CudaUtils.hpp" // CHECK_CUDA_STATUS +#include "aidge/utils/Log.hpp" + +namespace Aidge { + +void showCudaVersion() { + Log::info("CuDNN version: {}.{}.{}\n", CUDNN_MAJOR, CUDNN_MINOR, + CUDNN_PATCHLEVEL); + + int deviceCount = 0; + CHECK_CUDA_STATUS(cudaGetDeviceCount(&deviceCount)); + + if (deviceCount == 0) { + Log::warn("There are no available device(s) that support CUDA"); + } else { + Log::info("Detected {} CUDA Capable device(s)", deviceCount); + } + + for (int dev = 0; dev < deviceCount; ++dev) { + cudaSetDevice(dev); + cudaDeviceProp deviceProp; + cudaGetDeviceProperties(&deviceProp, dev); + + Log::info("\nDevice #{}: \"{}\"", dev, deviceProp.name); + + int driverVersion = 0; + int runtimeVersion = 0; + cudaDriverGetVersion(&driverVersion); + cudaRuntimeGetVersion(&runtimeVersion); + Log::info( + "\tCUDA Driver Version / Runtime Version: {}.{} / {}.{}", + (driverVersion / 1000), ((driverVersion % 100) / 10), + (runtimeVersion / 1000), ((runtimeVersion % 100) / 10)); + Log::info("\tCUDA Capability Major/Minor version number: {}.{}", + deviceProp.major, deviceProp.minor); + } +} +} // namespace Aidge +#endif // AIDGE_UTILS_SYS_INFO_CUDA_VERSION_INFO_H diff --git a/python_binding/pybind_backend_cuda.cpp b/python_binding/pybind_backend_cuda.cpp index 4b68621b14c2260754dd438d74f059b9f9aa256b..abd1997389f3574a24e171f6ab26628dcfe40cfd 100644 --- a/python_binding/pybind_backend_cuda.cpp +++ b/python_binding/pybind_backend_cuda.cpp @@ -6,8 +6,10 @@ namespace py = pybind11; namespace Aidge { -void init_Aidge(py::module& /*m*/){ +void init_cuda_sys_info(py::module& m); +void init_Aidge(py::module& m){ + init_cuda_sys_info(m); } PYBIND11_MODULE(aidge_backend_cuda, m) { diff --git a/python_binding/utils/sys_info/pybind_CudaVersionInfo.cpp b/python_binding/utils/sys_info/pybind_CudaVersionInfo.cpp new file mode 100644 index 0000000000000000000000000000000000000000..64f650903ec75d579ffd58dbd6d7db7bbaf573a2 --- /dev/null +++ b/python_binding/utils/sys_info/pybind_CudaVersionInfo.cpp @@ -0,0 +1,9 @@ +#include <pybind11/pybind11.h> +#include "aidge/utils/sys_info/CudaVersionInfo.hpp" + +namespace py = pybind11; +namespace Aidge { +void init_cuda_sys_info(py::module& m){ + m.def("show_cuda_version", &showCudaVersion); +} +}