Getting started with TensorFlow
Find information for getting started with TensorFlow.
The following TensorFlow related conda packages are included with WML CE:
Name | Description | Installed with powerai | Installed with tensorflow-gpu | Installed with powerai-cpu | Installed with tensorflow |
---|---|---|---|---|---|
tensorflow | TensorFlow Meta package | ✓ | ✓ | ||
tensorflow-gpu | TensorFlow GPU Meta package | ✓ | ✓ | ||
tensorflow-base | Contains the core TensorFlow Logic | ✓ | ✓ | ✓ | ✓ |
tensorflow-estimator | Required TensorFlow Estimator package | ✓ | ✓ | ✓ | ✓ |
tensorboard | Visualization Dashboard for TensorFlow | ✓ | ✓ | ✓ | ✓ |
tensorflow-large-model-support | TensorFlow Large Model Support | ✓ | |||
tensorflow-probability | Optional TensorFlow Probability package | ✓ | ✓ | ||
tf_cnn_benchmarks | Optional TensorFlow CNN benchmark package | ✓ | |||
ddl-tensorflow | Distributed Deep Learning custom operator for TensorFlow | ✓ | |||
bazel | Fast, scalable, multi-language and extensible build system | ||||
tensorflow-serving-api | Serving system for machine learning models | ✓ | ✓ | ||
tensorflow-serving | Serving system for machine learning models | ||||
tensorrt | C++ library running pre-trained networks quickly and efficiently | ✓ | ✓ |
You can install packages with conda install <package name>
.
The TensorFlow home page has various information, including Tutorials, How to documents, and a Getting Started guide.
Additional tutorials and examples are available from the community, for example:
tensorflow and tensorflow-gpu conda packages
- To install TensorFlow built for CPU support run the following command. Only
use the
strict-channel-priority
setting if you are installing into an x86 environment:
This command installs the TensorFlow package, with no packages for GPU support.conda install --strict-channel-priority tensorflow
Note: In the prior release, thetensorflow
conda package installed the TensorFlow package built for GPU support as that was the only support available in that release. - To install TensorFlow built for GPU support run the following command. Only use the
strict-channel-priority
setting if you are installing into an x86 environment:
This command installs TensorFlow along with the CUDA, cuDNN, and NCCL conda packages used with the GPUs.conda install --strict-channel-priority tensorflow-gpu
TensorFlow Large Model Support (TFLMS)
Large Model Support provides an approach to training large models and batch sizes that cannot fit in GPU memory. It does this by use of a graph editing library that takes the user model's computational graph and automatically adds swap-in and swap-out nodes for transferring tensors from GPU memory to system memory and vice versa during training.
For more information about TensorFlow LMS, see Getting started with TensorFlow large model support.
Distributed Deep Learning (DDL) custom operator for TensorFlow
The DDL custom operator uses IBM Spectrum™ MPI and NCCL to provide high-speed communications for distributed TensorFlow.
The DDL custom operator can be found in the ddl-tensorflow package. For more information about DDL and about the TensorFlow operator, see Integration with deep learning frameworks
TensorFlow with NVIDIA TensorRT (TF-TRT)
NVIDIA TensorRT is a plaform for high-performance deep learning inference. Trained models can be optimized with TensorRT; this is done by replacing TensorRT-compatible subgraphs with a single TRTEngineOp that is used to build a TensorRT engine. TensorRT can also calibrate for lower precision (FP16 and INT8) with a minimal loss of accuracy. After a model is optimized with TensorRT, the TensorFlow workflow is still used for inferencing, including TensorFlow-Serving.
A saved model can be optimized for TensorRT with the following python snippet:
from tensorflow.python.compiler.tensorrt import trt_convert as trt
converter = trt.TrtGraphConverter(
input_saved_model_dir=input_saved_model_dir)
converter.convert()
converter.save(output_saved_model_dir)
TensorRT is enabled in the tensorflow-gpu
and
tensorflow-serving
packages.
For additional information on TF-TRT, see the official Nvidia docs.
Additional TensorFlow features
The powerai TensorFlow packages include TensorBoard. For more information, see Getting started with TensorBoard.
The TensorFlow package includes support for additional features:
- Hadoop Distributed File System (HDFS) support
- Amazon Web Services (AWS) S3 support
- Kafka support
- Google Compute Platform (GCP) support
- IGNITE dataset support
- NVIDIA Collective Communications Library (NCCL) 2
- CUDA compute capabilities: 3.7, 6.0, 7.0 for NVIDIA Tesla K80, P100, and V100 GPUs
- CUDA 10.1 support
- Automatic Mixed Precision (AMP) support
TensorFlow CNN benchmarks
WML CE includes the tf_cnn_benchmarks package that contains a version of the TensorFlow CNN benchmark. This package contains implementations of several popular convolutional models, and is designed to be as fast as possible. The code supports both running on a single machine or running in distributed mode across multiple hosts. This version of tf_cnn_benchmarks is matched to the version of TensorFlow that is included in this release and has additional options to enable DDL and TensorFlow Large Model Support.
TensorFlow 2.0 Technology Preview
WML CE includes a technology preview of TensorFlow 2.0 compiled with GPU support. The focus of TensorFlow 2.0 is simplicity and ease of use. TensorFlow 2.0 leverages Keras as the high-level API for TensorFlow. The TensorFlow 2.0 home page contains examples written for 2.0 and information about migrating 1.X code to 2.0 along with getting started guides for beginners and experts.
The package name is tensorflow2-gpu
and it must be installed in a separate conda
environment than TensorFlow 1.x.
The following examples are installation commands:
conda create --name tensorflow2-tech-preview python=3.6 tensorflow2-gpu
conda activate tensorflow2-tech-preview
TensorFlow 2.0 has been tested with TensorBoard and TensorFlow Estimator. As the TensorFlow Estimator conda package is dependent on the TensorFlow conda package, it must be installed with the --no-deps flag to avoid TensorFlow 1.X getting installed when estimator is installed. To install TensorFlow Estimator run:
conda install tensorflow-estimator --no-deps
TensorFlow 2.0 is compiled with TensorRT support, however the examples in the tensorrt-samples conda package are not compatible with TensorFlow 2.0. TensorRT has not been tested with TensorFlow 2.0
TensorFlow 2.0 has not been tested with TensorFlow Large Model Support, TensorFlow Serving, TensorFlow Probability or tf_cnn_benchmarks at this time.
Tensorflow Keras-team Keras
TensorFlow includes an implementation of the Keras API (in the tf.keras
module)
with TensorFlow-specific enhancements. These include support for eager execution for intuitive
debugging and fast iteration, support for the TensorFlow SavedModel model exchange format, and
integrated support for distributed training. Keras-team Keras should not be used with TensorFlow
2.0, to use keras:
import tensorflow.keras as keras
Automatic mixed precision support
TensorFlow 1.14 includes a feature called Automatic Mixed Precision (AMP) that automatically takes advantage of lower precision hardware such at the Tensor Cores included in NVIDIA's V100 GPUs. AMP can speed up training in certain models. To enable AMP, add the following lines of Python to the model code:
config = tf.ConfigProto()
config.graph_options.rewrite_options.auto_mixed_precision=1