Skip to content

Commit ad73548

Browse files
authored
[build] add configure option --with-cudadecoder=no to disable building of cuda decoder (#3908)
1 parent 134b1e9 commit ad73548

File tree

5 files changed

+99
-47
lines changed

5 files changed

+99
-47
lines changed

src/configure

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ Configuration options:
7070
--static Build and link against static libraries [default=no]
7171
--shared Build and link against shared libraries [default=no]
7272
--use-cuda Build with CUDA [default=yes]
73+
--with-cudadecoder Build with CUDA decoder [default=yes]
7374
--cudatk-dir=DIR CUDA toolkit directory
7475
--cuda-arch=FLAGS Override the default CUDA_ARCH flags. See:
7576
https://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/index.html#nvcc-examples.
@@ -500,11 +501,10 @@ function configure_cuda {
500501
echo >> kaldi.mk
501502
echo "# CUDA configuration" >> kaldi.mk
502503
echo >> kaldi.mk
504+
503505
echo CUDA = true >> kaldi.mk
504506
echo CUDATKDIR = $CUDATKDIR >> kaldi.mk
505507
echo "CUDA_ARCH = $CUDA_ARCH" >> kaldi.mk
506-
507-
508508
echo >> kaldi.mk
509509

510510
# 64bit/32bit? We do not support cross compilation with CUDA so, use direct
@@ -525,7 +525,7 @@ WARNING: CUDA will not be used!
525525
CUDA is not supported with 32-bit builds."
526526
exit 1;
527527
fi
528-
528+
529529
#add cusolver flags for newer toolkits
530530
if [ "$CUSOLVER" == "true" ]; then
531531
echo "CUDA_LDLIBS += -lcusolver" >> kaldi.mk
@@ -744,6 +744,7 @@ debug_level=1
744744
double_precision=false
745745
dynamic_kaldi=false
746746
use_cuda=true
747+
with_cudadecoder=1
747748
static_fst=false
748749
static_math=false
749750
threaded_atlas=false
@@ -818,6 +819,15 @@ do
818819
--use-cuda=no)
819820
use_cuda=false;
820821
shift ;;
822+
--with-cudadecoder)
823+
with_cudadecoder=1;
824+
shift ;;
825+
--with-cudadecoder=yes)
826+
with_cudadecoder=1;
827+
shift ;;
828+
--with-cudadecoder=no)
829+
with_cudadecoder=0;
830+
shift ;;
821831
--static-math)
822832
static_math=true;
823833
shift ;;
@@ -1090,6 +1100,8 @@ else
10901100
echo "CUBROOT = $CUBROOT" >> kaldi.mk
10911101
fi
10921102

1103+
echo "WITH_CUDADECODER = $with_cudadecoder" >> kaldi.mk
1104+
echo >> kaldi.mk
10931105

10941106
# OS-specific steps given below append to kaldi.mk
10951107
echo "Doing OS specific configurations ..."

src/cudadecoder/Makefile

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
all:
2-
2+
33
EXTRA_CXXFLAGS = -Wno-sign-compare
44
include ../kaldi.mk
55

66
ifeq ($(CUDA), true)
7+
ifneq ($(WITH_CUDADECODER), 0)
78

89
# Make sure we have CUDA_ARCH from kaldi.mk,
910
ifndef CUDA_ARCH
@@ -15,9 +16,6 @@ TESTFILES =
1516
OBJFILES = batched-threaded-nnet3-cuda-pipeline.o decodable-cumatrix.o \
1617
cuda-decoder.o cuda-decoder-kernels.o cuda-fst.o
1718

18-
LDFLAGS += $(CUDA_LDFLAGS)
19-
LDLIBS += $(CUDA_LDLIBS)
20-
2119
LIBNAME = kaldi-cudadecoder
2220

2321
ADDLIBS = ../cudamatrix/kaldi-cudamatrix.a ../base/kaldi-base.a ../matrix/kaldi-matrix.a \
@@ -26,9 +24,19 @@ ADDLIBS = ../cudamatrix/kaldi-cudamatrix.a ../base/kaldi-base.a ../matrix/kaldi-
2624
../tree/kaldi-tree.a ../online2/kaldi-online2.a ../nnet3/kaldi-nnet3.a \
2725
../cudafeat/kaldi-cudafeat.a
2826

27+
LDFLAGS += $(CUDA_LDFLAGS)
28+
LDLIBS += $(CUDA_LDLIBS)
29+
30+
2931
# Implicit rule for kernel compilation
3032
%.o : %.cu
3133
$(CUDATKDIR)/bin/nvcc -c $< -o $@ $(CUDA_INCLUDE) $(CUDA_FLAGS) $(CUDA_ARCH) -I../ -I$(OPENFSTINC)
34+
35+
else
36+
all:
37+
$(warning "Not building cudadecoder extension -- to build with it, configure with --with-cudadecoder[=true]")
38+
endif
39+
3240
endif
3341

3442
include ../makefiles/default_rules.mk

src/cudadecoderbin/Makefile

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
all:
2-
2+
33
include ../kaldi.mk
44

55
ifeq ($(CUDA), true)
6+
ifneq ($(WITH_CUDADECODER), 0)
7+
8+
# Make sure we have CUDA_ARCH from kaldi.mk,
9+
ifndef CUDA_ARCH
10+
$(error CUDA_ARCH is undefined, run 'src/configure')
11+
endif
612

713
LDFLAGS += $(CUDA_LDFLAGS)
814
LDLIBS += $(CUDA_LDLIBS)
@@ -14,13 +20,18 @@ OBJFILES =
1420
TESTFILES =
1521

1622
ADDLIBS = ../cudadecoder/kaldi-cudadecoder.a ../cudafeat/kaldi-cudafeat.a \
17-
../online2/kaldi-online2.a ../ivector/kaldi-ivector.a \
18-
../nnet3/kaldi-nnet3.a ../chain/kaldi-chain.a ../nnet2/kaldi-nnet2.a \
19-
../cudamatrix/kaldi-cudamatrix.a ../decoder/kaldi-decoder.a \
20-
../lat/kaldi-lat.a ../fstext/kaldi-fstext.a ../hmm/kaldi-hmm.a \
21-
../feat/kaldi-feat.a ../transform/kaldi-transform.a \
22-
../gmm/kaldi-gmm.a ../tree/kaldi-tree.a ../util/kaldi-util.a \
23-
../matrix/kaldi-matrix.a ../base/kaldi-base.a
23+
../online2/kaldi-online2.a ../ivector/kaldi-ivector.a \
24+
../nnet3/kaldi-nnet3.a ../chain/kaldi-chain.a ../nnet2/kaldi-nnet2.a \
25+
../cudamatrix/kaldi-cudamatrix.a ../decoder/kaldi-decoder.a \
26+
../lat/kaldi-lat.a ../fstext/kaldi-fstext.a ../hmm/kaldi-hmm.a \
27+
../feat/kaldi-feat.a ../transform/kaldi-transform.a \
28+
../gmm/kaldi-gmm.a ../tree/kaldi-tree.a ../util/kaldi-util.a \
29+
../matrix/kaldi-matrix.a ../base/kaldi-base.a
30+
31+
else
32+
all:
33+
$(warning "Not building cudadecoder extension -- to build with it, configure with --with-cudadecoder[=true]")
34+
endif
2435

2536
endif
2637

src/cudafeat/Makefile

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,31 @@
1-
2-
31
all:
4-
2+
53
include ../kaldi.mk
6-
ifeq ($(CUDA), true)
7-
8-
TESTFILES =
94

105
ifeq ($(CUDA), true)
11-
OBJFILES += feature-window-cuda.o \
12-
feature-spectral-cuda.o \
13-
feature-online-cmvn-cuda.o \
14-
online-ivector-feature-cuda-kernels.o \
15-
online-ivector-feature-cuda.o \
16-
online-cuda-feature-pipeline.o \
17-
feature-online-batched-spectral-cuda.o \
18-
feature-online-batched-spectral-cuda-kernels.o \
19-
feature-online-batched-cmvn-cuda.o \
20-
feature-online-batched-cmvn-cuda-kernels.o \
21-
feature-online-batched-ivector-cuda.o \
22-
feature-online-batched-ivector-cuda-kernels.o \
23-
online-batched-feature-pipeline-cuda.o
6+
ifneq ($(WITH_CUDADECODER), 0)
7+
8+
# Make sure we have CUDA_ARCH from kaldi.mk,
9+
ifndef CUDA_ARCH
10+
$(error CUDA_ARCH is undefined, run 'src/configure')
2411
endif
2512

13+
TESTFILES =
14+
15+
OBJFILES += feature-window-cuda.o \
16+
feature-spectral-cuda.o \
17+
feature-online-cmvn-cuda.o \
18+
online-ivector-feature-cuda-kernels.o \
19+
online-ivector-feature-cuda.o \
20+
online-cuda-feature-pipeline.o \
21+
feature-online-batched-spectral-cuda.o \
22+
feature-online-batched-spectral-cuda-kernels.o \
23+
feature-online-batched-cmvn-cuda.o \
24+
feature-online-batched-cmvn-cuda-kernels.o \
25+
feature-online-batched-ivector-cuda.o \
26+
feature-online-batched-ivector-cuda-kernels.o \
27+
online-batched-feature-pipeline-cuda.o
28+
2629
LIBNAME = kaldi-cudafeat
2730

2831
ADDLIBS = ../feat/kaldi-feat.a ../util/kaldi-util.a ../matrix/kaldi-matrix.a \
@@ -33,8 +36,15 @@ LDFLAGS += $(CUDA_LDFLAGS)
3336
LDLIBS += $(CUDA_LDLIBS)
3437

3538

39+
# Implicit rule for kernel compilation
3640
%.o : %.cu
3741
$(CUDATKDIR)/bin/nvcc -c -g $< -o $@ $(CUDA_INCLUDE) $(CUDA_FLAGS) $(CUDA_ARCH) -I../ -I$(OPENFSTINC)
42+
43+
else
44+
all:
45+
$(warning "Not building cudadecoder extension -- to build with it, configure with --with-cudadecoder[=true]")
46+
endif
47+
3848
endif
3949

4050
include ../makefiles/default_rules.mk

src/cudafeatbin/Makefile

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,27 @@
1-
21
all:
2+
33
EXTRA_CXXFLAGS = -Wno-sign-compare
44
include ../kaldi.mk
55

6+
ifeq ($(CUDA), true)
7+
ifneq ($(WITH_CUDADECODER), 0)
8+
9+
# Make sure we have CUDA_ARCH from kaldi.mk,
10+
ifndef CUDA_ARCH
11+
$(error CUDA_ARCH is undefined, run 'src/configure')
12+
endif
13+
614
LDFLAGS += $(CUDA_LDFLAGS)
715
LDLIBS += $(CUDA_LDLIBS)
816

9-
BINFILES =
10-
11-
ifeq ($(CUDA), true)
12-
BINFILES += compute-mfcc-feats-cuda \
13-
apply-cmvn-online-cuda \
14-
compute-online-feats-cuda \
15-
compute-fbank-feats-cuda \
16-
apply-batched-cmvn-online-cuda \
17-
compute-mfcc-online-batched-cuda \
18-
compute-fbank-online-batched-cuda \
19-
compute-online-feats-batched-cuda
20-
endif
17+
BINFILES = compute-mfcc-feats-cuda \
18+
apply-cmvn-online-cuda \
19+
compute-online-feats-cuda \
20+
compute-fbank-feats-cuda \
21+
apply-batched-cmvn-online-cuda \
22+
compute-mfcc-online-batched-cuda \
23+
compute-fbank-online-batched-cuda \
24+
compute-online-feats-batched-cuda
2125

2226
OBJFILES =
2327

@@ -31,4 +35,11 @@ ADDLIBS = ../cudafeat/kaldi-cudafeat.a ../online2/kaldi-online2.a \
3135
../tree/kaldi-tree.a ../util/kaldi-util.a ../matrix/kaldi-matrix.a \
3236
../base/kaldi-base.a
3337

38+
else
39+
all:
40+
$(warning "Not building cudadecoder extension -- to build with it, configure with --with-cudadecoder[=true]")
41+
endif
42+
43+
endif
44+
3445
include ../makefiles/default_rules.mk

0 commit comments

Comments
 (0)