soufyane commited on
Commit
0db2352
·
verified ·
1 Parent(s): 41b70a5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -0
app.py CHANGED
@@ -3,6 +3,16 @@ import spaces
3
  import torch
4
  import keras
5
  import keras_nlp
 
 
 
 
 
 
 
 
 
 
6
 
7
  keras.utils.set_random_seed(42)
8
 
 
3
  import torch
4
  import keras
5
  import keras_nlp
6
+ import tensorflow as tf
7
+
8
+ gpus = tf.config.experimental.list_physical_devices('GPU')
9
+ if gpus:
10
+ try:
11
+ # Restrict TensorFlow to only allocate memory as needed
12
+ for gpu in gpus:
13
+ tf.config.experimental.set_memory_growth(gpu, True)
14
+ except RuntimeError as e:
15
+ print(e)
16
 
17
  keras.utils.set_random_seed(42)
18