Skip to main content

Simplication of GPU allocation for Tensorflow2

Project description

tf_alloc

Simpliying GPU allocation for Tensorflow

⭐️ Why tf_alloc? Problems?

  • Compare to pytorch, tensorflow allocate all GPU memory to single training.
  • However, it is too much waste because, some training does not use whole GPU memory.
  • To solve this problem, TF engineers use two methods.
  1. Limit to use only single GPU
  2. Limit the use of only a certain percentage of GPUs.
  • However, these methods require complex code and memory management.

⭐️ Why tf_alloc? How to solve?

tf_alloc simplfy and automate GPU allocation using two methods.

⭐️ How to allocate?

  • Before using tf_alloc, you have to install tensorflow fits for your environment.
  • This library does not install specific tensorflow version.
# On the top of the code
from tf_alloc import allocate as talloc
talloc(gpu=1, percentage=0.5)

import tensorflow as tf
""" your code"""

It is only code for allocating GPU in certain percentage.

Parameters:

  • gpu = which gpu you want to use (if you have two gpu than [0, 1] is possible)
  • percentage = the percentage of memory usage on single gpu. 1.0 for maximum use.

⭐️ Additional Function.

GET GPU Objects

gpu_objs = get_gpu_objects()
  • To use this code, you can get gpu objects that contains gpu information.
  • You can set GPU backend by using this function.

GET CURRENT STATE

Defualt
current(
    gpu_id = False, 
    total_memory=False, 
    used = False, 
    free = False, 
    percentage_of_use = False,
    percentage_of_free = False,
)
  • You can use this functions to see current GPU state and possible maximum allocation percentage.
  • Without any parameters, than it only visualize possible maximum allocation percentage.
  • It is cmd line visualizer. It doesn't return values.

Parameters

  • gpu_id = visualize the gpu id number
  • total_memory = visualize the total memory of GPU
  • used = visualize the used memory of GPU
  • free = visualize the free memory of GPU
  • percentage_of_used = visualize the percentage of used memory of GPU
  • percentage_of_free = visualize the percentage of free memory of GPU

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tf_alloc-0.0.3.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

tf_alloc-0.0.3-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file tf_alloc-0.0.3.tar.gz.

File metadata

  • Download URL: tf_alloc-0.0.3.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.1 pkginfo/1.8.2 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for tf_alloc-0.0.3.tar.gz
Algorithm Hash digest
SHA256 23de50f38934bcfc77cc809f1e6fd3abc48ca49c2e37d88755b0c8487f8bf097
MD5 2e395262a68477d67f0c50fb5888c28d
BLAKE2b-256 7f3dcef94db03038214598eb10b687f9ba4e5f17207d4d6709135d3c8515ead9

See more details on using hashes here.

File details

Details for the file tf_alloc-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: tf_alloc-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.1 pkginfo/1.8.2 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for tf_alloc-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 30d121647ea9d66f946d4447d5d4ff26b6d6867941ce50f48216163e6853d809
MD5 bdc95b496e16666432c76aba44afb237
BLAKE2b-256 511ee3fafbbb7ab35d331c1f724cc6c2dbc4d842d712da8b35310aff863c5dbf

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page