Так что проблема в том, что даже после нескольких проходов вперед код внезапно выходит из строя и выдает ошибку времени выполнения cuda. как показано ниже:
Код: Выделить всё
29 / 1363
forward passing
src_pad_idx: 1
src max value: 12164, src min value: 1
making mask
tensor(6.2539, device='cuda:0', grad_fn=)
30 / 1363
forward passing
src_pad_idx: 1
src max value: 11752, src min value: 1
making mask
tensor(6.1095, device='cuda:0', grad_fn=)
31 / 1363
forward passing
src_pad_idx: 1
src max value: 12888, src min value: 1
making mask
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
in ()
7 src, trg = src.to(device), trg.to(device)
8 optimizer.zero_grad()
----> 9 output = model(src, trg[:, :-1])
10 output = output.reshape(-1, output.shape[2])
11 trg = trg[:, 1:].reshape(-1)
3 frames
in make_src_mask(self, src)
50 def make_src_mask(self, src):
51 print("making mask")
---> 52 assert torch.all(src < len(vocab)), "Source input contains out-of-bounds indices!"
53 assert (src >= 0).all() and (src < len(vocab)).all(), "Source tensor contains invalid indices"
54 src_mask = (src == self.src_pad_idx)
RuntimeError: CUDA error: device-side assert triggered
CUDA kernel errors might be asynchronously reported at some other API call, so the stacktrace below might be incorrect.
For debugging consider passing CUDA_LAUNCH_BLOCKING=1
Compile with `TORCH_USE_CUDA_DSA` to enable device-side assertions.
Код: Выделить всё
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
print(device)
src_pad_idx = vocab.stoi[""]
print("creating transformer model")
model = Transformer(
src_embedding_matrix=src_embedding_matrix,
trg_embedding_matrix=trg_embedding_matrix,
src_pad_idx=src_pad_idx,
num_heads=10,
num_encoder_layers=6,
num_decoder_layers=6,
forward_expansion=2048,
dropout=0.10,
max_len=100,
device=device,
trg_vocab=vocab
).to(device)
print("created transformer model")
Код: Выделить всё
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
in ()
16 device=device,
17 trg_vocab=vocab
---> 18 ).to(device)
19 print("created transformer model")
3 frames
/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py in convert(t)
1324 memory_format=convert_to_format,
1325 )
-> 1326 return t.to(
1327 device,
1328 dtype if t.is_floating_point() or t.is_complex() else None,
RuntimeError: CUDA error: device-side assert triggered
CUDA kernel errors might be asynchronously reported at some other API call, so the stacktrace below might be incorrect.
For debugging consider passing CUDA_LAUNCH_BLOCKING=1
Compile with `TORCH_USE_CUDA_DSA` to enable device-side assertions
Подробнее здесь: https://stackoverflow.com/questions/793 ... ard-passes