Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions list_gpus.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
import os
import sys
from contextlib import redirect_stderr, redirect_stdout

# Try to mute and then load Tensorflow and Keras
# Muting seems to not work lately on Linux in any way
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
stdin = sys.stdin
sys.stdin = open(os.devnull, 'w')
stderr = sys.stderr
sys.stderr = open(os.devnull, 'w')
import tensorflow as tf
tf.logging.set_verbosity(tf.logging.ERROR)
from tensorflow.python.client import device_lib
sys.stdin = stdin
sys.stderr = stderr
# Suppress excessive console output and then load Tensorflow and Keras
# NOTE: This will potentially swallow important or useful information about
# problems with your tensorflow/keras installation, but it works.
# (Tested on Linux)
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' # FATAL
with open(os.devnull, "w") as null:
with redirect_stderr(null), redirect_stdout(null):
import tensorflow as tf
from tensorflow.python.client import device_lib
from tensorflow.python.util import deprecation

deprecation._PRINT_DEPRECATION_WARNINGS = False
tf.compat.v1.logging.set_verbosity(tf.compat.v1.logging.ERROR)

# Get list of all devices
devices = device_lib.list_local_devices()

# Print GPUs only
print('\n\n\nList of found GPUs:')
print('\n\n\nList of available CUDNN GPUs:')
for device in devices:
if device.device_type == 'GPU':
print(device.physical_device_desc)
30 changes: 16 additions & 14 deletions sources/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,26 @@
import numpy as np
from sources import CarlaEnv, STOP, models, ACTIONS_NAMES
from collections import deque
from contextlib import redirect_stderr, redirect_stdout
from threading import Thread
from dataclasses import dataclass
import cv2

# Try to mute and then load Tensorflow and Keras
# Muting seems to not work lately on Linux in any way
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
stdin = sys.stdin
sys.stdin = open(os.devnull, 'w')
stderr = sys.stderr
sys.stderr = open(os.devnull, 'w')
import tensorflow as tf
tf.logging.set_verbosity(tf.logging.ERROR)
import keras.backend.tensorflow_backend as backend
from keras.optimizers import Adam
from keras.models import load_model, Model
sys.stdin = stdin
sys.stderr = stderr
# Suppress excessive console output and then load Tensorflow and Keras
# NOTE: This will potentially swallow important or useful information about
# problems with your tensorflow/keras installation, but it works.
# (Tested on Linux)
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' # FATAL
with open(os.devnull, "w") as null:
with redirect_stderr(null), redirect_stdout(null):
import tensorflow as tf
import keras.backend.tensorflow_backend as backend
from tensorflow.python.util import deprecation
from keras.optimizers import Adam
from keras.models import load_model, Model

deprecation._PRINT_DEPRECATION_WARNINGS = False
tf.compat.v1.logging.set_verbosity(tf.compat.v1.logging.ERROR)


# Agent class
Expand Down
32 changes: 17 additions & 15 deletions sources/models.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
import os
import sys
import settings

# Try to mute and then load Tensorflow and Keras
# Muting seems to not work lately on Linux in any way
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
stdin = sys.stdin
sys.stdin = open(os.devnull, 'w')
stderr = sys.stderr
sys.stderr = open(os.devnull, 'w')
import tensorflow as tf
tf.logging.set_verbosity(tf.logging.ERROR)
from keras.applications.xception import Xception
from keras.models import Sequential, Model
from keras.layers import Dense, GlobalAveragePooling2D, Input, Concatenate, Conv2D, AveragePooling2D, Activation, Flatten
sys.stdin = stdin
sys.stderr = stderr
from contextlib import redirect_stderr, redirect_stdout

# Suppress excessive console output and then load Tensorflow and Keras
# NOTE: This will potentially swallow important or useful information about
# problems with your tensorflow/keras installation, but it works.
# (Tested on Linux)
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' # FATAL
with open(os.devnull, "w") as null:
with redirect_stderr(null), redirect_stdout(null):
import tensorflow as tf
from tensorflow.python.util import deprecation
from keras.applications.xception import Xception
from keras.models import Sequential, Model
from keras.layers import Dense, GlobalAveragePooling2D, Input, Concatenate, Conv2D, AveragePooling2D, Activation, Flatten

deprecation._PRINT_DEPRECATION_WARNINGS = False
tf.compat.v1.logging.set_verbosity(tf.compat.v1.logging.ERROR)

MODEL_NAME_PREFIX = ''

Expand Down
26 changes: 14 additions & 12 deletions sources/tensorboard.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
import os
import sys
from contextlib import redirect_stderr, redirect_stdout

# Try to mute and then load TensorFlow and Keras
# Muting seems to not work lately on Linux in any way
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
stdin = sys.stdin
sys.stdin = open(os.devnull, 'w')
stderr = sys.stderr
sys.stderr = open(os.devnull, 'w')
import tensorflow as tf
tf.logging.set_verbosity(tf.logging.ERROR)
from keras.callbacks import Callback
sys.stdin = stdin
sys.stderr = stderr
# Suppress excessive console output and then load Tensorflow and Keras
# NOTE: This will potentially swallow important or useful information about
# problems with your tensorflow/keras installation, but it works.
# (Tested on Linux)
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' # FATAL
with open(os.devnull, "w") as null:
with redirect_stderr(null), redirect_stdout(null):
import tensorflow as tf
from tensorflow.python.util import deprecation
from keras.callbacks import Callback

deprecation._PRINT_DEPRECATION_WARNINGS = False
tf.compat.v1.logging.set_verbosity(tf.compat.v1.logging.ERROR)

# Own Tensorboard class giving ability to use single writer across multiple .fit() calls
# Allows us also to easily log additional data
Expand Down
26 changes: 14 additions & 12 deletions sources/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import settings
from sources import ARTDQNAgent, TensorBoard, STOP, ACTIONS, ACTIONS_NAMES
from collections import deque
from contextlib import redirect_stderr, redirect_stdout
import time
import random
import numpy as np
Expand All @@ -11,18 +12,19 @@
from dataclasses import dataclass
from threading import Thread

# Try to mute and then load Tensorflow
# Muting seems to not work lately on Linux in any way
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
stdin = sys.stdin
sys.stdin = open(os.devnull, 'w')
stderr = sys.stderr
sys.stderr = open(os.devnull, 'w')
import tensorflow as tf
tf.logging.set_verbosity(tf.logging.ERROR)
import keras.backend.tensorflow_backend as backend
sys.stdin = stdin
sys.stderr = stderr
# Suppress excessive console output and then load Tensorflow and Keras
# NOTE: This will potentially swallow important or useful information about
# problems with your tensorflow/keras installation, but it works.
# (Tested on Linux)
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' # FATAL
with open(os.devnull, "w") as null:
with redirect_stderr(null), redirect_stdout(null):
import tensorflow as tf
import keras.backend.tensorflow_backend as backend
from tensorflow.python.util import deprecation

deprecation._PRINT_DEPRECATION_WARNINGS = False
tf.compat.v1.logging.set_verbosity(tf.compat.v1.logging.ERROR)


# Trainer class
Expand Down