aboutsummarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Peschel2023-07-08 22:34:48 -0400
committerMark Peschel2023-07-08 22:36:02 -0400
commitd529c0ede8354b1c3751d9a324d3d6ffcd6db5da (patch)
treee63026638947c407da888f3bc1e83f6a797dec7a
parentd2a73892d9dafe76e86b9aa5a6b93e400f26ee6c (diff)
downloadaur-d529c0ede8354b1c3751d9a324d3d6ffcd6db5da.tar.gz
Make test.py slightly less non-deterministic.
-rw-r--r--next.txt3
-rw-r--r--test.py20
2 files changed, 13 insertions, 10 deletions
diff --git a/next.txt b/next.txt
index 1d2675b9c176..6a4953236f32 100644
--- a/next.txt
+++ b/next.txt
@@ -1,6 +1,3 @@
-it occurs to me, about the opt things, we can just do march=native.
- build with match=x86_64 -O2 and march=native -O2 and benchmark the results.
- remove the optimization notes from github readme
clean chroot build
party. I am so glad this is over.
diff --git a/test.py b/test.py
index 3e92a136fb65..58aeea12fe24 100644
--- a/test.py
+++ b/test.py
@@ -33,12 +33,13 @@ def is_gfx1031():
# if len(architectures) != 1, we ignore it since idk what to do then.
return {'gfx1031'} == architectures
-# You can use environment variables if your GPU works but is not officially supported.
-# For example, I have a Radeon RX 6750 XT, which is detected as the unsupported gfx1031 arch,
-# but the supported gfx1030 architecture works just dandy.
-# This test, when run on such a machine, will override the architecture.
-if is_gfx1031():
- os.environ['HSA_OVERRIDE_GFX_VERSION'] = '10.3.0'
+def set_gfx_override():
+ # You can use environment variables if your GPU works but is not officially supported.
+ # For example, I have a Radeon RX 6750 XT, which is detected as the unsupported gfx1031 arch,
+ # but the supported gfx1030 architecture works just dandy.
+ # This test, when run on such a machine, will override the architecture.
+ if is_gfx1031():
+ os.environ['HSA_OVERRIDE_GFX_VERSION'] = '10.3.0'
def uninstall(package_name):
subprocess.run(['sudo', 'pacman', '-Rdd', package_name])
@@ -122,12 +123,16 @@ def test_tf_short():
tf.autograph.to_graph(temp)
def test_tf_mnist():
+ seed = 531
import tensorflow as tf
+ tf.random.set_seed(seed)
+ tf.keras.utils.set_random_seed(531)
+
# Taken from tensorflow.org/tutorials/quickstart/beginner.
mnist = tf.keras.datasets.mnist
(x_train, y_train), (x_test, y_test) = mnist.load_data()
x_train, x_test = x_train / 255., x_test / 255.
-
+
import time
start = time.time()
@@ -155,6 +160,7 @@ def test_tf_mnist():
print('Your mileage may vary.')
def check_packages(tensorflow_path, python_tensorflow_path):
+ set_gfx_override()
uninstall_all()
install(tensorflow_path)