Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the function of torch.backends.cudnn.benchmark in PyTorch

2025-02-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article is to share with you about the role of torch.backends.cudnn.benchmark in PyTorch, the editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.

Setting up torch.backends.cudnn.benchmark=True will allow the program to spend a little extra time at the beginning, searching for the convolution algorithm that best suits it for each convolution layer of the entire network, thereby speeding up the network. The applicable scenario is that the network structure is fixed (not dynamic), and the input shape of the network (including batch size, image size, input channel) is unchanged, which is generally applicable. On the contrary, if the settings of the convolution layer change all the time, it will cause the program to optimize constantly, which will take more time.

The general code is put at the beginning:

If args.use_gpu and torch.cuda.is_available (): device = torch.device ('cuda') torch.backends.cudnn.benchmark = Trueelse:device = torch.device (' cpu') these are the functions of torch.backends.cudnn.benchmark in PyTorch. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report