Getting this Error while running the code in PyTorch ver 1.8.1 and CUDA 10.1

(base) sajid@sajid-pc:~/Desktop/dctts-pytorch$ python3 main.py --action train --module Text2Mel
train: Text to Mel

loop 0
▝[1/60] |gs: 0, mels: 0.384276, bd1: 0.694295, atten: 0.783801, scale: 99.999000| [0.0% eta ETA unknown]Traceback (most recent call last):
File “/home/sajid/Desktop/dctts-pytorch/main.py”, line 62, in
main()
File “/home/sajid/Desktop/dctts-pytorch/main.py”, line 47, in main
train(args.module, args.load)
File “/home/sajid/Desktop/dctts-pytorch/pkg/train.py”, line 54, in train
train_text2mel(load_trained)
File “/home/sajid/Desktop/dctts-pytorch/pkg/train.py”, line 198, in train_text2mel
plot_spectrum(mels[0].cpu().data, “mel_true”, gs, dir=logdir)
File “/home/sajid/Desktop/dctts-pytorch/pkg/utils.py”, line 110, in plot_spectrum
im = ax.imshow(np.flip(spectrum, 0), cmap=“jet”, aspect=0.2 * spectrum.shape[1] / spectrum.shape[0])
File “<array_function internals>”, line 5, in flip
File “/home/sajid/anaconda3/lib/python3.9/site-packages/numpy/lib/function_base.py”, line 241, in flip
return m[indexer]
ValueError: step must be greater than zero

The issue seems to be raised by numpy in:

im = ax.imshow(np.flip(spectrum, 0), cmap=“jet”, aspect=0.2 * spectrum.shape[1] / spectrum.shape[0])
> ValueError: step must be greater than zero

so maybe you are passing a non-contiguous tensor to this method.
Call spectrum.numpy() or spectrum.contiguou().numpy() before using it in flip.

Thanks a lot, it worked and fixed the issue, however, I have found another issue.

(dctts-pytorch) sajid@sajid-pc:~/Desktop/dctts-pytorch$ python3 main.py --action train --module Text2Mel
train: Text to Mel
loop 0
▝[16/60] |gs: 15, mels: 0.257367, bd1: 0.689199, atten: 0.787459, scale: 99.984001| [26.7% eta 00:01:22]Traceback (most recent call last):
  File "/home/sajid/Desktop/dctts-pytorch/main.py", line 62, in <module>
    main()
  File "/home/sajid/Desktop/dctts-pytorch/main.py", line 47, in main
    train(args.module, args.load)
  File "/home/sajid/Desktop/dctts-pytorch/pkg/train.py", line 54, in train
    train_text2mel(load_trained)
  File "/home/sajid/Desktop/dctts-pytorch/pkg/train.py", line 168, in train_text2mel
    atten_guide * graph.attention * atten_mask,
RuntimeError: The size of tensor a (300) must match the size of tensor b (328) at non-singleton dimension 2