TensorFlow를 공용 GPU에서 사용 할 때 메모리 절약 방법

TensorFlow를 공용 GPU에서 사용 할 때 메모리 절약 방법

절대적 메모리 uppeor bound 설정

tf.Session생성 할 때 GPU memory allocation을 지정할 수 있다. 이것을 위해서 tf.GPUOptions config부분을 아래와 같이 활용 한다.

# Assume that you have 12GB of GPU memory and want to allocate ~4GB:
gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=0.333)

sess = tf.Session(config=tf.ConfigProto(gpu_options=gpu_options))

위와 같이 per_process_gpu_memory_fraction=0.333으로 설정된 것은 strict하게 upper bound on the amount of GPU memory를 설정한 것이다.

탄력적으로 GPU memory 사용 방법

아래와 같이 allow_growth True로 설정하면 필요에 따라 탄력적으로 memory를 사용하게 된다.

config = tf.ConfigProto()
config.gpu_options.allow_growth = True
session = tf.Session(config=config, ...)

출처: https://goodtogreate.tistory.com/entry/TensorFlow를-공용-GPU에서-사용-할-때-메모리-절약-방법 [GOOD to GREAT]

시스템 환경 설정으로 적용하는 방법


해도 동일한 효과를 가질 수 있음.


Tensorflow 2.x 적용하는 방법


import tensorflow as tf

config = tf.compat.v1.ConfigProto()
config.gpu_options.allow_growth = True
session = tf.compat.v1.Session(config=config)


슈퍼컴퓨팅 전문 기업 클루닉스/ 상무(기술이사)/ 정보시스템감리사/ 시스존 블로그 운영자

You may also like...

8 Responses

  1. Creați un cont personal 말해보세요:

    Thank you for your sharing. I am worried that I lack creative ideas. It is your article that makes me full of hope. Thank you. But, I have a question, can you help me?

  2. mtmetlife 말해보세요:

    Hello, my family member. I just wanted to express how great this piece is—it’s well written and has almost all the important information. I want to see more posts like this one.

  3. Puravive 말해보세요:

    Thanks I have just been looking for information about this subject for a long time and yours is the best Ive discovered till now However what in regards to the bottom line Are you certain in regards to the supply

  4. temp mail 말해보세요:

    Hello, I would want to keep in contact with you regarding your writings on AOL because I genuinely appreciate your writing. I’m excited to see you soon. I need a specialist in this area to address my issue. Perhaps you are that somebody.

  5. bestiptvireland 말해보세요:

    hiI like your writing so much share we be in contact more approximately your article on AOL I need a specialist in this area to resolve my problem Maybe that is you Looking ahead to see you

  6. tempmail 말해보세요:

    I would claim that a true assistance is involved in producing excellent posts. It’s my first time visiting your website, and I’m amazed at how much research you did to produce such a fantastic article. Fantastic work!

  7. tempmail 말해보세요:

    Hi, member of my family. I just wanted to say how fantastic this article is—it’s nicely written and has nearly all of the important details. I hope to see more content similar to this one.

  8. pilllow 말해보세요:

    Fantastic site A lot of helpful info here Im sending it to some buddies ans additionally sharing in delicious And naturally thanks on your sweat

페이스북/트위트/구글 계정으로 댓글 가능합니다.