Skip to content

Commit d6e8dfe

Browse files
Removes a deprecation warning. Tested the updated .ipynb file.
PiperOrigin-RevId: 404370475
1 parent 356b4db commit d6e8dfe

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

site/en/r1/guide/eager.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,7 @@
702702
},
703703
"outputs": [],
704704
"source": [
705-
"if tf.test.is_gpu_available():\n",
705+
"if tf.config.list_physical_devices('GPU'):\n",
706706
" with tf.device(\"gpu:0\"):\n",
707707
" v = tf.Variable(tf.random_normal([1000, 1000]))\n",
708708
" v = None # v no longer takes up GPU memory"
@@ -1116,7 +1116,7 @@
11161116
" print(\"CPU: {} secs\".format(measure(tf.random_normal(shape), steps)))\n",
11171117
"\n",
11181118
"# Run on GPU, if available:\n",
1119-
"if tf.test.is_gpu_available():\n",
1119+
"if tf.config.list_physical_devices('GPU'):\n",
11201120
" with tf.device(\"/gpu:0\"):\n",
11211121
" print(\"GPU: {} secs\".format(measure(tf.random_normal(shape), steps)))\n",
11221122
"else:\n",
@@ -1141,7 +1141,7 @@
11411141
},
11421142
"outputs": [],
11431143
"source": [
1144-
"if tf.test.is_gpu_available():\n",
1144+
"if tf.config.list_physical_devices('GPU'):\n",
11451145
" x = tf.random_normal([10, 10])\n",
11461146
"\n",
11471147
" x_gpu0 = x.gpu()\n",

site/en/r1/tutorials/eager/eager_basics.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@
236236
"x = tf.random.uniform([3, 3])\n",
237237
"\n",
238238
"print(\"Is there a GPU available: \"),\n",
239-
"print(tf.test.is_gpu_available())\n",
239+
"print(tf.config.list_physical_devices('GPU'))\n",
240240
"\n",
241241
"print(\"Is the Tensor on GPU #0: \"),\n",
242242
"print(x.device.endswith('GPU:0'))"
@@ -292,7 +292,7 @@
292292
" time_matmul(x)\n",
293293
"\n",
294294
"# Force execution on GPU #0 if available\n",
295-
"if tf.test.is_gpu_available():\n",
295+
"if tf.config.list_physical_devices('GPU'):\n",
296296
" with tf.device(\"GPU:0\"): # Or GPU:1 for the 2nd GPU, GPU:2 for the 3rd etc.\n",
297297
" x = tf.random_uniform([1000, 1000])\n",
298298
" assert x.device.endswith(\"GPU:0\")\n",

site/en/r1/tutorials/sequences/text_generation.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@
543543
},
544544
"outputs": [],
545545
"source": [
546-
"if tf.test.is_gpu_available():\n",
546+
"if tf.config.list_physical_devices('GPU'):\n",
547547
" rnn = tf.keras.layers.CuDNNGRU\n",
548548
"else:\n",
549549
" import functools\n",

site/en/tutorials/customization/custom_layers.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090
},
9191
"outputs": [],
9292
"source": [
93-
"print(tf.test.is_gpu_available())"
93+
"print(tf.config.list_physical_devices('GPU'))"
9494
]
9595
},
9696
{

0 commit comments

Comments
 (0)