Skip to main content

tfu

A small library of many useful utilities for Tensorflow training workflows.

Filtering Visible Devices

In some instances, you may want to filter what devices are visible to Tensorflow. For example, you may have multiple GPUS, but would prefer to use only a single GPU instance when training your model. tf_utils includes some convenience methods to assist with this.

Selecting a single GPU:

visible_devices = tfu.devices.select_gpu(0)

Selecting a subset of GPUs:

visible_devices = tfu.devices.select_gpu([0, 1])

Training Strategies

When a training strategy is needed, in particular OneDeviceStrategy or MirroredDeviceStrategy, tf_utils provides some convenience functions to create these strategies automatically and filter out unused devices. Some examples are provided below.

Use the CPU only via a OneDeviceStrategy:

strategy = tfu.strategy.cpu(0)

Use a single GPU via the OneDeviceStrategy:

strategy = tfu.strategy.gpu(0)

Use multiple GPUs via the MirroredDeviceStrategy:

strategy = tfu.strategy.gpu([0, 1])

Dynamic Memory Growth

Tensorflow has the ability to use dynamic memory allocation, rather than allocating all of the memory on the GPU at once. Enabling dynamic memory allocation allows you to not only monitor memory usage of your models during training, but it also grants you the ability to run multiple models on a single GPU instance. All device selection and strategy functions within tf_utils support this feature via the use_dynamic_memory flag.

Enabling dynamic memory growth via device selection:

visible_devices = tfu.devices.select_gpu(0, use_dynamic_memory=True)

Enabling dynamic memory growth via strategy creation:

strategy = tfu.strategy.gpu(0, use_dynamic_memory=True)

Metadata

Release files for tf-utilities 0.1.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tf-utilities 0.1.9
File Size Uploaded
tf-utilities-0.1.9.tar.gz 10.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tf-utilities 0.1.9
File Interpreter ABI Platform
tf_utilities-0.1.9-py3-none-any.whl Python 3 none any Details

Total release size: 22.2 kB

Release files / tf-utilities-0.1.9.tar.gz

Download URL tf-utilities-0.1.9.tar.gz
Size 10.7 kB
Tags Source
SHA-256 checksum
How to use checksums
6b0efeb1c8fdb79b4c229063724c40ad6e9a8a3ce2e26526aed48816b497d827
BLAKE2b-256 checksum
How to use checksums
d18a0017aea4edc6872e97e0a0f8269c2b2d1fc1ae030fe56820b5f2d5d6df39
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Release files / tf_utilities-0.1.9-py3-none-any.whl

Download URL tf_utilities-0.1.9-py3-none-any.whl
Size 11.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8aa84ea67a9236098dd71cdd7325b86cde5d102da4cc1edeb722e092159f8a3e
BLAKE2b-256 checksum
How to use checksums
bbc0e23d048fc80a8c3b3046b660ae61bbb256fa061cd3fa5057c71f39c5d8ae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Release history Release notifications | RSS feed

This release

0.1.9 This release

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page