From 5b25d50c643b1476d7809e4814a5f9e37f17ab69 Mon Sep 17 00:00:00 2001 From: Michael McAuliffe Date: Fri, 28 Jul 2023 22:16:46 -0700 Subject: [PATCH] Add support for Cuda 12.0 --- recipe/build_kaldi.sh | 5 +++++ recipe/meta.yaml | 24 ++++++++++++++++------- recipe/patches/0006-Cuda-12-support.patch | 23 ++++++++++++++++++++++ 3 files changed, 45 insertions(+), 7 deletions(-) create mode 100644 recipe/patches/0006-Cuda-12-support.patch diff --git a/recipe/build_kaldi.sh b/recipe/build_kaldi.sh index 1bcc9e6..187f3d1 100644 --- a/recipe/build_kaldi.sh +++ b/recipe/build_kaldi.sh @@ -77,6 +77,11 @@ mkdir build pushd build +if [[ "${target_platform}" == "linux-64" ]] && [[ "${cuda_compiler_version}" =~ 12.* ]]; then + # Cuda 12.0 places files in the targets/platform directory structure rather than in PREFIX/lib and PREFIX/include + CMAKE_ARGS="${CMAKE_ARGS} -DCUDA_TOOLKIT_ROOT_DIR=${PREFIX}/targets/x86_64-linux" +fi + cmake ${CMAKE_ARGS} \ -DCMAKE_INSTALL_PREFIX="${PREFIX}" \ -DCONDA_ROOT="${PREFIX}" \ diff --git a/recipe/meta.yaml b/recipe/meta.yaml index dd82211..b4218f3 100755 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -42,11 +42,10 @@ source: - patches/0003-Support-openfst-1.8.1.patch - patches/0004-Support-openfst-1.8.2.patch - patches/0005-Shared-libraries-on-windows.patch + - patches/0006-Cuda-12-support.patch # [(cuda_compiler_version or "").startswith("12")] build: number: 1 - # Bug in for cuda 11.1 with c++17 on linux: https://forums.developer.nvidia.com/t/nvc-20-9-fails-to-compile-code-instantiating-any-std-tuple-with-gcc-10-2-on-c-17/160987 - skip: true # [cuda_compiler_version == "10.2" or (linux and cuda_compiler_version == "11.1")] requirements: build: @@ -72,24 +71,35 @@ outputs: - libtool # [not win] - automake # [not win] host: + - cuda-version {{ cuda_compiler_version }} # [cuda_compiler_version != "None"] + - cuda-profiler-api # [(cuda_compiler_version or "").startswith("12")] + - cuda-nvtx-dev # [(cuda_compiler_version or "").startswith("12")] + - cuda-cudart-dev # [(cuda_compiler_version or "").startswith("12")] + - cuda-driver-dev # [(cuda_compiler_version or "").startswith("12")] + - cuda-nvrtc-dev # [(cuda_compiler_version or "").startswith("12")] + - libcublas-dev # [(cuda_compiler_version or "").startswith("12")] + - libcurand-dev # [(cuda_compiler_version or "").startswith("12")] + - libcufft-dev # [(cuda_compiler_version or "").startswith("12")] + - libcusolver-dev # [(cuda_compiler_version or "").startswith("12")] + - libcusparse-dev # [(cuda_compiler_version or "").startswith("12")] - icu - libblas - libcblas - liblapack - liblapacke - - magma # [cuda_compiler_version != "None"] - - pthreads-win32 # [win] + - magma # [cuda_compiler_version != "None"] + - pthreads-win32 # [win] - zlib - openfst - - dlfcn-win32 # [win] + - dlfcn-win32 # [win] run: - libblas - libcblas - liblapack - liblapacke - - magma # [cuda_compiler_version != "None"] + - magma # [cuda_compiler_version != "None"] - openfst - - ucrt # [win] + - ucrt # [win] test: # will also run run_test.py (checking the binaries) commands: diff --git a/recipe/patches/0006-Cuda-12-support.patch b/recipe/patches/0006-Cuda-12-support.patch new file mode 100644 index 0000000..bbc39fe --- /dev/null +++ b/recipe/patches/0006-Cuda-12-support.patch @@ -0,0 +1,23 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 24cb574..b8ca1c0 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1,4 +1,4 @@ +-cmake_minimum_required(VERSION 3.18) ++cmake_minimum_required(VERSION 3.26) + project(kaldi) + + if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) +@@ -16,6 +16,12 @@ if(CONDA_ROOT) + include_directories("${CONDA_ROOT}/include") + if (NOT CUDA_TOOLKIT_ROOT_DIR) + set(CUDA_TOOLKIT_ROOT_DIR "${CONDA_ROOT}") ++ else() ++ set(CMAKE_INCLUDE_PATH "${CMAKE_INCLUDE_PATH};${CUDA_TOOLKIT_ROOT_DIR}/include") ++ set(CMAKE_LIBRARY_PATH "${CMAKE_LIBRARY_PATH};${CUDA_TOOLKIT_ROOT_DIR}/lib;${CUDA_TOOLKIT_ROOT_DIR}/lib/stubs") ++ link_directories("${CUDA_TOOLKIT_ROOT_DIR}/lib") ++ link_directories("${CUDA_TOOLKIT_ROOT_DIR}/lib/stubs") ++ include_directories("${CUDA_TOOLKIT_ROOT_DIR}/include") + endif() + + endif()