Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 197858e

Browse files
author
Kirill Kolodiazhnyi
committed
Fix GPU setting for systems without GPU
1 parent c217353 commit 197858e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

code2seq.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88

99
if __name__ == '__main__':
1010
physical_devices = tf.config.list_physical_devices('GPU')
11-
tf.config.experimental.set_memory_growth(physical_devices[0], True)
12-
# tf.config.set_visible_devices([], 'GPU')
11+
if len(physical_devices):
12+
tf.config.experimental.set_memory_growth(physical_devices[0], True)
13+
# tf.config.set_visible_devices([], 'GPU')
1314

1415
args = read_args()
1516

0 commit comments

Comments
 (0)