mpc001 / Visual_Speech_Recognition_for_Multiple_Languages

Visual Speech Recognition for Multiple Languages
Other
356 stars 56 forks source link

Using GPU in inference #6

Closed Nadedic closed 1 year ago

Nadedic commented 1 year ago

Hello So, attempting to use the GPU with a sample video trying to perform lip reading with this simple command:

python main.py --config-filename configs/LRS3_V_WER32.3.ini --data-filename test_video.mp4 --gpu-idx 0

Terminal runs normally, loading the pretrained model etc then I face this error:

load a pre-trained model from: models/LRS3/LRS3_V_WER32.3/model.pth
face tracking speed: 1.51 fps.
Traceback (most recent call last):
  File "main.py", line 210, in <module>
    main()
  File "main.py", line 189, in main
    one_step_inference(
  File "main.py", line 159, in one_step_inference
    output = lipreader(data_filename, landmarks_filename)
  File "Visual_Speech_Recognition_for_Multiple_Languages\lipreading\subroutines.py", line 107, in __call__
    output = self.model.predict(sequence)
  File "Visual_Speech_Recognition_for_Multiple_Languages\lipreading\model.py", line 141, in predict
    nbest_hyps = self.beam_search(
  File "Miniconda3\envs\VSRML\lib\site-packages\torch\nn\modules\module.py", line 1190, in _call_impl
    return forward_call(*input, **kwargs)
  File "Visual_Speech_Recognition_for_Multiple_Languages\espnet\nets\beam_search.py", line 373, in forward
    running_hyps = self.post_process(i, maxlen, maxlenratio, best, ended_hyps)
  File "Visual_Speech_Recognition_for_Multiple_Languages\espnet\nets\batch_beam_search.py", line 348, in post_process
    return self._batch_select(running_hyps, remained_ids)
  File "Visual_Speech_Recognition_for_Multiple_Languages\espnet\nets\batch_beam_search.py", line 51, in _batch_select
    score=hyps.score[ids],
RuntimeError: indices should be either on cpu or on the same device as the indexed tensor (cpu)

The lip reading task works correctly if I don't specify a GPU parameter and looking around abit, apparently the problem is offloading some variables from CPU to GPU which breaks somewhere during runtime. Any help would be appreciated. Thank you!

mpc001 commented 1 year ago

There seems to be an issue when using a higher version of PyTorch, but I believe that the issue has been resolved in the latest repository. Please feel free to check it and let me know if any further issues related this.