Skip to content

Commit 8edfa9d

Browse files
csukuangfjdanpovey
authored andcommitted
[scripts,build] Fix the MKL LD_PRELOAD issue for kaldi pybind test; rename a file. (#3817)
1 parent df970aa commit 8edfa9d

File tree

6 files changed

+33
-18
lines changed

6 files changed

+33
-18
lines changed

egs/aishell/s10/chain/inference.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def main():
4343
model.eval()
4444

4545
specifier = 'ark,scp:{filename}.ark,{filename}.scp'.format(
46-
filename=os.path.join(args.dir, 'confidence'))
46+
filename=os.path.join(args.dir, 'nnet_output'))
4747

4848
if args.save_as_compressed:
4949
Writer = kaldi.CompressedMatrixWriter
@@ -83,8 +83,8 @@ def main():
8383
float(batch_idx) / len(dataloader) * 100))
8484

8585
writer.Close()
86-
logging.info('confidence is saved to {}'.format(
87-
os.path.join(args.dir, 'confidence.scp')))
86+
logging.info('pseudo-log-likelihood is saved to {}'.format(
87+
os.path.join(args.dir, 'nnet_output.scp')))
8888

8989

9090
if __name__ == '__main__':

egs/aishell/s10/local/decode.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ post_decode_acwt=10 # can be used in 'chain' systems to scale acoustics by 10
2020
. parse_options.sh || exit 1
2121

2222
if [ $# != 4 ]; then
23-
echo "Usage: $0 [options] <graph-dir> <trans_model> <confidence_scp> <decode-dir>"
23+
echo "Usage: $0 [options] <graph-dir> <trans_model> <nnet_output_scp> <decode-dir>"
2424
exit 1
2525
fi
2626

2727
graphdir=$1
2828
trans_model=$2
29-
confidence_scp=$3
29+
nnet_output_scp=$3
3030
dir=$4
3131

3232
if [[ ! -d $graphdir ]]; then
@@ -39,15 +39,15 @@ if [[ ! -f $trans_model ]]; then
3939
exit 1
4040
fi
4141

42-
if [[ ! -f $confidence_scp ]]; then
43-
echo "confidence scp $confidence_scp does not exist"
42+
if [[ ! -f $nnet_output_scp ]]; then
43+
echo "nnet_output_scp $nnet_output_scp does not exist"
4444
exit 1
4545
fi
4646

4747
mkdir -p $dir
4848

4949
for i in $(seq $nj); do
50-
utils/split_scp.pl -j $nj $[$i - 1] $confidence_scp $dir/confidence.$i.scp
50+
utils/split_scp.pl -j $nj $[$i - 1] $nnet_output_scp $dir/nnet_output.$i.scp
5151
done
5252

5353
lat_wspecifier="ark:|lattice-scale --acoustic-scale=$post_decode_acwt ark:- ark:- | gzip -c >$dir/lat.JOB.gz"
@@ -66,4 +66,4 @@ $cmd --num-threads $num_threads JOB=1:$nj $dir/log/decode.JOB.log \
6666
--min-active=$min_active \
6767
--num-threads=$num_threads \
6868
--word-symbol-table=$graphdir/words.txt \
69-
$trans_model $graphdir/HCLG.fst scp:$dir/confidence.JOB.scp "$lat_wspecifier" || exit 1
69+
$trans_model $graphdir/HCLG.fst scp:$dir/nnet_output.JOB.scp "$lat_wspecifier" || exit 1

egs/aishell/s10/local/run_chain.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,8 @@ if [[ $stage -le 9 ]]; then
174174
echo "inference: computing likelihood"
175175
for x in test dev; do
176176
mkdir -p exp/chain/inference/$x
177-
if [[ -f exp/chain/inference/$x/confidence.scp ]]; then
178-
echo "exp/chain/inference/$x/confidence.scp already exists! Skip"
177+
if [[ -f exp/chain/inference/$x/nnet_output.scp ]]; then
178+
echo "exp/chain/inference/$x/nnet_output.scp already exists! Skip"
179179
else
180180
best_epoch=$(cat exp/chain/train/best-epoch-info | grep 'best epoch' | awk '{print $NF}')
181181
inference_checkpoint=exp/chain/train/epoch-${best_epoch}.pt
@@ -201,8 +201,8 @@ fi
201201
if [[ $stage -le 10 ]]; then
202202
echo "decoding"
203203
for x in test dev; do
204-
if [[ ! -f exp/chain/inference/$x/confidence.scp ]]; then
205-
echo "exp/chain/inference/$x/confidence.scp does not exist!"
204+
if [[ ! -f exp/chain/inference/$x/nnet_output.scp ]]; then
205+
echo "exp/chain/inference/$x/nnet_output.scp does not exist!"
206206
echo "Please run inference.py first"
207207
exit 1
208208
fi
@@ -212,7 +212,7 @@ if [[ $stage -le 10 ]]; then
212212
--nj $nj \
213213
exp/chain/graph \
214214
exp/chain/0.trans_mdl \
215-
exp/chain/inference/$x/confidence.scp \
215+
exp/chain/inference/$x/nnet_output.scp \
216216
exp/chain/decode_res/$x
217217
done
218218
fi

src/configure

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,6 +1244,15 @@ elif [ "`uname`" == "Linux" ]; then
12441244
echo MKLLIB = $MKLLIBDIR >> kaldi.mk
12451245
fi
12461246
echo >> kaldi.mk
1247+
1248+
echo "MKL_LD_PRELOAD := $MKLROOT/lib/intel64/libmkl_def.so \\
1249+
$MKLROOT/lib/intel64/libmkl_avx2.so \\
1250+
$MKLROOT/lib/intel64/libmkl_core.so \\
1251+
$MKLROOT/lib/intel64/libmkl_intel_lp64.so \\
1252+
$MKLROOT/lib/intel64/libmkl_intel_thread.so" >> kaldi.mk
1253+
1254+
echo >> kaldi.mk
1255+
12471256
check_exists makefiles/linux_x86_64_mkl.mk
12481257
cat makefiles/linux_x86_64_mkl.mk >> kaldi.mk
12491258
echo "MKLFLAGS = ${MKL_LINK_LINE} ${THREADING_LINE} $EXTRA_LIBS " >> kaldi.mk

src/pybind/Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ LDFLAGS += -Wl,-rpath=$(CURDIR)/../../tools/openfst/lib
9797

9898
LIBFILE=$(LIBNAME)$(LIBFILE_EXTENSION)
9999

100+
ifdef MKL_LD_PRELOAD
101+
LD_PRELOAD += $(MKL_LD_PRELOAD)
102+
export LD_PRELOAD
103+
endif
100104

101105
.PHONY: all clean test
102106

@@ -138,6 +142,6 @@ depend:
138142
for f in $(CCFILES); do \
139143
$(CXX) -M -MT "$$(dirname $$f)/$$(basename -s .cc $$f).o" \
140144
$(CXXFLAGS) $$f >> .depend.mk; \
141-
done
145+
done
142146

143147
-include .depend.mk

tools/extras/install_mkl.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,13 +254,15 @@ ConfigLdSo() {
254254
ldconfig )
255255
}
256256
257-
# Load MKL libraris, which is need for pybind tests to pass
257+
# Load MKL libraries, which is needed for pybind tests to pass
258258
(
259-
echo "export LD_PRELOAD:=/opt/intel/mkl/lib/intel64/libmkl_def.so:\
259+
# WARNING: we assume that you installed MKL in the default path: /opt/intel
260+
# if not, please refer to `MKL_LD_PRELOAD` in `src/kaldi.mk`
261+
echo "export LD_PRELOAD=/opt/intel/mkl/lib/intel64/libmkl_def.so:\
260262
/opt/intel/mkl/lib/intel64/libmkl_avx2.so:\
261263
/opt/intel/mkl/lib/intel64/libmkl_core.so:\
262264
/opt/intel/mkl/lib/intel64/libmkl_intel_lp64.so:\
263-
/opt/intel/mkl/lib/intel64/libmkl_intel_thread.so"
265+
/opt/intel/mkl/lib/intel64/libmkl_intel_thread.so:${LD_PRELOAD}"
264266
) >> env.sh
265267
266268
# Invoke installation.

0 commit comments

Comments
 (0)