Skip to content
Snippets Groups Projects
Commit 48454ced authored by huongdm1896's avatar huongdm1896
Browse files

update client code

parent a8a0eccf
No related merge requests found
......@@ -9,18 +9,24 @@ import numpy as np
import sys
import random
# list up
physical_devices = tf.config.list_physical_devices('GPU')
if physical_devices:
if len(physical_devices) > 0:
# Only use 1st GPU
tf.config.set_visible_devices(physical_devices[0], 'GPU')
# Avoid over mem
tf.config.experimental.set_memory_growth(physical_devices[0], True)
print("GPU detected and memory growth enabled.")
print("GPU detected and memory growth enabled. Using GPU:", physical_devices[0].name)
else:
print("No GPU detected, using CPU.")
# Set random seed for reproducibility
def set_random_seed(seed):
random.seed(seed) # Python random module seed
np.random.seed(seed) # Numpy random seed
tf.random.set_seed(seed) # TensorFlow random seed
random.seed(seed)
np.random.seed(seed)
tf.random.set_seed(seed)
# Set a specific seed value
set_random_seed(42)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment