简体   繁体   English

tensorflow gpu 上的 2.0 自定义层

[英]tensorflow 2.0 custom layers on gpu

Will completely custom-made layers in TensorFlow automatically be run on GPUs? TensorFlow 中完全定制的层会自动在 GPU 上运行吗? I noticed that in this document ( https://www.tensorflow.org/guide/keras/rnn#rnn_layers_and_rnn_cells ) it seems that the RNN wrappers won't be using CudNN?我注意到在本文档( https://www.tensorflow.org/guide/keras/rnn#rnn_layers_and_rnn_cells )中似乎 RNN 包装器不会使用 CudNN? That means it wouldn't run on the GPU right?这意味着它不会在 GPU 上运行,对吧?

Your custom layers will still use the GPU and you can confirm that as explained in this answer .您的自定义图层仍将使用 GPU 并且您可以按照此答案中的说明进行确认。

You are right though that the custom layers won't use cuDNN.尽管自定义层不会使用 cuDNN,但您是对的。 Why does it matter?为什么这有关系? To quote after NVidia:在 NVidia 之后引用:

cuDNN provides highly tuned implementations for standard routines such as forward and backward convolution, pooling, normalization, and activation layers cuDNN 为标准例程提供高度调整的实现,例如前向和后向卷积、池化、归一化和激活层

In other words, using these optimised primitives will enhance performance of the training.换句话说,使用这些优化的原语将提高训练的性能。 Number of examples with detailed explanation is provided in the cuDNN: Efficient Primitives for Deep Learning paper. cuDNN: Efficient Primitives for Deep Learning论文中提供了许多带有详细解释的示例。 Take for instance spatial convolutions .空间卷积为例。 Non-optimised implementation would use "naive" approach, while cuDNN uses all sorts of tricks to reduce number of operations and batch them appropriately.未优化的实现将使用“幼稚”的方法,而 cuDNN 使用各种技巧来减少操作数量并适当地对它们进行批处理。 GPU is still fast when compared to classical CPU, cuDNN just makes it faster.与经典 CPU 相比,GPU 仍然很快,cuDNN 只是让它更快。 For more recent, independent benchmarks, check out eg this article .有关最新的独立基准,请查看例如这篇文章

Still, if Tensorflow runs in the GPU mode, complete computational graph will be executed on the GPU (to my knowledge there's even no simple way you could take out portion of the graph, ie intermediate layer, and put on CPU).尽管如此,如果 Tensorflow 在 GPU 模式下运行,完整的计算图将在 GPU 上执行(据我所知,甚至没有简单的方法可以取出图的中间层),

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM