thu-spmi/CAT

Test on python3

Closed this issue · 15 comments

Thanks for your great work~
Have you tried to install the dependencies on python3 and run the code?

aky15 commented

change src/ctc_crf/Makefile line 18
python setup.py
to
python setup_1_0.py install
It's for python3 and torch version 1.0+

Thanks for your reply~ When I install the package, I successfully install the Kaldi and pass the demo test. When I install your package, I follow your instructions and successfully install them. However, I can install the ctc_crf_base_1_0 successfully, but when I run the demo shown below, it throws out segmentation fault (core dumped). Look forward to your reply~
微信截图_20200103152951

aky15 commented

We update the Makefile, see src/ctc_crf/Makefile for details.
In python3, some files were mistakenly deleted by the clean command and we decided to remove it.

Thanks for your quick reply! However, after I change Makefile in src/ctc_crf, I directly run make command. However, when compling gpu_den, it throws out this error, *** No rule to make target '/root/kaldi-trunk/tools/openfst/libfst.so', needed by 'libfst_read.so'. Stop.
Look forward to your reply~

aky15 commented

CAT/src/ctc_crf/gpu_den/CMakeLists.txt line 8 should be:
link_libraries(${openfst_dir}/lib/libfst.so)
sorry for the mistake.

Thanks for your reply~ I have successfully installed the package, however, it still not work for me.
image
It cannot process this line shown above.
The demo still cannot pass the test. Would it possible for you to try my demo test? (Email to you?)

aky15 commented

Well, it's really hard to figure out where the problesm is with only the code line provided and I believe more detailed error messages are needed. For the python3 version, the default package name is ctc_crf_base_1_0 (maybe you have modified src/ctc_crf/setup_1_0.py ?) Make sure to import the correct corresponding package successfully.

ctc_crf
test
Here is my test demo. After you download them, change them to .py format(because github not allowed to upload .py)
The first should be named ctc_crf.py, while the second is test.py. Run test.py.
Look forward to your reply~

Plus, in python, I try to import torch, import ctc_crf_base_1_0 and it gives me no fault~ I haven't modified the setup_1_0.py.

aky15 commented

If the package name is ctc_crf_base_1_0 , you should change ctc_crf_base.gpu_ctc to ctc_crf_base_1_0.gpu_ctc (and so for other related functions). Or you can simply rebuild the package with the name ctc_crf_base (by modifying setup_1_0.py) and remain the ctc_crf.py recipe unchanged.
If it still doesn't work, send the code as well as the error message to my Email ankeyuthu@gmail.com

Hi, the problem still bothers me. I have sent you email~ Look forward to your reply~

aky15 commented

Hi, Alex. The CTC_CRF_LOSS function input format should be:
logit: torch.cuda.FloatTensor (float32)
label: torch.IntTensor (int32)
logit_length: torch.IntTensor (int32)
label_length: torch.IntTensor (int32)

So you can assign the label in this way:

label_1 = torch.from_numpy(np.array([2,1,3]).astype('int32'))
label_2 = torch.from_numpy(np.array([2,1]).astype('int32'))
label_list = [label_1,label_2]
label = torch.cat(label_list)

Thanks for your reply~ After modifying the code as you suggest, I successfully pass the first gpu_ctc, however, gives me segmentation fault (core dumped) in the second,
logit = logit.cuda()
image
Look forward to your reply~

aky15 commented

gpu_den is for the calculating of the denominator (refer to our paper for details).
Before that, a denominator FST should be prepared in advance.(see the egs we provided)

Then add this to your training recipe:

os.environ['CUDA_VISIBLE_DEVICES'] = '0' // set visible GPU index, multi-GPU is also supported.
TARGET_GPUS = [0]
gpus = torch.IntTensor(TARGET_GPUS)
ctc_crf_base.init_env('path/to/the/den_lm/den_lm.fst', gpus)

Thanks for your reply~ You are so helpful~