#create ML model model = tf.keras.Sequential([ tf.keras.layers.Flatten(input_shape=(28, 28)), tf.keras.layers.Dense(128, activation='relu'), tf.keras.layers.Dense(10) ])
#compile ML model model.compile(optimizer='adam', loss=tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True), metrics=['accuracy'])
#train ML model model.fit(train_images, train_labels, epochs=10)
#evaluate ML model on test set test_loss, test_acc = model.evaluate(test_images, test_labels, verbose=2)
#setup stop time t1 = time.time() total_time = t1-t0
#print results print('\n') print(f'Training set contained {train_set_count} images') print(f'Testing set contained {test_set_count} images') print(f'Model achieved {test_acc:.2f} testing accuracy') print(f'Training and testing took {total_time:.2f} seconds')
RTX 3090 的试验配置
System: Linux
CPU: Intel® Core™ V4-2650
RAM: 128GB
Storage: 1TB SSD
tensorflow环境配置:
docker container run -ti tensorflow/tensorflow
1 2 3 4 5 6 7 8
>>> print(f'Training set contained {train_set_count} images') Training set contained 60000 images >>> print(f'Testing set contained {test_set_count} images') Testing set contained 10000 images >>> print(f'Model achieved {test_acc:.2f} testing accuracy') Model achieved 0.83 testing accuracy >>> print(f'Training and testing took {total_time:.2f} seconds') Training and testing took 40.90 seconds
训练10个epoch,包括test,最终耗时为 40.90s
M1的试验配置
System: macOS Big Sur
Storage: 512GB SSD
Unified Memory: 16GB
M1芯片包含8个CPU核,8个GPU核以及16个神经网络引擎核心。
1 2 3 4 5 6 7 8
>>> print(f'Training set contained {train_set_count} images') Training set contained 60000 images >>> print(f'Testing set contained {test_set_count} images') Testing set contained 10000 images >>> print(f'Model achieved {test_acc:.2f} testing accuracy') Model achieved 0.20 testing accuracy >>> print(f'Training and testing took {total_time:.2f} seconds') Training and testing took 6.85 seconds
"""Created by: Vlachas Pantelis, CSE-lab, ETH Zurich """ #!/usr/bin/env python
import sys from Config.global_conf import global_params sys.path.insert(0, global_params.global_utils_path) from plotting_utils import * from global_utils import *
import argparse
defgetModel(params): sys.path.insert(0, global_params.py_models_path.format(params["model_name"])) if params["model_name"] == "esn": import esn as model return model.esn(params) elif params["model_name"] == "esn_parallel": import esn_parallel as model return model.esn_parallel(params) elif params["model_name"] == "rnn_statefull": import rnn_statefull as model return model.rnn_statefull(params) elif params["model_name"] == "rnn_statefull_parallel": import rnn_statefull_parallel as model return model.rnn_statefull_parallel(params) elif params["model_name"] == "mlp": import mlp as model return model.mlp(params) else: raise ValueError("model not found.") defrunModel(params_dict): if params_dict["mode"] in ["train", "all"]: trainModel(params_dict) if params_dict["mode"] in ["test", "all"]: testModel(params_dict) return0
deftrainModel(params_dict): model = getModel(params_dict) model.train() model.delete() del model return0
deftestModel(params_dict): model = getModel(params_dict) model.testing() model.delete() del model return0
defdefineParser(): parser = argparse.ArgumentParser() subparsers = parser.add_subparsers(help='Selection of the model.', dest='model_name')
@torch.jit.script def foo(): x = torch.ones((1024 * 12, 1024 * 12), dtype=torch.float32) y = torch.ones((1024 * 12, 1024 * 12), dtype=torch.float32) z = x + y return z
if __name__ == '__main__': z0 = None for _ in tqdm(range(10000000000)): zz = foo() if z0 is None: z0 = zz else: z0 += zz
# 在此之前,先手动编译pybind11 git clone https://github.com/pybind/pybind11 mkdir build cd build cmake .. make check -j 4 (make and check, not necessary) sudo make install
60;
RuntimeError: CUDA out of memory. Tried to allocate 5.75 GiB (GPU 0; 23.69 GiB total capacity; 17.45 GiB already allocated; 4.84 GiB free; 17.47 GiB reserved in total by PyTorch)
RuntimeError: CUDA out of memory. Tried to allocate 5.75 GiB (GPU 0; 23.69 GiB total capacity; 17.45 GiB already allocated; 4.84 GiB free; 17.47 GiB reserved in total by PyTorch)
6. Detecting exotic wakes with hydrodynamic sensors Mengying Wang and Maziar S. Hemati ↩
7. AIAA conference-2019,Machine Learning Based Detection of Flow Disturbances Using Surface Pressure Measurements Wei Hou∗1 , Darwin Darakananda†1 , and Jeff D. Eldredge‡1 ↩
8. Kiran Ramesh, Ashok Gopalarathnam, Kenneth Granlund, Michael V. Ol, and Jack R. Edwards. Discrete-vortex method with novel shedding criterion for unsteady aerofoil flows with intermittent leading-edge vortex shedding. Journal of Fluid Mechanics, 751:500–538, 2014 ↩