파이토치 모델을 돌리다 보면, 모델 크기와 데이터 배치 만큼 그래픽 카드의 메모리를 쓰는 데 그 크기를 정확히 알고 싶을 때가 있다. nvidia-smi 를 써서 눈대중으로 알아볼 수 있지만, torch 를 임포트해서 바이트 단위 사용량을 알 수 있다. 바로 아래 코드를 사용하면 된다.
메모리 크기는 byte 단위로 나타내므로, Megabyte 로 표기하려면 1024**2 로 나누면 된다.
참고
Get total amount of free GPU memory and available using pytorch
I'm using google colab free Gpu's for experimentation and wanted to know how much GPU Memory available to play around, torch.cuda.memory_allocated() returns the current GPU memory occupied, but how...
stackoverflow.com
2. https://discuss.pytorch.org/t/how-to-calculate-the-gpu-memory-that-a-model-uses/157486
How to calculate the GPU memory that a model uses?
I wanted to reduce the size of Pytorch models since it consumes a lot of GPU memory and I am not gonna train them again. First, I thought I could change them to TensorRT engine. and then I was curious how I can calculate the size of gpu memory that it uses
discuss.pytorch.org
'노트정리 > 인공지능·데이터' 카테고리의 다른 글
| 허깅페이스 (huggingface) 모델 다운로드 받기 (1) | 2024.10.19 |
|---|---|
| matplotlib에서 축(axis)에 사용자 정의 포맷팅 적용 방법 재정리 (0) | 2024.03.03 |
| 파이토치(pytorch)에서 사전학습 모델과 데이터셋의 경로 설정 (0) | 2024.02.16 |
| SQL 연습할만한 웹사이트 (0) | 2024.01.09 |
| Elasticsearch 를 사용할 때 Kibana 를 원격사용하기 위한 방법 (0) | 2022.04.19 |
| 리눅스 콘다 환경에서 GPU 를 사용하는 LightGBM 설치 (0) | 2021.10.28 |
| matplotlib 에서 이미지 저장(savefig) 할 때, 하단이 잘리는 문제 해결법 (0) | 2021.03.31 |
| 하이퍼레저 패브릭 테스트 네트워크에서 peer chaincode invoke 500 error 해결법 (0) | 2021.02.19 |


