Skip to content

Commit

Permalink
Upgrade to CMake 3.10 minimum, shared lib and CUDA support (#266)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: flashlight/flashlight#266

*Looking for comments here.* We don't have to go with this, but this is a draft of what this looks like. Helps us eliminate a lot of technical debt for now. We might be able to one day relax this restriction down the line again if we need to.

Update the minimum version of CMake required for flashlight to 3.10. 3.10 deprecates `FindCUDA.cmake` and adds first-class support for CUDA code in CMake as a project language.

Among other things, this diff:
- **Adds support for CUDA 11** and running flashlight code on Ampere with the CMake build
- **Adds support for building flashlight libraries, flashlight core, and flashlight apps as shared objects/libraries**. This makes shipping these libraries to other places easy.
- **Removes the `fl-libraries-cuda` and `warpctc` targets from flashlight**. These used to be separate CUDA libraries that were linked with and exported as additional targets
  - They flashlight exported targets more difficult to understand
  - They had the potential to conflict with other bits, i.e. another build of warpctc on the user's machine
  - CUDA kernels in flashlight libraries are now part of the `fl-libraries` target which makes it transparently easy to add new CUDA sources to flashlight, cc chaitan3
- CMake 3.10 automatically enables CUDA Separable Compilation, device linking, and PIC.
- Removes the backport of `cuda_add_library` that was necessary for older versions of CMake
- Builds warpctc as part of `fl-app-asr`
- Removes unused cruft in warpctc related to the warpctc CPU backend (which we will never use or build)
- Removes direct linking of `OpenMP` and `Threads` `IMPORTED` targets because they incorrectly propagate flags to nvcc which aren't interpreted properly. This is probably fixable in a better way.
- Gates the installation of CUB for CUDA versions <= 11 (this is necessary - including CUB with CUDA >= 11 breaks things)

Changes that need to be rebased (so they're Github auto-mentioned):
- flashlight/flashlight#215
- flashlight/flashlight#225

Reviewed By: tlikhomanenko

Differential Revision: D25013556

fbshipit-source-id: 8bbb56783dba07c0f2e7209748ddcd0e7c481db8
  • Loading branch information
jacobkahn authored and facebook-github-bot committed Nov 18, 2020
1 parent dd46aa0 commit 57f93e1
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.5.1)
cmake_minimum_required(VERSION 3.10)

project(flashlight)
project(flashlight LANGUAGES CXX C)

include(CTest)
include(CMakeDependentOption)
Expand Down
2 changes: 1 addition & 1 deletion bindings/python/CMakeLists.txt
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5.1)
cmake_minimum_required(VERSION 3.10)

include(${CMAKE_MODULE_PATH}/Buildpybind11.cmake)
include(${CMAKE_MODULE_PATH}/pybind11Tools.cmake)
Expand Down
2 changes: 1 addition & 1 deletion flashlight/lib/test/CMakeLists.txt
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5.1)
cmake_minimum_required(VERSION 3.10)

set(DIR ${CMAKE_CURRENT_LIST_DIR})
set(LIBS fl-libraries)
Expand Down
2 changes: 1 addition & 1 deletion flashlight/lib/text/CMakeLists.txt
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5.1)
cmake_minimum_required(VERSION 3.10)

# ------------------------- Components -------------------------

Expand Down
2 changes: 1 addition & 1 deletion flashlight/lib/text/decoder/CMakeLists.txt
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5.1)
cmake_minimum_required(VERSION 3.10)

include(${CMAKE_CURRENT_LIST_DIR}/lm/CMakeLists.txt)

Expand Down
2 changes: 1 addition & 1 deletion flashlight/lib/text/decoder/lm/CMakeLists.txt
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5.1)
cmake_minimum_required(VERSION 3.10)

set(KENLM_MAX_ORDER 6 CACHE STRING "Maximum ngram order for KenLM")

Expand Down
2 changes: 1 addition & 1 deletion flashlight/lib/text/dictionary/CMakeLists.txt
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5.1)
cmake_minimum_required(VERSION 3.10)

target_sources(
fl-libraries
Expand Down
2 changes: 1 addition & 1 deletion flashlight/lib/text/tokenizer/CMakeLists.txt
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5.1)
cmake_minimum_required(VERSION 3.10)

target_sources(
fl-libraries
Expand Down

0 comments on commit 57f93e1

Please sign in to comment.