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]

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

export TF_FORCE_GPU_ALLOW_GROWTH=true

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

 

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...

34 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

  9. Otho Flatley 말해보세요:

    I just could not leave your web site before suggesting that I really enjoyed the standard information a person supply to your visitors Is gonna be again steadily in order to check up on new posts

  10. bestiptv-smarters 말해보세요:

    I loved as much as you will receive carried out right here The sketch is attractive your authored material stylish nonetheless you command get got an impatience over that you wish be delivering the following unwell unquestionably come more formerly again since exactly the same nearly a lot often inside case you shield this hike

  11. streameastweb 말해보세요:

    I have read some excellent stuff here Definitely value bookmarking for revisiting I wonder how much effort you put to make the sort of excellent informative website

  12. streameastweb 말해보세요:

    Hey there You have done a fantastic job I will certainly digg it and personally recommend to my friends Im confident theyll be benefited from this site

  13. youtube to mp3 말해보세요:

    Your blog has become an indispensable resource for me. I’m always excited to see what new insights you have to offer. Thank you for consistently delivering top-notch content!

  14. Disposable Temporary Address 말해보세요:

    I love how this blog gives a voice to important social and political issues It’s important to use your platform for good, and you do that flawlessly

  15. floatswitchs 말해보세요:

    Wonderful beat I wish to apprentice while you amend your web site how could i subscribe for a blog web site The account aided me a acceptable deal I had been a little bit acquainted of this your broadcast provided bright clear idea

  16. bestiptvireland 말해보세요:

    Wow wonderful blog layout How long have you been blogging for you make blogging look easy The overall look of your site is great as well as the content

  17. blogmedia 말해보세요:

    Hi i think that i saw you visited my web site thus i came to Return the favore Im attempting to find things to enhance my siteI suppose its ok to use a few of your ideas

  18. theorangedip 말해보세요:

    Your passion for your subject matter shines through in every post. It’s clear that you genuinely care about sharing knowledge and making a positive impact on your readers. Kudos to you!

  19. theorangedip 말해보세요:

    Your blog is a true hidden gem on the internet. Your thoughtful analysis and engaging writing style set you apart from the crowd. Keep up the excellent work!

  20. airhostess 말해보세요:

    helloI like your writing very so much proportion we keep up a correspondence extra approximately your post on AOL I need an expert in this space to unravel my problem May be that is you Taking a look forward to see you

  21. mycroxyproxy 말해보세요:

    I have been browsing online more than three hours today yet I never found any interesting article like yours It is pretty worth enough for me In my view if all website owners and bloggers made good content as you did the internet will be a lot more useful than ever before

  22. Regras do bacará 말해보세요:

    Simplesmente desejo dizer que seu artigo é tão surpreendente A clareza em sua postagem é simplesmente excelente e posso presumir que você é um especialista neste assunto. Com sua permissão, deixe-me pegar seu feed para me manter atualizado com as próximas postagens. Um milhão de agradecimentos e por favor continue o trabalho gratificante

  23. bizzlyn 말해보세요:

    helloI really like your writing so a lot share we keep up a correspondence extra approximately your post on AOL I need an expert in this house to unravel my problem May be that is you Taking a look ahead to see you

  24. Kalorifer Sobası 말해보세요:

    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

  25. minihints 말해보세요:

    Eu acredito que todas as idéias que você apresentou para sua postagem são realmente convincentes e certamente funcionarão. No entanto, as postagens são muito curtas para novatos. Você pode, por favor, alongá-las um pouco nas próximas vezes. Obrigado pela postagem

  26. top888casino 말해보세요:

    I do not even know how I ended up here but I thought this post was great I do not know who you are but certainly youre going to a famous blogger if you are not already Cheers

  27. igameplay 말해보세요:

    Simply wish to say your article is as amazing The clearness in your post is just nice and i could assume youre an expert on this subject Well with your permission let me to grab your feed to keep updated with forthcoming post Thanks a million and please carry on the gratifying work

  28. bigduffers 말해보세요:

    Just wish to say your article is as surprising The clearness in your post is just cool and i could assume youre an expert on this subject Fine with your permission allow me to grab your RSS feed to keep updated with forthcoming post Thanks a million and please keep up the enjoyable work

  29. streameast 말해보세요:

    Thank you for the good writeup It in fact was a amusement account it Look advanced to far added agreeable from you However how could we communicate

  30. ibomma 말해보세요:

    obviously like your website but you need to test the spelling on quite a few of your posts Several of them are rife with spelling problems and I to find it very troublesome to inform the reality on the other hand Ill certainly come back again

  31. exploreuaeonline 말해보세요:

    Magnificent beat I would like to apprentice while you amend your site how can i subscribe for a blog web site The account helped me a acceptable deal I had been a little bit acquainted of this your broadcast offered bright clear idea

  32. winwavelotto 말해보세요:

    Your blog has become an indispensable resource for me. I’m always excited to see what new insights you have to offer. Thank you for consistently delivering top-notch content!

  33. iptvuk 말해보세요:

    Ive read several just right stuff here Certainly price bookmarking for revisiting I wonder how a lot effort you place to create this kind of great informative website

  34. petloverhaven 말해보세요:

    Your blog is a treasure trove of valuable insights and thought-provoking commentary. Your dedication to your craft is evident in every word you write. Keep up the fantastic work!

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