Skip to content

Commit

Permalink
Add support for Cuda 12.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mmcauliffe authored and h-vetinari committed Jul 29, 2023
1 parent e89fbbe commit 5b25d50
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 7 deletions.
5 changes: 5 additions & 0 deletions recipe/build_kaldi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}" \
Expand Down
24 changes: 17 additions & 7 deletions recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down
23 changes: 23 additions & 0 deletions recipe/patches/0006-Cuda-12-support.patch
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit 5b25d50

Please sign in to comment.