| cmake_minimum_required(VERSION 3.18) |
| project(cancer_trainer LANGUAGES CXX CUDA) |
|
|
| set(CMAKE_CXX_STANDARD 17) |
| set(CMAKE_CUDA_STANDARD 17) |
|
|
| if (MSVC) |
| add_compile_options(/O2 /W4) |
| else() |
| add_compile_options(-O3 -ffast-math -fno-math-errno -fno-trapping-math -Wall -Wextra -Wno-unused-parameter) |
| endif() |
|
|
| enable_language(CUDA) |
| set(CMAKE_CUDA_ARCHITECTURES 75 80 86) # Turing, Ampere |
|
|
| find_package(CUDAToolkit REQUIRED) |
| add_definitions(-D_FORCE_INLINES) |
|
|
| # Tell CMake where to find stb_image.h |
| target_include_directories(cancer_trainer PRIVATE vendor) |
|
|
| file(GLOB SRC "src/*.cpp" "src/*.hpp" "src/*.cu") |
| add_executable(cancer_trainer ${SRC}) |
| target_link_libraries(cancer_trainer PRIVATE CUDA::cudart CUDA::cufft) |
| target_compile_options(cancer_trainer PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:-use_fast_math>) |
|
|
| # Define STB_IMAGE_IMPLEMENTATION in only one compilation unit |
| set_source_files_properties(src/data_loader.cpp PROPERTIES |
| COMPILE_DEFINITIONS STB_IMAGE_IMPLEMENTATION |
| )``` |
|
|
| #### `vendor/stb_image.h` |
| *Descarga y coloca el fichero `stb_image.h` de la [fuente oficial](https://github.com/nothings/stb/blob/master/stb_image.h) en esta carpeta.* |
|
|
| #### `src/utils.hpp` |
| ```cpp |
| #pragma once |
| #include <string> |
| #include <vector> |
| #include <cuda_runtime.h> |
|
|
| void check_cuda(cudaError_t st, const char* msg); |
| void write_submission_csv(const std::string& path, |
| const std::vector<std::string>& ids, |
| const std::vector<float>& probabilities); |