Notice
Recent Posts
Recent Comments
Link
반응형
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- ai개발밋업
- Git
- 쉽게배우는운영체제
- Python
- 정보처리기사
- backpropagation
- 우분투리눅스
- repository 복구
- 2020정보처리기사
- AIStages
- GitHub
- BPTT
- RNN
- CNN
- ann
- java
- 리눅스연습문제
- 운영체제연습문제
- 판교퇴근길밋업
- homebrew설치
- 리눅스7장
- Swing
- 부스트캠프 AI Tech
- Django
- 자바
- 파이썬
- MAC OS
- 운영체제
- 딥러닝
- github branch
Archives
- Today
- Total
코딩하는 애옹😸
[PyTorch] Troubleshooting 본문
728x90
반응형
PyTorch Troubleshooting
GPUtil 사용하기
GPU의 상태를 보여줌
iter마다 메모리가 늘어나는지 확인
!pip install GPUtil import GPUtil GPUtil.showUtilization()
1. empty_cache() 써보기
torch.cuda.empty_cache()
- 사용되지 않은 GPU상 cache 정리
- Loop 전에 실행하면 이전의 학습에 남아있던 메모리들에 의해 영향을 받을 확률이 적음
2. Training loop에 tensor로 축적되는 변수 확인
- tensor로 처리된 변수는 GPU 상에 메모리 사용
- 해당 변수 loop 안에 연산이 있을 때 GPU에 computation graph를 생성 (메모리 잠식)
3. 가능 batch 사이즈 실험
- batch size를 1로 해서 실험
oom = False try: run_model(batch_size) except RuntimeError: # Out of memory oom = True if oom: for _ in range(batch_size): run_model(1)
4. torch.no_grad() 사용
- inference 시점에서는 torch.no_grad() 사용하기
- backward로 인해 쌓이는 메모리에서 자유로움
with torch.no_grad():
for data, target in test_loader:
output = network(data)
test_loss += F.nll_loss(output, target, size_average=False).item()
pred = output.data.max(1, keepdim=True)[1]
correct += pred.eq(target.data.view_as(pred)).sum()
5. 기타
- colab에서는 너무 큰 사이즈는 실행하지 말 것 (LSTM, ... )
- torchsummary 등으로 사이즈 맞출 것 (CNN)
반응형
'부스트캠프 AI Tech 3기 > Study' 카테고리의 다른 글
Semantic Segmentation 대회에서 사용하는 방법 (0) | 2022.05.09 |
---|---|
AI와 저작권법 (0) | 2022.02.16 |
[PyTorch] Multi-GPU (0) | 2022.01.27 |
[PyTorch] 모델 불러오기 (0) | 2022.01.26 |
[PyTorch] AutoGrad (0) | 2022.01.25 |
Comments