Last active
December 13, 2017 15:54
-
-
Save fedden/ae3294a98df4730bd3609ce3e962e853 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string = "took {}s to run population size of {} for {} iterations" | |
population_size = 500 | |
iteration_count = 100 | |
solution_size = 64 * 64 | |
# Naive DFO | |
with tf.device("/cpu:0"): | |
start = time.time() | |
naive_dfo(solution_size=solution_size, | |
population_size=population_size, | |
iteration_count=iteration_count) | |
end = time.time() | |
time_taken = end - start | |
print(" naive CPU: " + string.format(time_taken, population_size, iteration_count)) | |
# CPU Vectorised DFO | |
tf.reset_default_graph() | |
with tf.device("/cpu:0"): | |
start = time.time() | |
vectorised_dfo(solution_size=solution_size, | |
population_size=population_size, | |
iteration_count=iteration_count, | |
print_results=False) | |
end = time.time() | |
time_taken = end - start | |
print("vector CPU: " + string.format(time_taken, population_size, iteration_count)) | |
# GPU Vectorised DFO | |
tf.reset_default_graph() | |
with tf.device("/gpu:0"): | |
start = time.time() | |
vectorised_dfo(solution_size=solution_size, | |
population_size=population_size, | |
iteration_count=iteration_count, | |
print_results=False) | |
end = time.time() | |
time_taken = end - start | |
print("vector GPU: " + string.format(time_taken, population_size, iteration_count)) | |
#--------------------------------------- | |
# | |
# Output | |
# | |
#--------------------------------------- | |
# | |
# naive CPU: took 321.1472821235657s to run population size of 500 for 100 iterations | |
# vector CPU: took 5.197434663772583s to run population size of 500 for 100 iterations | |
# vector GPU: took 0.4568960666656494s to run population size of 500 for 100 iterations |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment