์ฌํ๊น์ง PyTorch ์ฌ์ฉํ ๋ฐฉ์๊ณผ ์ฐจ์ด๊ฐ ์์๋ ๊ฑฐ ๊ฐ์๋ฐ ์ ๋ฐ ๋ฌธ๊ตฌ๊ฐ ๋ ์ ์กฐ๊ธ ๋นํฉ์ค๋ฌ์ ๋ค. BERT ์ค์ต ์ค์ ๋ง๋ ๊ฑฐ์๊ณ ์ผ๋จ ํด๊ฒฐํ๊ธด ํ๋๋ฐ ๊น๋ํ ๋ฐฉ์์ ์๋ ๊ฒ ๊ฐ๋ค.
๋นจ๊ฐ์ ์ฒดํฌ ํ์๋ฅผ ํด๋ ๊ณณ์์ RuntimeError: ~ ๊ฐ ๋ด๊ณ ๋ชจ๋ ํ ์๊ฐ cuda:0์ ์ฌ๋ผ๊ฐ์ผ ํ๋๋ฐ cpu์ ์ฌ๋ผ๊ฐ ๊ฒ ์๋ ๊ฒ ๊ฐ์์ ๋นจ๊ฐ์ ์ฒดํฌ ์ ์ print()๋ก ๊ฐ ํ ์๊ฐ ์ด๋ ์ฌ๋ผ๊ฐ์๋์ง device๋ฅผ ์ฐ์ด๋ณด์๋ค.
input_ids, attention_mask, token_type_ids๋ custom torch dataset, collate_fn, dataloader๋ฅผ ๊ฑฐ์ณ ์ต์ข ์ ์ผ๋ก ๋ชจ๋ธ ํ์ต ๋ฐ์ดํฐ๊ฐ ๋๊ธฐ ๋๋ฌธ์ collate_fn์ ๋ฆฌํด ๊ฒฐ๊ณผ์ ๋ชจ๋ .to(device)๋ฅผ ์ถ๊ฐํด์ฃผ์๋ค.
๋ชจ๋ GPU์ ์ฌ๋ผ๊ฐ ๊ฒ์ ํ์ธํ๋ค.
'๐จโ๐ซ' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[PyTorch] RuntimeError - dtype, grad_fn (0) | 2023.06.27 |
---|---|
[PLM] IndexError: Target X is out of bounds. (0) | 2022.11.16 |
[TensorFlow] WARNING:tensorflow:Can save best model only with acc available, skipping. (0) | 2022.09.05 |
[KoNLPy] The MeCab dictionary does not exist at "~". (0) | 2022.07.11 |
[Ubuntu] Give root password for maintenance (or type Control-D to continue) (0) | 2022.06.24 |