Updated:

๐Ÿ”ข Pytorch ์ž˜๋ชป๋œ CUDA ์žฅ์น˜ ๋ฒˆํ˜ธ ์‚ฌ์šฉ ๋ฌธ์ œ

model.load_state_dict(
    torch.load(path, map_location='cuda:0') 
)

pretrained model, weight๋ฅผ loadํ•˜๊ฑฐ๋‚˜ ํ˜น์€ ํ›ˆ๋ จ ๋ฃจํ”„๋ฅผ resume ์„ ์œ„ํ•ด torch.load() ๋ฅผ ์‚ฌ์šฉํ•  ๋•Œ ๋งˆ์ฃผํ•  ์ˆ˜ ์žˆ๋Š” ์—๋Ÿฌ ๋กœ๊ทธ๋‹ค. ๋ฐœ์ƒํ•˜๋Š” ์ด์œ ๋Š” ํ˜„์žฌ GPU ์— ํ• ๋‹นํ•˜๋ ค๋Š” ๋ชจ๋ธ์ด ์‚ฌ์ „ ํ›ˆ๋ จ๋•Œ ํ• ๋‹น ๋˜์—ˆ๋˜ GPU ๋ฒˆํ˜ธ์™€ ํ˜„์žฌ ํ• ๋‹นํ•˜๋ ค๋Š” GPU ๋ฒˆํ˜ธ๊ฐ€ ์„œ๋กœ ์ƒ์ดํ•˜๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค. ๋”ฐ๋ผ์„œ torch.load์˜ map_location์ธ์ž์— ํ˜„์žฌ ์ž์‹ ์ด ์‚ฌ์šฉํ•˜๋ ค๋Š” GPU ๋ฒˆํ˜ธ๋ฅผ ์ž…๋ ฅํ•ด์ฃผ์ž.

Leave a comment