File tree Expand file tree Collapse file tree 4 files changed +7
-7
lines changed Expand file tree Collapse file tree 4 files changed +7
-7
lines changed Original file line number Diff line number Diff line change 702
702
},
703
703
"outputs" : [],
704
704
"source" : [
705
- " if tf.test.is_gpu_available( ):\n " ,
705
+ " if tf.config.list_physical_devices('GPU' ):\n " ,
706
706
" with tf.device(\" gpu:0\" ):\n " ,
707
707
" v = tf.Variable(tf.random_normal([1000, 1000]))\n " ,
708
708
" v = None # v no longer takes up GPU memory"
1116
1116
" print(\" CPU: {} secs\" .format(measure(tf.random_normal(shape), steps)))\n " ,
1117
1117
" \n " ,
1118
1118
" # Run on GPU, if available:\n " ,
1119
- " if tf.test.is_gpu_available( ):\n " ,
1119
+ " if tf.config.list_physical_devices('GPU' ):\n " ,
1120
1120
" with tf.device(\" /gpu:0\" ):\n " ,
1121
1121
" print(\" GPU: {} secs\" .format(measure(tf.random_normal(shape), steps)))\n " ,
1122
1122
" else:\n " ,
1141
1141
},
1142
1142
"outputs" : [],
1143
1143
"source" : [
1144
- " if tf.test.is_gpu_available( ):\n " ,
1144
+ " if tf.config.list_physical_devices('GPU' ):\n " ,
1145
1145
" x = tf.random_normal([10, 10])\n " ,
1146
1146
" \n " ,
1147
1147
" x_gpu0 = x.gpu()\n " ,
Original file line number Diff line number Diff line change 236
236
" x = tf.random.uniform([3, 3])\n " ,
237
237
" \n " ,
238
238
" print(\" Is there a GPU available: \" ),\n " ,
239
- " print(tf.test.is_gpu_available( ))\n " ,
239
+ " print(tf.config.list_physical_devices('GPU' ))\n " ,
240
240
" \n " ,
241
241
" print(\" Is the Tensor on GPU #0: \" ),\n " ,
242
242
" print(x.device.endswith('GPU:0'))"
292
292
" time_matmul(x)\n " ,
293
293
" \n " ,
294
294
" # 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 " ,
296
296
" with tf.device(\" GPU:0\" ): # Or GPU:1 for the 2nd GPU, GPU:2 for the 3rd etc.\n " ,
297
297
" x = tf.random_uniform([1000, 1000])\n " ,
298
298
" assert x.device.endswith(\" GPU:0\" )\n " ,
Original file line number Diff line number Diff line change 543
543
},
544
544
"outputs" : [],
545
545
"source" : [
546
- " if tf.test.is_gpu_available( ):\n " ,
546
+ " if tf.config.list_physical_devices('GPU' ):\n " ,
547
547
" rnn = tf.keras.layers.CuDNNGRU\n " ,
548
548
" else:\n " ,
549
549
" import functools\n " ,
Original file line number Diff line number Diff line change 90
90
},
91
91
"outputs" : [],
92
92
"source" : [
93
- " print(tf.test.is_gpu_available( ))"
93
+ " print(tf.config.list_physical_devices('GPU' ))"
94
94
]
95
95
},
96
96
{
You can’t perform that action at this time.
0 commit comments