Date: Thu, 28 Mar 2024 09:35:05 -0500 (CDT) Message-ID: <479288342.1130.1711636505832@wiki.ncsa.illinois.edu> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_1129_445013714.1711636505831" ------=_Part_1129_445013714.1711636505831 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
This guide will show our users how= to use the TensorFlow Profiler to profile the execution of your TensorFlow= code.
Copy and paste the following code into tf-profile.py.= p>
from date= time import datetime import os import tensorflow from tensorflow.keras.datasets import mnist from tensorflow import keras from tensorflow.keras import layers (train_images, train_labels), (test_images, test_labels) =3D mnist.load_dat= a() model =3D keras.Sequential([ layers.Dense(512, activation=3D"relu"), layers.Dense(10, activation=3D"softmax") ]) model.compile(optimizer=3D"rmsprop", loss=3D"sparse_categorical_crossentropy", metrics=3D["accuracy"]) train_images =3D train_images.reshape((60000, 28 * 28)) train_images =3D train_images.astype("float32") / 255 test_images =3D test_images.reshape((10000, 28 * 28)) test_images =3D test_images.astype("float32") / 255 # Create a TensorBoard callback logs =3D "logs/" + datetime.now().strftime("%Y%m%d-%H%M%S") tboard_callback =3D tensorflow.keras.callbacks.TensorBoard(log_dir =3D logs= , histogram_freq =3D 1, profile_batch =3D '10,20') model.fit(train_images,=20 train_labels,=20 epochs=3D10,=20 batch_size=3D128,=20 callbacks =3D [tboard_callback])
The tensorflow.keras.callbacks.TensorBoard command=
will create a tensorboard callback and profile_ba=
tch will pick batch number 10 to batch number
Run the code with command
python = tf-profile.py
Compress the logs fold= er
tar -zc= vf ./logs.tar.gz ./logs
Download the tarball file with = sftp and/or hal-ondemand.
Decompress the tarball file
tar -zx= vf ./logs.tar.gz
Install the tensorboard profile plugin = in your python environment.
pip ins= tall tensorboard_plugin_profile
Launch the tensorboard with profiler in= stalled.
tensorb= oard --logdir ./logs
Coming soon...