Skip to content
Snippets Groups Projects
Commit 0e36e66d authored by Cyril Moineau's avatar Cyril Moineau
Browse files

Merge branch 'cuda-version' into 'dev'

Show cuda version during compilation.

See merge request !17
parents 517de61b 820589d2
No related branches found
No related tags found
2 merge requests!32version 0.2.1,!17Show cuda version during compilation.
Pipeline #45710 passed
......@@ -2,11 +2,24 @@
cmake_minimum_required(VERSION 3.18)
file(READ "${CMAKE_SOURCE_DIR}/version.txt" version)
add_definitions(-DPROJECT_VERSION="${version}")
file(READ "${CMAKE_SOURCE_DIR}/project_name.txt" project)
message(STATUS "Project name: ${project}")
message(STATUS "Project version: ${version}")
execute_process(
COMMAND git rev-parse --short HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
message(STATUS "Latest git commit: ${GIT_COMMIT_HASH}")
# Define a preprocessor macro with the Git commit version
add_definitions(-DGIT_COMMIT_HASH="${GIT_COMMIT_HASH}")
# Note : project name is {project} and python module name is also {project}
set(module_name _${project}) # target name
......@@ -33,6 +46,11 @@ endif()
enable_language(CUDA)
message(STATUS "Cuda compiler version = ${CMAKE_CUDA_COMPILER_VERSION}")
# Define a preprocessor macro with the Cuda compiler version
add_definitions(-DCUDA_COMPILER_VERSION="${CMAKE_CUDA_COMPILER_VERSION}")
##############################################
# Find system dependencies
find_package(CUDAToolkit REQUIRED)
......
#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 {
#ifndef PROJECT_VERSION // Normally defined in CMakeLists.txt
#define PROJECT_VERSION "Unknown version"
#endif
#ifndef GIT_COMMIT_HASH
#define GIT_COMMIT_HASH ""
#endif
#ifndef CUDA_COMPILER_VERSION
#define CUDA_COMPILER_VERSION "Unknown version"
#endif
void showCudaVersion() {
Log::info("Aidge backend CUDA: {} ({}), {} {}", PROJECT_VERSION, GIT_COMMIT_HASH, __DATE__, __TIME__);
Log::info("CUDA compiler version: {}", CUDA_COMPILER_VERSION);
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
......@@ -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) {
......
#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);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment