파이토치 모델을 돌리다 보면, 모델 크기와 데이터 배치 만큼 그래픽 카드의 메모리를 쓰는 데 그 크기를 정확히 알고 싶을 때가 있다. 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
'노트정리 > 인공지능' 카테고리의 다른 글
파이토치(pytorch)에서 사전학습 모델과 데이터셋의 경로 설정 (0) | 2024.02.16 |
---|---|
케라스(Keras)에서 custom loss function(손실함수) 정의하기 (0) | 2019.04.21 |
파이썬(python)에서 쓸 수 있는 딥러닝(deep learning) 라이브러리 씨아노(theano) 튜토리얼 소개 (0) | 2016.07.20 |
인공 신경망에 관한 설명. 스탠포드 대학 앤드류 응 교수의 sparse autoencoder 정리 노트로 인공신경망 이해하기 (4) | 2016.01.07 |
인공 신경망(artificial neural network)에서 선형분리가능(linearly separable)의 의미 (0) | 2015.11.28 |
딥 러닝(또는 인공신경망) 자바, C++ 무료 라이브러리 (0) | 2015.11.20 |
캐글(kaggle)회장 제레미 하워드(Jeremy Howard)의 컴퓨터가 배울 수 있다는 점이 미래에 가져올 멋지고, 무시무시한 미래. (2) | 2015.08.18 |
퍼셉트론 학습 알고리즘 소스 코드 (0) | 2013.12.20 |