Closed wienerjier closed 2 months ago
Yes, please have a look at https://github.com/k2-fsa/k2/blob/b8a45acfa16464324f8ba6cc10b6a9dd3bba0ccc/k2/torch/bin/ctc_decode.cu#L126
kaldifeat::FbankOptions fbank_opts; fbank_opts.frame_opts.samp_freq = FLAGS_sample_rate; fbank_opts.frame_opts.dither = 0; fbank_opts.frame_opts.frame_shift_ms = FLAGS_frame_shift_ms; fbank_opts.frame_opts.frame_length_ms = FLAGS_frame_length_ms; fbank_opts.mel_opts.num_bins = FLAGS_num_bins; fbank_opts.device = device;
You need to assign a GPU device to fbank_opts
torch::Tensor features = fbank.ComputeFeatures(strided, /*vtln_warp*/ 1.0f);
You need to move
strided
to the same device asfbank_opts
.
follow the above links, I test it on arm cpu, but I got a c10 error: what(): self must be a matrix. I wonder it's called by wave_data reader or by the libtorch?
Error is like below:
terminate called after throwing an instance of c10::Error
what(): self must be a matrix
Exception raised from meta at /media/nvidia/NVME/pytorch/pytorch-v1.10.0/aten/src/ATen/native/LinearAlgebra.cpp:46 (most recent call first):
frame #0: c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string<char, std::char_traits
My wave_data is like below : dose it right type for k2::ComputeFeatures?
-0.0054 -0.0063 -0.0063 -0.0042 -0.0025 -0.0025 -0.0036 -0.0062 [ CPUFloatType{258000} ]
my code is like this:
using namespace std; int main() {
torch::Device device(torch::kCPU);
kaldifeat::FbankOptions fbank_opts;
fbank_opts.frame_opts.samp_freq = 16000;
fbank_opts.frame_opts.dither = 0;
fbank_opts.frame_opts.frame_shift_ms = 10.0;
fbank_opts.frame_opts.frame_length_ms = 25.0;
fbank_opts.mel_opts.num_bins = 80;
fbank_opts.device = torch::Device(torch::kCPU);
kaldifeat::Fbank fbank(fbank_opts);
std::cout<<fbank_opts.device<<std::endl;
std::vector<std::string> wave_filenames(1);
wave_filenames[0]="/home/asr/vadspeaker/kaldifeat/testalan/hj.wav";
auto wave_data = k2::ReadWave(wave_filenames, 16000);
for (auto &w : wave_data) {
w = w.to(device);
}
std::cout<<wave_data<<std::endl;
std::cout<<typeid(wave_data).name()<<std::endl;
std::vector<int64_t> num_frames;
auto features_vec = k2::ComputeFeatures(fbank, wave_data, &num_frames);
}
Can you use gdb to get the stack trace?
Yes, please have a look at https://github.com/k2-fsa/k2/blob/b8a45acfa16464324f8ba6cc10b6a9dd3bba0ccc/k2/torch/bin/ctc_decode.cu#L126
You need to assign a GPU device to fbank_opts
https://github.com/k2-fsa/k2/blob/b8a45acfa16464324f8ba6cc10b6a9dd3bba0ccc/k2/torch/csrc/features.cu#L49
You need to move
strided
to the same device asfbank_opts
.