跳至主要內容
  • Hostloc 空間訪問刷分
  • 售賣場
  • 廣告位
  • 賣站?

4563博客

全新的繁體中文 WordPress 網站
  • 首頁
  • tensorflow_macos 速度测试
未分類
23 11 月 2020

tensorflow_macos 速度测试

tensorflow_macos 速度测试

資深大佬 : sharpy 3

MBP16 i9-9880h 5500M 8G

#!/usr/bin/env python # coding: utf-8 import tensorflow.compat.v2 as tf import tensorflow_datasets as tfds  tf.enable_v2_behavior()  from tensorflow.python.framework.ops import disable_eager_execution  disable_eager_execution()  from tensorflow.python.compiler.mlcompute import mlcompute  mlcompute.set_mlc_device(device_name='cpu')  (ds_train, ds_test), ds_info = tfds.load(     'mnist',     split=['train', 'test'],     shuffle_files=True,     as_supervised=True,     with_info=True, )   def normalize_img(image, label):     """Normalizes images: `uint8` -> `float32`."""     return tf.cast(image, tf.float32) / 255., label   ds_train = ds_train.map(     normalize_img, num_parallel_calls=tf.data.experimental.AUTOTUNE) ds_train = ds_train.cache() ds_train = ds_train.shuffle(ds_info.splits['train'].num_examples) ds_train = ds_train.batch(128) ds_train = ds_train.prefetch(tf.data.experimental.AUTOTUNE)  ds_test = ds_test.map(     normalize_img, num_parallel_calls=tf.data.experimental.AUTOTUNE) ds_test = ds_test.batch(128) ds_test = ds_test.cache() ds_test = ds_test.prefetch(tf.data.experimental.AUTOTUNE)  model = tf.keras.models.Sequential([     tf.keras.layers.Flatten(input_shape=(28, 28, 1)),     tf.keras.layers.Dense(128, activation='relu'),     tf.keras.layers.Dense(10, activation='softmax') ]) model.compile(     loss='sparse_categorical_crossentropy',     optimizer=tf.keras.optimizers.Adam(0.001),     metrics=['accuracy'], )  model.fit(     ds_train,     epochs=10, ) 

GPU 速度

Epoch 1/10 469/469 [==============================] – 10s 14ms/step – batch: 234.0000 – size: 1.0000 – loss: 0.3598 – accuracy: 0.9028

Epoch 2/10 469/469 [==============================] – 9s 14ms/step – batch: 234.0000 – size: 1.0000 – loss: 0.1623 – accuracy: 0.9535

Epoch 3/10 469/469 [==============================] – 9s 14ms/step – batch: 234.0000 – size: 1.0000 – loss: 0.1182 – accuracy: 0.9664

Epoch 4/10 469/469 [==============================] – 9s 14ms/step – batch: 234.0000 – size: 1.0000 – loss: 0.0911 – accuracy: 0.9735

Epoch 5/10 469/469 [==============================] – 9s 14ms/step – batch: 234.0000 – size: 1.0000 – loss: 0.0732 – accuracy: 0.9786

CPU 速度

Epoch 1/10 469/469 [==============================] – 3s 1ms/step – batch: 234.0000 – size: 1.0000 – loss: nan – accuracy: 0.0987

Epoch 2/10 469/469 [==============================] – 3s 1ms/step – batch: 234.0000 – size: 1.0000 – loss: nan – accuracy: 0.0987

Epoch 3/10 469/469 [==============================] – 3s 1ms/step – batch: 234.0000 – size: 1.0000 – loss: nan – accuracy: 0.0987

Epoch 4/10 469/469 [==============================] – 3s 1ms/step – batch: 234.0000 – size: 1.0000 – loss: nan – accuracy: 0.0987

Epoch 5/10 469/469 [==============================] – 3s 1ms/step – batch: 234.0000 – size: 1.0000 – loss: nan – accuracy: 0.0987

大佬有話說 (6)

  • 資深大佬 : tzm41

    浅窄的 dense net,GPU 没啥加速效果吧…

  • 資深大佬 : RichardSun

    想起之前我试过一个好像叫 plaidML 的 backend,随便跑了下试试 GPU 模式比普通 backend 的 CPU 都慢

  • 資深大佬 : ZRS

    试试 resnet50

  • 資深大佬 : tianshilei1992

    我一直想写一个 Metal 的 OpenMP offloading plugin,但是 Metal compiler 没开源,我搞不定 CodeGen…

  • 主 資深大佬 : sharpy

    @tianshilei1992 #4 你可以看看 https://github.com/a2flo/floor.git 这个项目,也许有点儿启发,这个项目修改了 clang 的源码,使之能生成各个后端代码,看说明是“compiles compute/graphics C++ code to CUDA/PTX, Metal/AIR, OpenCL/SPIR/SPIR-V, Vulkan/SPIR-V code/binaries ”

  • 資深大佬 : tianshilei1992

    @sharpy

文章導覽

上一篇文章
下一篇文章

AD

其他操作

  • 登入
  • 訂閱網站內容的資訊提供
  • 訂閱留言的資訊提供
  • WordPress.org 台灣繁體中文

51la

4563博客

全新的繁體中文 WordPress 網站
返回頂端
本站採用 WordPress 建置 | 佈景主題採用 GretaThemes 所設計的 Memory
4563博客
  • Hostloc 空間訪問刷分
  • 售賣場
  • 廣告位
  • 賣站?
在這裡新增小工具