{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "00cc32c8-2ea9-494d-bcb1-2e1cf80bf62d",
   "metadata": {},
   "outputs": [],
   "source": [
    "import tensorflow as tf"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2eb1b249-c610-4185-bdf9-fde4a42a50ad",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Confirm that TensorFlow is using the GPU.\n",
    "print(\"Num GPUs Available: \", len(tf.config.list_physical_devices('GPU')))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d3f0607d-f438-49ad-be8f-54d130151fda",
   "metadata": {},
   "outputs": [],
   "source": [
    "# If GPU is availble and accessible for TF, resulting list should be not empty\n",
    "tf.config.list_physical_devices('GPU')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f1bd27b4-c0e5-4122-b7de-4b789c4efbc7",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Enabling logging device placement to find out which devices TF operations and tensors are assigned to\n",
    "tf.debugging.set_log_device_placement(True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "dc1a0061-3591-4495-a1de-43cb030e69d5",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Create some tensors\n",
    "a = tf.constant([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]])\n",
    "b = tf.constant([[1.0, 2.0], [3.0, 4.0], [5.0, 6.0]])\n",
    "c = tf.matmul(a, b)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4541ef95-78ea-441a-a0bd-2888c3ff0f69",
   "metadata": {},
   "outputs": [],
   "source": [
    "# The cell above should print an indication the MatMul op was executed on GPU:0\n",
    "print(c)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
