{"id":364751,"date":"2024-05-21T02:23:38","date_gmt":"2024-05-21T02:23:38","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=364751"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=364751","title":{"rendered":"<span>\u041e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 Power Limit \u0434\u043b\u044f deep learning \u0437\u0430\u0434\u0430\u0447 \u043d\u0430 RTX 3090<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041d\u0435\u0434\u0430\u0432\u043d\u043e \u044f \u043a\u0443\u043f\u0438\u043b \u0431\/\u0443 RTX 3090 \u0434\u043b\u044f \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u043e\u0432 \u0441 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435\u043c \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u044b\u0445 \u0441\u0435\u0442\u0435\u0439 \u0438 \u0432\u044b\u044f\u0441\u043d\u0438\u043b, \u0447\u0442\u043e \u043a\u0430\u0440\u0442\u0430 \u0441\u0438\u043b\u044c\u043d\u043e \u043d\u0430\u0433\u0440\u0435\u0432\u0430\u0435\u0442\u0441\u044f \u0438 \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u044f\u0435\u0442 \u043c\u043d\u043e\u0433\u043e \u044d\u043d\u0435\u0440\u0433\u0438\u0438.<\/p>\n<p>\u0421\u0442\u043e\u043a\u043e\u0432\u044b\u0439 power limit \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 390 \u0412\u0442, \u043d\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d \u0434\u043e 480 \u0412\u0442. GPU \u0432\u044b\u0434\u0435\u043b\u044f\u0435\u0442 \u0442\u0430\u043a \u043c\u043d\u043e\u0433\u043e \u0442\u0435\u043f\u043b\u0430, \u0447\u0442\u043e \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u043d\u0430\u0433\u0440\u0435\u0432\u0430\u0442\u044c CPU. <\/p>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u0441\u043d\u0438\u0436\u0435\u043d\u0438\u044f \u043d\u0430\u0433\u0440\u0435\u0432\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u043d\u0438\u0436\u0435\u043d\u0438\u0435 \u043d\u0430\u043f\u0440\u044f\u0436\u0435\u043d\u0438\u044f (undervolting): <br \/>\u043c\u0435\u043d\u044c\u0448\u0435 \u043d\u0430\u043f\u0440\u044f\u0436\u0435\u043d\u0438\u0435 => \u043c\u0435\u043d\u044c\u0448\u0435 \u043c\u043e\u0449\u043d\u043e\u0441\u0442\u044c => \u043c\u0435\u043d\u044c\u0448\u0435 \u043d\u0430\u0433\u0440\u0435\u0432. <\/p>\n<p>\u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u044b NVIDIA \u043f\u043e\u0434 Linux <a href=\"https:\/\/github.com\/NVIDIA\/open-gpu-kernel-modules\/discussions\/236\" rel=\"noopener noreferrer nofollow\">\u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0442<\/a> \u043f\u043e\u043d\u0438\u0436\u0435\u043d\u0438\u0435 \u043d\u0430\u043f\u0440\u044f\u0436\u0435\u043d\u0438\u044f. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u043c \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u043d\u0438\u0436\u0435\u043d\u0438\u0435 \u043b\u0438\u043c\u0438\u0442\u0430 \u043c\u043e\u0449\u043d\u043e\u0441\u0442\u0438 (power limit).<\/p>\n<p>Power limit &#8212; \u044d\u0442\u043e \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u044d\u043d\u0435\u0440\u0433\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u044f\u0442\u044c GPU. \u042d\u0442\u043e\u0442 \u043f\u0440\u0435\u0434\u0435\u043b \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u0443\u0442\u0435\u043c \u0440\u0435\u0433\u0443\u043b\u0438\u0440\u043e\u0432\u043a\u0438 \u0447\u0430\u0441\u0442\u043e\u0442 \u0438 \u043d\u0430\u043f\u0440\u044f\u0436\u0435\u043d\u0438\u0439, \u0447\u0442\u043e\u0431\u044b \u044d\u043d\u0435\u0440\u0433\u043e\u043f\u043e\u0442\u0440\u0435\u0431\u043b\u0435\u043d\u0438\u0435 \u043e\u0441\u0442\u0430\u0432\u0430\u043b\u043e\u0441\u044c \u043d\u0438\u0436\u0435 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u0435\u043b\u0430. \u042f \u0441\u043d\u0438\u0437\u0438\u043b power limit \u0434\u043e 250 \u0412\u0442, \u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0443\u043f\u0430\u043b\u0430 \u043d\u0435 \u0442\u0430\u043a \u0441\u0438\u043b\u044c\u043d\u043e, \u043a\u0430\u043a \u044f \u043e\u0436\u0438\u0434\u0430\u043b. \u042f \u0440\u0435\u0448\u0438\u043b \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c, \u043a\u0430\u043a \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043c\u043e\u0449\u043d\u043e\u0441\u0442\u0438 \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435  DL \u0437\u0430\u0434\u0430\u0447\u0438:<\/p>\n<ul>\n<li>\n<p>Training:<\/p>\n<ul>\n<li>\n<p>fp32<\/p>\n<\/li>\n<li>\n<p>tf32<\/p>\n<\/li>\n<li>\n<p>amp fp16<\/p>\n<\/li>\n<li>\n<p>fp16 (.half())<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>Inference:<\/p>\n<ul>\n<li>\n<p>fp32<\/p>\n<\/li>\n<li>\n<p>tf32<\/p>\n<\/li>\n<li>\n<p>amp fp16<\/p>\n<\/li>\n<li>\n<p>fp16 (.half())<\/p>\n<\/li>\n<li>\n<p>TensorRT fp16<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>\u0412\u0441\u0435 \u0442\u0435\u0441\u0442\u044b \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u043b\u0438\u0441\u044c \u043d\u0430 vit_base_patch16_224 \u0438\u0437 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 <a href=\"https:\/\/github.com\/huggingface\/pytorch-image-models\" rel=\"noopener noreferrer nofollow\">timm<\/a>.<\/p>\n<\/p>\n<h2>fp32 training batch_size=160 approx. 20GB of VRAM<\/h2>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/fd8\/ee6\/bf6\/fd8ee6bf64c7be4631b872bff3d4c8dc.png\" width=\"1742\" height=\"1302\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/fd8\/ee6\/bf6\/fd8ee6bf64c7be4631b872bff3d4c8dc.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/1a8\/b96\/cd5\/1a8b96cd5cf55cc8a27ad310e7700cab.png\" width=\"3728\" height=\"1344\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/1a8\/b96\/cd5\/1a8b96cd5cf55cc8a27ad310e7700cab.png\"\/><\/figure>\n<p>280 \u0412\u0442 => 80 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432 \u043e\u0442 \u043f\u0438\u043a\u043e\u0432\u043e\u0439 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 (\u043f\u0440\u0438 480\u0412\u0442)<br \/>330 \u0412\u0442 => 90 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432<br \/>380 \u0412\u0442 => 95 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432<\/p>\n<h2>tf32<\/h2>\n<p>\u041d\u0430\u043f\u0438\u0441\u0430\u0432<\/p>\n<pre><code class=\"python\">torch.backends.cuda.matmul.allow_tf32 = True<\/code><\/pre>\n<p>\u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0443\u043a\u0430\u0437\u0430\u0442\u044c pytorch \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0440\u0435\u0436\u0438\u043c \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439 TF32. \u041f\u043e \u0441\u0443\u0442\u0438, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u0436\u0435\u0440\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0447\u0430\u0441\u0442\u044c\u044e \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438 fp32, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0431\u044b\u0441\u0442\u0440\u044b\u0435 \u043c\u0430\u0442\u0440\u0438\u0447\u043d\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438. \u0418\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043d\u0438\u0436\u0435 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442, \u043a\u0430\u043a \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u0438 \u0432\u0437\u044f\u0442\u044b \u0438\u0437 \u0441\u0442\u0430\u0442\u044c\u0438 \u0432<a href=\"https:\/\/developer.nvidia.com\/blog\/accelerating-ai-training-with-tf32-tensor-cores\/\" rel=\"noopener noreferrer nofollow\"> \u0431\u043b\u043e\u0433\u0435<\/a> NVIDIA. \u041e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 TF32 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u044b \u0422\u0435\u043d\u0437\u043e\u0440\u043d\u044b\u043c\u0438 \u044f\u0434\u0440\u0430\u043c\u0438 (Tensor Cores).<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/59c\/311\/9da\/59c3119daa755c67c9bd204b9836a37a.png\" alt=\"\u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0444\u043e\u0440\u043c\u0430\u0442\u043e\u0432 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0447\u0438\u0441\u0435\u043b\" title=\"\u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0444\u043e\u0440\u043c\u0430\u0442\u043e\u0432 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0447\u0438\u0441\u0435\u043b\" width=\"625\" height=\"371\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/59c\/311\/9da\/59c3119daa755c67c9bd204b9836a37a.png\"\/><\/p>\n<div><figcaption>\u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0444\u043e\u0440\u043c\u0430\u0442\u043e\u0432 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0447\u0438\u0441\u0435\u043b<\/figcaption><\/div>\n<\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/944\/3c8\/78f\/9443c878f50f75704d36503613404449.png\" alt=\"\u041e\u043f\u0435\u0440\u0430\u0446\u0438\u044f dot product (\u0441\u043a\u0430\u043b\u044f\u0440\u043d\u043e\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435) \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c TF32\" title=\"\u041e\u043f\u0435\u0440\u0430\u0446\u0438\u044f dot product (\u0441\u043a\u0430\u043b\u044f\u0440\u043d\u043e\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435) \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c TF32\" width=\"768\" height=\"251\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/944\/3c8\/78f\/9443c878f50f75704d36503613404449.png\"\/><\/p>\n<div><figcaption>\u041e\u043f\u0435\u0440\u0430\u0446\u0438\u044f dot product (\u0441\u043a\u0430\u043b\u044f\u0440\u043d\u043e\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435) \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c TF32<\/figcaption><\/div>\n<\/figure>\n<h2>tf32 training batch_size=160 approx. 20GB of VRAM<\/h2>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/fcc\/4d7\/03a\/fcc4d703afe7e51e022ab402cf07af51.png\" width=\"1741\" height=\"1304\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/fcc\/4d7\/03a\/fcc4d703afe7e51e022ab402cf07af51.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/546\/fb9\/bcc\/546fb9bcc5fd6dd6ed0a2e6559b1e768.png\" width=\"3728\" height=\"1344\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/546\/fb9\/bcc\/546fb9bcc5fd6dd6ed0a2e6559b1e768.png\"\/><\/figure>\n<p>230 \u0412\u0442 => 80 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432 \u043e\u0442 \u043f\u0438\u043a\u043e\u0432\u043e\u0439 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 (\u043f\u0440\u0438 480\u0412\u0442)<br \/>280 \u0412\u0442 => 90 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432<br \/>320 \u0412\u0442 => 95 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432<br \/>\u041a\u0430\u043a \u043c\u044b \u0432\u0438\u0434\u0438\u043c, \u0442\u0435\u043d\u0437\u043e\u0440\u043d\u044b\u0435 \u044f\u0434\u0440\u0430 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0431\u044b\u0441\u0442\u0440\u0435\u0435, \u043d\u043e \u0438 \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u043e\u043b\u0435\u0435 \u044d\u043d\u0435\u0440\u0433\u043e\u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b.<\/p>\n<h2>amp (fp16)<\/h2>\n<p>\u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>torch.autocast<\/code> \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0443\u043a\u0430\u0437\u0430\u0442\u044c pytorch \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c fp16 \u0432\u043c\u0435\u0441\u0442\u043e fp32 \u0434\u043b\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439. \u0421\u043f\u0438\u0441\u043e\u043a \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c <a href=\"https:\/\/pytorch.org\/docs\/stable\/amp.html#cuda-op-specific-behavior\" rel=\"noopener noreferrer nofollow\">\u0437\u0434\u0435\u0441\u044c<\/a>. \u0418 \u0441\u043d\u043e\u0432\u0430 \u043c\u044b \u043e\u0431\u043c\u0435\u043d\u0438\u0432\u0430\u0435\u043c \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u043d\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c. \u041c\u044b \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a matmul, conv2d, \u0430\u0432\u0442\u043e\u043a\u0430\u0441\u0442\u044f\u0442\u0441\u044f \u0432 fp16, \u043d\u043e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438, \u0442\u0440\u0435\u0431\u0443\u044e\u0449\u0438\u0435 \u0431\u043e\u043b\u044c\u0448\u0435\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a sum, pow, \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u043e\u0442\u0435\u0440\u044c \u0438 \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u0430\u0432\u0442\u043e\u043a\u0430\u0441\u0442\u044f\u0442\u0441\u044f fp32.<br \/>\u0421 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c fp16 \u0435\u0441\u0442\u044c \u043e\u0434\u043d\u0430 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430: \u0438\u043d\u043e\u0433\u0434\u0430 \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u044b \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043a\u043e \u043c\u0430\u043b\u044b, \u0447\u0442\u043e \u043d\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u0432 fp16 \u0438 \u043e\u043a\u0440\u0443\u0433\u043b\u044f\u044e\u0442\u0441\u044f \u0434\u043e \u043d\u0443\u043b\u044f.<br \/>\u043d\u0443\u043b\u0435\u0432\u043e\u0439 \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442 =>\u043d\u0443\u043b\u0435\u0432\u043e\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0432\u0435\u0441\u043e\u0432 => \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u043d\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442.<br \/>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u0443\u043c\u043d\u043e\u0436\u0430\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u043e\u0442\u0435\u0440\u044c \u043d\u0430 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f (\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0446\u0435\u043d\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438), \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0441\u043b\u0435 backward pass \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043d\u0435\u043d\u0443\u043b\u0435\u0432\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u0430.<br \/>\u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u044b \u0434\u043b\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0432\u0435\u0441\u043e\u0432, \u043c\u044b \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0438\u0445 \u0432 fp32 \u0438 \u0443\u0431\u0438\u0440\u0430\u0435\u043c \u0440\u0430\u043d\u0435\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u043d\u043e\u0435 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u0447\u0442\u043e\u0431\u044b \u043e\u043d\u043e \u043d\u0435 \u0432\u043b\u0438\u044f\u043b\u043e \u043d\u0430 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f (\u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u044b \u0443\u043c\u043d\u043e\u0436\u0430\u044e\u0442\u0441\u044f \u043d\u0430 learning rate, \u0438 \u0435\u0441\u043b\u0438 \u043c\u044b \u043d\u0435 \u0443\u0431\u0435\u0440\u0435\u043c \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u0442\u043e \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0439 learning rate \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0433\u043e).<br \/>\u0415\u0441\u043b\u0438 \u0441\u043e\u0431\u043b\u044e\u0434\u0435\u043d\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435 \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u0438, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a \u0432\u0435\u0440\u0441\u0438\u044f cuBLAS\/cuDNN \u0438 \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u0438 \u043c\u0430\u0442\u0440\u0438\u0446, \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0431\u0443\u0434\u0443\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u0442\u0435\u043d\u0437\u043e\u0440\u043d\u044b\u043c\u0438 \u044f\u0434\u0440\u0430\u043c\u0438. \u041a\u0440\u0438\u0442\u0435\u0440\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043d\u0430 <a href=\"https:\/\/developer.download.nvidia.com\/video\/gputechconf\/gtc\/2020\/presentations\/s21929-tensor-core-performance-on-nvidia-gpus-the-ultimate-guide.pdf\" rel=\"noopener noreferrer nofollow\">\u0441\u043b\u0430\u0439\u0434\u0430\u0445<\/a> \u043e\u0442 NVIDIA (\u0441\u0442\u0440. 18-19).<\/p>\n<pre><code class=\"python\">for images, labels in zip(data, targets):     optimizer.zero_grad()     with autocast(device_type='cuda', dtype=torch.float16):         outputs = model.forward(images)         loss = criterion(outputs,labels)      scaler.scale(loss).backward()     scaler.step(optimizer)     scaler.update()<\/code><\/pre>\n<h2>amp (fp16) training batch_size=160 approx. 13GB of VRAM<\/h2>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/8c5\/b00\/50c\/8c5b0050c9a2c877e23ad6301a4da6cd.png\" width=\"1741\" height=\"1298\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/8c5\/b00\/50c\/8c5b0050c9a2c877e23ad6301a4da6cd.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/839\/432\/691\/839432691465364327b4f3b2edbeee48.png\" width=\"3728\" height=\"1344\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/839\/432\/691\/839432691465364327b4f3b2edbeee48.png\"\/><\/figure>\n<p>250 \u0412\u0442 => 80 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432 \u043e\u0442 \u043f\u0438\u043a\u043e\u0432\u043e\u0439 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 (\u043f\u0440\u0438 480\u0412\u0442)<br \/>300 \u0412\u0442 => 90 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432<br \/>350 \u0412\u0442 => 95 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432<\/p>\n<p>\u042d\u043d\u0435\u0440\u0433\u043e\u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0445\u0443\u0436\u0435, \u0447\u0435\u043c \u0443 tf32, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u0432 fp32 \u0438 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0442\u0435\u043d\u0437\u043e\u0440\u043d\u044b\u0435 \u044f\u0434\u0440\u0430.<\/p>\n<h2>fp16 (.half())<\/h2>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f <code>.half()<\/code> \u043d\u0430 \u043d\u0430\u0448\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043c\u043e\u0434\u0435\u043b\u0438, \u043c\u044b \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u043c \u0438\u0445 \u0432 fp16. \u042d\u0442\u043e \u0431\u044b\u0441\u0442\u0440\u0435\u0435, \u0447\u0435\u043c amp, \u043d\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u043d\u0435\u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u043c\u0443 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044e \u0438 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u0431\u043e\u043b\u044c\u0448\u043e\u043c\u0443 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 NaN&#8217;\u043e\u0432.<\/p>\n<h2>fp16 (.half()) training batch_size=160 approx. 11GB of VRAM<\/h2>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/bcb\/824\/927\/bcb824927f94a03134597a4c33a3e97f.png\" width=\"1715\" height=\"1298\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/bcb\/824\/927\/bcb824927f94a03134597a4c33a3e97f.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/a77\/7ff\/0b4\/a777ff0b489bc8c9dd1dd3c606617298.png\" width=\"3728\" height=\"1344\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a77\/7ff\/0b4\/a777ff0b489bc8c9dd1dd3c606617298.png\"\/><\/figure>\n<p>200 \u0412\u0442 => 80 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432 \u043e\u0442 \u043f\u0438\u043a\u043e\u0432\u043e\u0439 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 (\u043f\u0440\u0438 480\u0412\u0442)<br \/>230 \u0412\u0442 => 90 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432<br \/>270 \u0412\u0442 => 95 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432<\/p>\n<p>\u042d\u0442\u043e \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u044d\u043d\u0435\u0440\u0433\u043e\u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435: \u043c\u044b \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c fp32.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c inference.<\/p>\n<h2>fp32 inference batch_size=2048 approx. 21GB of VRAM<\/h2>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/f2b\/200\/1af\/f2b2001afb96a0617f1fbca43dfc80d7.png\" width=\"1768\" height=\"1299\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f2b\/200\/1af\/f2b2001afb96a0617f1fbca43dfc80d7.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/a56\/a81\/077\/a56a81077f6ac895995a12d7919f5898.png\" width=\"3728\" height=\"1344\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a56\/a81\/077\/a56a81077f6ac895995a12d7919f5898.png\"\/><\/figure>\n<p>290 \u0412\u0442 => 80 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432 \u043e\u0442 \u043f\u0438\u043a\u043e\u0432\u043e\u0439 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 (\u043f\u0440\u0438 480\u0412\u0442)<br \/>350 \u0412\u0442 => 90 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432<br \/>390 \u0412\u0442 => 95 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432<\/p>\n<h2>tf32 inference batch_size=2048 approx. 21GB of VRAM<\/h2>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/c8b\/4c3\/b12\/c8b4c3b125ed7c030fb4bd0e909b8fd6.png\" width=\"1768\" height=\"1313\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c8b\/4c3\/b12\/c8b4c3b125ed7c030fb4bd0e909b8fd6.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/dec\/302\/e68\/dec302e6886d788d585dcaf0642d6147.png\" width=\"3728\" height=\"1344\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/dec\/302\/e68\/dec302e6886d788d585dcaf0642d6147.png\"\/><\/figure>\n<p>250 \u0412\u0442 => 80 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432 \u043e\u0442 \u043f\u0438\u043a\u043e\u0432\u043e\u0439 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 (\u043f\u0440\u0438 480\u0412\u0442)<br \/>300 \u0412\u0442 => 90 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432<br \/>350 \u0412\u0442 => 95 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432<\/p>\n<h2>amp (fp16) inference batch_size=2048 approx. 16GB of VRAM<\/h2>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/be8\/00e\/0d7\/be800e0d79487585322a45264de5b86c.png\" width=\"1741\" height=\"1298\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/be8\/00e\/0d7\/be800e0d79487585322a45264de5b86c.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/303\/0f6\/557\/3030f6557db2b71de9bc65596dca2d8c.png\" width=\"3728\" height=\"1344\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/303\/0f6\/557\/3030f6557db2b71de9bc65596dca2d8c.png\"\/><\/figure>\n<p>260 \u0412\u0442 => 80 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432 \u043e\u0442 \u043f\u0438\u043a\u043e\u0432\u043e\u0439 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 (\u043f\u0440\u0438 480\u0412\u0442)<br \/>310 \u0412\u0442 => 90 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432<br \/>360 \u0412\u0442 => 95 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432<\/p>\n<h2>fp16 (.half()) inference batch_size=2048 approx. 11GB of VRAM<\/h2>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/6b0\/933\/9f7\/6b09339f710756e3b18532d48ae50e6a.png\" width=\"1741\" height=\"1298\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/6b0\/933\/9f7\/6b09339f710756e3b18532d48ae50e6a.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/191\/4cb\/b4c\/1914cbb4c866592522cf9fa100d57b6b.png\" width=\"3728\" height=\"1344\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/191\/4cb\/b4c\/1914cbb4c866592522cf9fa100d57b6b.png\"\/><\/figure>\n<p>260 \u0412\u0442 =>80 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432 \u043e\u0442 \u043f\u0438\u043a\u043e\u0432\u043e\u0439 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 (\u043f\u0440\u0438 480\u0412\u0442)<br \/>310 \u0412\u0442 => 90 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432<br \/>360 \u0412\u0442 => 95 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432<\/p>\n<h2>TensorRT<\/h2>\n<p>\u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a TensorRT \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0439 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0430\u0448\u0435\u0433\u043e \u0438\u043d\u0444\u0435\u0440\u0435\u043d\u0441\u0430.<br \/>\u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430\u0445 \u043c\u044b \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043d\u0430\u0448\u0443 \u043c\u043e\u0434\u0435\u043b\u044c \u0432 onnx, \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0435\u0433\u043e, \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u043c onnx \u0432 TensorRT \u0438 \u0437\u0430\u0442\u0435\u043c \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u044c TensorRT \u0432 pytorch jit. \u041d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 pytorch \u0441\u0440\u0430\u0437\u0443 \u0432 TensorRT \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0434\u043b\u044f ViT, \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u0432 \u044d\u0442\u043e\u043c <a href=\"https:\/\/github.com\/pytorch\/TensorRT\/issues\/1860\" rel=\"noopener noreferrer nofollow\">issue<\/a>.<\/p>\n<h2>TensorRT fp16 vs pytorch fp16 (.half()) batch_size=512<\/h2>\n<p>Batch size = 512, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043d\u0435 \u0445\u0432\u0430\u0442\u0438\u043b\u043e VRAM \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 TensorRT \u043c\u043e\u0434\u0435\u043b\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0431\u041e\u043b\u044c\u0448\u0438\u0439 \u0431\u0430\u0442\u0447.<\/p>\n<p>.half()<br \/>260 \u0412\u0442 => 82 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u0430 \u043e\u0442 \u043f\u0438\u043a\u043e\u0432\u043e\u0439 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 (\u043f\u0440\u0438 480\u0412\u0442)<br \/>310 \u0412\u0442 => 90 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432<br \/>360 \u0412\u0442 => 95 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432<\/p>\n<p>TensorRT fp16<br \/>290 \u0412\u0442 => 81 \u043f\u0440\u043e\u0446\u0435\u043d\u0442 \u043e\u0442 \u043f\u0438\u043a\u043e\u0432\u043e\u0439 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 (\u043f\u0440\u0438 480\u0412\u0442)<br \/>340 \u0412\u0442 => 90 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432<br \/>390 \u0412\u0442 => 95 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/a10\/292\/2fb\/a102922fb0458173cd33ed09167cde54.png\" alt=\"\u0418\u043d\u0444\u0435\u0440\u0435\u043d\u0441. \u0412\u0440\u0435\u043c\u044f \u043d\u0430 1 \u0431\u0430\u0442\u0447\" title=\"\u0418\u043d\u0444\u0435\u0440\u0435\u043d\u0441. \u0412\u0440\u0435\u043c\u044f \u043d\u0430 1 \u0431\u0430\u0442\u0447\" width=\"3741\" height=\"1344\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a10\/292\/2fb\/a102922fb0458173cd33ed09167cde54.png\"\/><\/p>\n<div><figcaption>\u0418\u043d\u0444\u0435\u0440\u0435\u043d\u0441. \u0412\u0440\u0435\u043c\u044f \u043d\u0430 1 \u0431\u0430\u0442\u0447<\/figcaption><\/div>\n<\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/698\/16d\/f5d\/69816df5d149d011eede17b6eab07536.png\" alt=\"\u0418\u043d\u0444\u0435\u0440\u0435\u043d\u0441. 100 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u0440\u0435\u0436\u0438\u043c\u043e\u0432 \u0438\u043d\u0434\u0438\u0432\u0438\u0434\u0443\u0430\u043b\u044c\u043d\u043e\" title=\"\u0418\u043d\u0444\u0435\u0440\u0435\u043d\u0441. 100 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u0440\u0435\u0436\u0438\u043c\u043e\u0432 \u0438\u043d\u0434\u0438\u0432\u0438\u0434\u0443\u0430\u043b\u044c\u043d\u043e\" width=\"3728\" height=\"1344\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/698\/16d\/f5d\/69816df5d149d011eede17b6eab07536.png\"\/><\/p>\n<div><figcaption>\u0418\u043d\u0444\u0435\u0440\u0435\u043d\u0441. 100 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u0440\u0435\u0436\u0438\u043c\u043e\u0432 \u0438\u043d\u0434\u0438\u0432\u0438\u0434\u0443\u0430\u043b\u044c\u043d\u043e<\/figcaption><\/div>\n<\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/19c\/c1b\/d89\/19cc1bd8960901910aebe77a300761fc.png\" alt=\"\u0418\u043d\u0444\u0435\u0440\u0435\u043d\u0441. 100 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432 \u044d\u0442\u043e TensorRT fp16\" title=\"\u0418\u043d\u0444\u0435\u0440\u0435\u043d\u0441. 100 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432 \u044d\u0442\u043e TensorRT fp16\" width=\"3728\" height=\"1344\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/19c\/c1b\/d89\/19cc1bd8960901910aebe77a300761fc.png\"\/><\/p>\n<div><figcaption>\u0418\u043d\u0444\u0435\u0440\u0435\u043d\u0441. 100 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432 \u044d\u0442\u043e TensorRT fp16<\/figcaption><\/div>\n<\/figure>\n<h3>\u041e\u0431\u0449\u0438\u0435 \u0433\u0440\u0430\u0444\u0438\u043a\u0438<\/h3>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/cfb\/7f8\/957\/cfb7f89577b3b7bece1f28a05be80dda.png\" alt=\"\u0418\u043d\u0444\u0435\u0440\u0435\u043d\u0441. 100 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u0440\u0435\u0436\u0438\u043c\u043e\u0432 \u0438\u043d\u0434\u0438\u0432\u0438\u0434\u0443\u0430\u043b\u044c\u043d\u043e\" title=\"\u0418\u043d\u0444\u0435\u0440\u0435\u043d\u0441. 100 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u0440\u0435\u0436\u0438\u043c\u043e\u0432 \u0438\u043d\u0434\u0438\u0432\u0438\u0434\u0443\u0430\u043b\u044c\u043d\u043e\" width=\"3728\" height=\"1344\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/cfb\/7f8\/957\/cfb7f89577b3b7bece1f28a05be80dda.png\"\/><\/p>\n<div><figcaption>\u0418\u043d\u0444\u0435\u0440\u0435\u043d\u0441. 100 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u0440\u0435\u0436\u0438\u043c\u043e\u0432 \u0438\u043d\u0434\u0438\u0432\u0438\u0434\u0443\u0430\u043b\u044c\u043d\u043e<\/figcaption><\/div>\n<\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d64\/e67\/701\/d64e67701c7e90e38e6e23a71339bc4d.png\" alt=\"\u0418\u043d\u0444\u0435\u0440\u0435\u043d\u0441. 100 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432 \u044d\u0442\u043e  fp16 .half()\" title=\"\u0418\u043d\u0444\u0435\u0440\u0435\u043d\u0441. 100 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432 \u044d\u0442\u043e  fp16 .half()\" width=\"3728\" height=\"1344\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d64\/e67\/701\/d64e67701c7e90e38e6e23a71339bc4d.png\"\/><\/p>\n<div><figcaption>\u0418\u043d\u0444\u0435\u0440\u0435\u043d\u0441. 100 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432 \u044d\u0442\u043e  fp16 .half()<\/figcaption><\/div>\n<\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/7f7\/b93\/8ed\/7f7b938ed79f5a2e29ec0d111a819c7b.png\" alt=\"Train. 100 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u0440\u0435\u0436\u0438\u043c\u043e\u0432 \u0438\u043d\u0434\u0438\u0432\u0438\u0434\u0443\u0430\u043b\u044c\u043d\u043e\" title=\"Train. 100 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u0440\u0435\u0436\u0438\u043c\u043e\u0432 \u0438\u043d\u0434\u0438\u0432\u0438\u0434\u0443\u0430\u043b\u044c\u043d\u043e\" width=\"3728\" height=\"1344\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/7f7\/b93\/8ed\/7f7b938ed79f5a2e29ec0d111a819c7b.png\"\/><\/p>\n<div><figcaption>Train. 100 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u0440\u0435\u0436\u0438\u043c\u043e\u0432 \u0438\u043d\u0434\u0438\u0432\u0438\u0434\u0443\u0430\u043b\u044c\u043d\u043e<\/figcaption><\/div>\n<\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/cb3\/26a\/707\/cb326a70746899fef15c7a8699bbe7c7.png\" alt=\"Train. 100 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432 \u044d\u0442\u043e  fp16 .half()\" title=\"Train. 100 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432 \u044d\u0442\u043e  fp16 .half()\" width=\"3728\" height=\"1344\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/cb3\/26a\/707\/cb326a70746899fef15c7a8699bbe7c7.png\"\/><\/p>\n<div><figcaption>Train. 100 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432 \u044d\u0442\u043e  fp16 .half()<\/figcaption><\/div>\n<\/figure>\n<h2>\u0412\u044b\u0432\u043e\u0434\u044b<\/h2>\n<p>\u0415\u0441\u043b\u0438 \u0445\u043e\u0442\u0438\u0442\u0435 \u0447\u0442\u043e\u0431\u044b GPU \u043d\u0430\u0433\u0440\u0435\u0432\u0430\u043b\u0441\u044f \u043c\u0435\u043d\u044c\u0448\u0435:<\/p>\n<ul>\n<li>\n<p>\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u0431\u043e\u043b\u0435\u0435 \u043d\u0438\u0437\u043a\u0443\u044e \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c. \u042d\u0442\u043e \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0431\u044b\u0441\u0442\u0440\u0435\u0435, \u043d\u043e \u0438 \u043a\u0440\u0438\u0432\u0430\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c\/\u043c\u043e\u0449\u043d\u043e\u0441\u0442\u044c \u043d\u0430\u0441\u044b\u0449\u0430\u0435\u0442\u0441\u044f \u0431\u044b\u0441\u0442\u0440\u0435\u0435, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043d\u0438\u0437\u0438\u0442\u044c power limit \u0431\u0435\u0437 \u043e\u0441\u043e\u0431\u043e\u0433\u043e \u0443\u0449\u0435\u0440\u0431\u0430 \u0434\u043b\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438.<\/p>\n<\/li>\n<li>\n<p>330-360 \u0412\u0442 &#8212; \u0445\u043e\u0440\u043e\u0448\u0438\u0439 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d \u0434\u043b\u044f power limit. \u041c\u043e\u0436\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u0441\u0442\u043e\u043a\u043e\u0432\u043e\u0433\u043e power limit \u043d\u0435\u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u043d\u043e \u0434\u0430\u0436\u0435 \u0442\u0430\u043a\u043e\u0435 \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u0442\u044c GPU \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0445\u043b\u0430\u0434\u043d\u0435\u0435 (3-5 \u0433\u0440\u0430\u0434\u0443\u0441\u043e\u0432 \u0426\u0435\u043b\u044c\u0441\u0438\u044f) \u0438 \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c RPM \u0432\u0435\u043d\u0442\u0438\u043b\u044f\u0442\u043e\u0440\u043e\u0432.<br \/>\u0412 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u0438\u0440\u043e\u0441\u0442 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0435\u0449\u0435 \u0431\u043e\u043b\u044c\u0448\u0435. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u0435\u0439\u0447\u0430\u0441 \u044f \u0434\u0435\u043b\u0430\u044e \u0438\u043d\u0444\u0435\u0440\u0435\u043d\u0441 DDPM \u043c\u043e\u0434\u0435\u043b\u0438, \u0438 \u0441\u043d\u0438\u0436\u0435\u043d\u0438\u0435 power limit \u0441 390 \u0412\u0442 \u0434\u043e 300 \u0412\u0442 \u0441\u043d\u0438\u0436\u0430\u0435\u0442 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u043b\u0438\u0448\u044c \u043d\u0430 8 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432, \u043f\u0440\u0438\u0447\u0435\u043c \u0443\u0442\u0438\u043b\u0438\u0437\u0430\u0446\u0438\u044f GPU 100%.<\/p>\n<\/li>\n<\/ul>\n<p>\u041a\u043e\u0434 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043d\u0430 <a href=\"https:\/\/github.com\/qwertyforce\/optimal_power_limit_for_dl\" rel=\"noopener noreferrer nofollow\">Github<\/a><\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/785022\/\"> https:\/\/habr.com\/ru\/articles\/785022\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041d\u0435\u0434\u0430\u0432\u043d\u043e \u044f \u043a\u0443\u043f\u0438\u043b \u0431\/\u0443 RTX 3090 \u0434\u043b\u044f \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u043e\u0432 \u0441 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435\u043c \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u044b\u0445 \u0441\u0435\u0442\u0435\u0439 \u0438 \u0432\u044b\u044f\u0441\u043d\u0438\u043b, \u0447\u0442\u043e \u043a\u0430\u0440\u0442\u0430 \u0441\u0438\u043b\u044c\u043d\u043e \u043d\u0430\u0433\u0440\u0435\u0432\u0430\u0435\u0442\u0441\u044f \u0438 \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u044f\u0435\u0442 \u043c\u043d\u043e\u0433\u043e \u044d\u043d\u0435\u0440\u0433\u0438\u0438.<\/p>\n<p>\u0421\u0442\u043e\u043a\u043e\u0432\u044b\u0439 power limit \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 390 \u0412\u0442, \u043d\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d \u0434\u043e 480 \u0412\u0442. GPU \u0432\u044b\u0434\u0435\u043b\u044f\u0435\u0442 \u0442\u0430\u043a \u043c\u043d\u043e\u0433\u043e \u0442\u0435\u043f\u043b\u0430, \u0447\u0442\u043e \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u043d\u0430\u0433\u0440\u0435\u0432\u0430\u0442\u044c CPU. <\/p>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u0441\u043d\u0438\u0436\u0435\u043d\u0438\u044f \u043d\u0430\u0433\u0440\u0435\u0432\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u043d\u0438\u0436\u0435\u043d\u0438\u0435 \u043d\u0430\u043f\u0440\u044f\u0436\u0435\u043d\u0438\u044f (undervolting): <br \/>\u043c\u0435\u043d\u044c\u0448\u0435 \u043d\u0430\u043f\u0440\u044f\u0436\u0435\u043d\u0438\u0435 => \u043c\u0435\u043d\u044c\u0448\u0435 \u043c\u043e\u0449\u043d\u043e\u0441\u0442\u044c => \u043c\u0435\u043d\u044c\u0448\u0435 \u043d\u0430\u0433\u0440\u0435\u0432. <\/p>\n<p>\u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u044b NVIDIA \u043f\u043e\u0434 Linux <a href=\"https:\/\/github.com\/NVIDIA\/open-gpu-kernel-modules\/discussions\/236\" rel=\"noopener noreferrer nofollow\">\u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0442<\/a> \u043f\u043e\u043d\u0438\u0436\u0435\u043d\u0438\u0435 \u043d\u0430\u043f\u0440\u044f\u0436\u0435\u043d\u0438\u044f. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u043c \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u043d\u0438\u0436\u0435\u043d\u0438\u0435 \u043b\u0438\u043c\u0438\u0442\u0430 \u043c\u043e\u0449\u043d\u043e\u0441\u0442\u0438 (power limit).<\/p>\n<p>Power limit &#8212; \u044d\u0442\u043e \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u044d\u043d\u0435\u0440\u0433\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u044f\u0442\u044c GPU. \u042d\u0442\u043e\u0442 \u043f\u0440\u0435\u0434\u0435\u043b \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u0443\u0442\u0435\u043c \u0440\u0435\u0433\u0443\u043b\u0438\u0440\u043e\u0432\u043a\u0438 \u0447\u0430\u0441\u0442\u043e\u0442 \u0438 \u043d\u0430\u043f\u0440\u044f\u0436\u0435\u043d\u0438\u0439, \u0447\u0442\u043e\u0431\u044b \u044d\u043d\u0435\u0440\u0433\u043e\u043f\u043e\u0442\u0440\u0435\u0431\u043b\u0435\u043d\u0438\u0435 \u043e\u0441\u0442\u0430\u0432\u0430\u043b\u043e\u0441\u044c \u043d\u0438\u0436\u0435 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u0435\u043b\u0430. \u042f \u0441\u043d\u0438\u0437\u0438\u043b power limit \u0434\u043e 250 \u0412\u0442, \u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0443\u043f\u0430\u043b\u0430 \u043d\u0435 \u0442\u0430\u043a \u0441\u0438\u043b\u044c\u043d\u043e, \u043a\u0430\u043a \u044f \u043e\u0436\u0438\u0434\u0430\u043b. \u042f \u0440\u0435\u0448\u0438\u043b \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c, \u043a\u0430\u043a \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043c\u043e\u0449\u043d\u043e\u0441\u0442\u0438 \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435  DL \u0437\u0430\u0434\u0430\u0447\u0438:<\/p>\n<ul>\n<li>\n<p>Training:<\/p>\n<ul>\n<li>\n<p>fp32<\/p>\n<\/li>\n<li>\n<p>tf32<\/p>\n<\/li>\n<li>\n<p>amp fp16<\/p>\n<\/li>\n<li>\n<p>fp16 (.half())<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>Inference:<\/p>\n<ul>\n<li>\n<p>fp32<\/p>\n<\/li>\n<li>\n<p>tf32<\/p>\n<\/li>\n<li>\n<p>amp fp16<\/p>\n<\/li>\n<li>\n<p>fp16 (.half())<\/p>\n<\/li>\n<li>\n<p>TensorRT fp16<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>\u0412\u0441\u0435 \u0442\u0435\u0441\u0442\u044b \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u043b\u0438\u0441\u044c \u043d\u0430 vit_base_patch16_224 \u0438\u0437 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 <a href=\"https:\/\/github.com\/huggingface\/pytorch-image-models\" rel=\"noopener noreferrer nofollow\">timm<\/a>.<\/p>\n<\/p>\n<h2>fp32 training batch_size=160 approx. 20GB of VRAM<\/h2>\n<figure class=\"full-width\"><\/figure>\n<figure class=\"full-width\"><\/figure>\n<p>280 \u0412\u0442 => 80 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432 \u043e\u0442 \u043f\u0438\u043a\u043e\u0432\u043e\u0439 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 (\u043f\u0440\u0438 480\u0412\u0442)<br \/>330 \u0412\u0442 => 90 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432<br \/>380 \u0412\u0442 => 95 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432<\/p>\n<h2>tf32<\/h2>\n<p>\u041d\u0430\u043f\u0438\u0441\u0430\u0432<\/p>\n<pre><code class=\"python\">torch.backends.cuda.matmul.allow_tf32 = True<\/code><\/pre>\n<p>\u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0443\u043a\u0430\u0437\u0430\u0442\u044c pytorch \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0440\u0435\u0436\u0438\u043c \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439 TF32. \u041f\u043e \u0441\u0443\u0442\u0438, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u0436\u0435\u0440\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0447\u0430\u0441\u0442\u044c\u044e \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438 fp32, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0431\u044b\u0441\u0442\u0440\u044b\u0435 \u043c\u0430\u0442\u0440\u0438\u0447\u043d\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438. \u0418\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043d\u0438\u0436\u0435 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442, \u043a\u0430\u043a \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u0438 \u0432\u0437\u044f\u0442\u044b \u0438\u0437 \u0441\u0442\u0430\u0442\u044c\u0438 \u0432<a href=\"https:\/\/developer.nvidia.com\/blog\/accelerating-ai-training-with-tf32-tensor-cores\/\" rel=\"noopener noreferrer nofollow\"> \u0431\u043b\u043e\u0433\u0435<\/a> NVIDIA. \u041e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 TF32 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u044b \u0422\u0435\u043d\u0437\u043e\u0440\u043d\u044b\u043c\u0438 \u044f\u0434\u0440\u0430\u043c\u0438 (Tensor Cores).<\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0444\u043e\u0440\u043c\u0430\u0442\u043e\u0432 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0447\u0438\u0441\u0435\u043b<\/figcaption><\/div>\n<\/figure>\n<figure class=\"full-width\">\n<div><figcaption>\u041e\u043f\u0435\u0440\u0430\u0446\u0438\u044f dot product (\u0441\u043a\u0430\u043b\u044f\u0440\u043d\u043e\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435) \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c TF32<\/figcaption><\/div>\n<\/figure>\n<h2>tf32 training batch_size=160 approx. 20GB of VRAM<\/h2>\n<figure class=\"full-width\"><\/figure>\n<figure class=\"full-width\"><\/figure>\n<p>230 \u0412\u0442 => 80 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432 \u043e\u0442 \u043f\u0438\u043a\u043e\u0432\u043e\u0439 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 (\u043f\u0440\u0438 480\u0412\u0442)<br \/>280 \u0412\u0442 => 90 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432<br \/>320 \u0412\u0442 => 95 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432<br \/>\u041a\u0430\u043a \u043c\u044b \u0432\u0438\u0434\u0438\u043c, \u0442\u0435\u043d\u0437\u043e\u0440\u043d\u044b\u0435 \u044f\u0434\u0440\u0430 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0431\u044b\u0441\u0442\u0440\u0435\u0435, \u043d\u043e \u0438 \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u043e\u043b\u0435\u0435 \u044d\u043d\u0435\u0440\u0433\u043e\u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b.<\/p>\n<h2>amp (fp16)<\/h2>\n<p>\u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>torch.autocast<\/code> \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0443\u043a\u0430\u0437\u0430\u0442\u044c pytorch \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c fp16 \u0432\u043c\u0435\u0441\u0442\u043e fp32 \u0434\u043b\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439. \u0421\u043f\u0438\u0441\u043e\u043a \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c <a href=\"https:\/\/pytorch.org\/docs\/stable\/amp.html#cuda-op-specific-behavior\" rel=\"noopener noreferrer nofollow\">\u0437\u0434\u0435\u0441\u044c<\/a>. \u0418 \u0441\u043d\u043e\u0432\u0430 \u043c\u044b \u043e\u0431\u043c\u0435\u043d\u0438\u0432\u0430\u0435\u043c \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u043d\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c. \u041c\u044b \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a matmul, conv2d, \u0430\u0432\u0442\u043e\u043a\u0430\u0441\u0442\u044f\u0442\u0441\u044f \u0432 fp16, \u043d\u043e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438, \u0442\u0440\u0435\u0431\u0443\u044e\u0449\u0438\u0435 \u0431\u043e\u043b\u044c\u0448\u0435\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a sum, pow, \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u043e\u0442\u0435\u0440\u044c \u0438 \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u0430\u0432\u0442\u043e\u043a\u0430\u0441\u0442\u044f\u0442\u0441\u044f fp32.<br \/>\u0421 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c fp16 \u0435\u0441\u0442\u044c \u043e\u0434\u043d\u0430 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430: \u0438\u043d\u043e\u0433\u0434\u0430 \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u044b \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043a\u043e \u043c\u0430\u043b\u044b, \u0447\u0442\u043e \u043d\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u0432 fp16 \u0438 \u043e\u043a\u0440\u0443\u0433\u043b\u044f\u044e\u0442\u0441\u044f \u0434\u043e \u043d\u0443\u043b\u044f.<br \/>\u043d\u0443\u043b\u0435\u0432\u043e\u0439 \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442 =>\u043d\u0443\u043b\u0435\u0432\u043e\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0432\u0435\u0441\u043e\u0432 => \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u043d\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442.<br \/>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u0443\u043c\u043d\u043e\u0436\u0430\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u043e\u0442\u0435\u0440\u044c \u043d\u0430 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f (\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0446\u0435\u043d\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438), \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0441\u043b\u0435 backward pass \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043d\u0435\u043d\u0443\u043b\u0435\u0432\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u0430.<br \/>\u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u044b \u0434\u043b\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0432\u0435\u0441\u043e\u0432, \u043c\u044b \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0438\u0445 \u0432 fp32 \u0438 \u0443\u0431\u0438\u0440\u0430\u0435\u043c \u0440\u0430\u043d\u0435\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u043d\u043e\u0435 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u0447\u0442\u043e\u0431\u044b \u043e\u043d\u043e \u043d\u0435 \u0432\u043b\u0438\u044f\u043b\u043e \u043d\u0430 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f (\u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u044b \u0443\u043c\u043d\u043e\u0436\u0430\u044e\u0442\u0441\u044f \u043d\u0430 learning rate, \u0438 \u0435\u0441\u043b\u0438 \u043c\u044b \u043d\u0435 \u0443\u0431\u0435\u0440\u0435\u043c \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u0442\u043e \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0439 learning rate \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0433\u043e).<br \/>\u0415\u0441\u043b\u0438 \u0441\u043e\u0431\u043b\u044e\u0434\u0435\u043d\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435 \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u0438, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a \u0432\u0435\u0440\u0441\u0438\u044f cuBLAS\/cuDNN \u0438 \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u0438 \u043c\u0430\u0442\u0440\u0438\u0446, \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0431\u0443\u0434\u0443\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u0442\u0435\u043d\u0437\u043e\u0440\u043d\u044b\u043c\u0438 \u044f\u0434\u0440\u0430\u043c\u0438. \u041a\u0440\u0438\u0442\u0435\u0440\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043d\u0430 <a href=\"https:\/\/developer.download.nvidia.com\/video\/gputechconf\/gtc\/2020\/presentations\/s21929-tensor-core-performance-on-nvidia-gpus-the-ultimate-guide.pdf\" rel=\"noopener noreferrer nofollow\">\u0441\u043b\u0430\u0439\u0434\u0430\u0445<\/a> \u043e\u0442 NVIDIA (\u0441\u0442\u0440. 18-19).<\/p>\n<pre><code class=\"python\">for images, labels in zip(data, targets):     optimizer.zero_grad()     with autocast(device_type='cuda', dtype=torch.float16):         outputs = model.forward(images)         loss = criterion(outputs,labels)      scaler.scale(loss).backward()     scaler.step(optimizer)     scaler.update()<\/code><\/pre>\n<h2>amp (fp16) training batch_size=160 approx. 13GB of VRAM<\/h2>\n<figure class=\"full-width\"><\/figure>\n<figure class=\"full-width\"><\/figure>\n<p>250 \u0412\u0442 => 80 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432 \u043e\u0442 \u043f\u0438\u043a\u043e\u0432\u043e\u0439 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 (\u043f\u0440\u0438 480\u0412\u0442)<br \/>300 \u0412\u0442 => 90 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432<br \/>350 \u0412\u0442 => 95 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432<\/p>\n<p>\u042d\u043d\u0435\u0440\u0433\u043e\u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0445\u0443\u0436\u0435, \u0447\u0435\u043c \u0443 tf32, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u0432 fp32 \u0438 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0442\u0435\u043d\u0437\u043e\u0440\u043d\u044b\u0435 \u044f\u0434\u0440\u0430.<\/p>\n<h2>fp16 (.half())<\/h2>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f <code>.half()<\/code> \u043d\u0430 \u043d\u0430\u0448\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043c\u043e\u0434\u0435\u043b\u0438, \u043c\u044b \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u043c \u0438\u0445 \u0432 fp16. \u042d\u0442\u043e \u0431\u044b\u0441\u0442\u0440\u0435\u0435, \u0447\u0435\u043c amp, \u043d\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u043d\u0435\u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u043c\u0443 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044e \u0438 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u0431\u043e\u043b\u044c\u0448\u043e\u043c\u0443 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 NaN&#8217;\u043e\u0432.<\/p>\n<h2>fp16 (.half()) training batch_size=160 approx. 11GB of VRAM<\/h2>\n<figure class=\"full-width\"><\/figure>\n<figure class=\"full-width\"><\/figure>\n<p>200 \u0412\u0442 => 80 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432 \u043e\u0442 \u043f\u0438\u043a\u043e\u0432\u043e\u0439 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 (\u043f\u0440\u0438 480\u0412\u0442)<br \/>230 \u0412\u0442 => 90 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432<br \/>270 \u0412\u0442 => 95 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432<\/p>\n<p>\u042d\u0442\u043e \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u044d\u043d\u0435\u0440\u0433\u043e\u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435: \u043c\u044b \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c fp32.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c inference.<\/p>\n<h2>fp32 inference batch_size=2048 approx. 21GB of VRAM<\/h2>\n<figure class=\"full-width\"><\/figure>\n<figure class=\"full-width\"><\/figure>\n<p>290 \u0412\u0442 => 80 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432 \u043e\u0442 \u043f\u0438\u043a\u043e\u0432\u043e\u0439 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 (\u043f\u0440\u0438 480\u0412\u0442)<br \/>350 \u0412\u0442 => 90 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432<br \/>390 \u0412\u0442 => 95 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432<\/p>\n<h2>tf32 inference batch_size=2048 approx. 21GB of VRAM<\/h2>\n<figure class=\"full-width\"><\/figure>\n<figure class=\"full-width\"><\/figure>\n<p>250 \u0412\u0442 => 80 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432 \u043e\u0442 \u043f\u0438\u043a\u043e\u0432\u043e\u0439 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 (\u043f\u0440\u0438 480\u0412\u0442)<br \/>300 \u0412\u0442 => 90 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432<br \/>350 \u0412\u0442 => 95 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432<\/p>\n<h2>amp (fp16) inference batch_size=2048 approx. 16GB of VRAM<\/h2>\n<figure class=\"full-width\"><\/figure>\n<figure class=\"full-width\"><\/figure>\n<p>260 \u0412\u0442 => 80 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432 \u043e\u0442 \u043f\u0438\u043a\u043e\u0432\u043e\u0439 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 (\u043f\u0440\u0438 480\u0412\u0442)<br \/>310 \u0412\u0442 => 90 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432<br \/>360 \u0412\u0442 => 95 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432<\/p>\n<h2>fp16 (.half()) inference batch_size=2048 approx. 11GB of VRAM<\/h2>\n<figure class=\"full-width\"><\/figure>\n<figure class=\"full-width\"><\/figure>\n<p>260 \u0412\u0442 =>80 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432 \u043e\u0442 \u043f\u0438\u043a\u043e\u0432\u043e\u0439 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 (\u043f\u0440\u0438 480\u0412\u0442)<br \/>310 \u0412\u0442 => 90 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432<br \/>360 \u0412\u0442 => 95 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432<\/p>\n<h2>TensorRT<\/h2>\n<p>\u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a TensorRT \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0439 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0430\u0448\u0435\u0433\u043e \u0438\u043d\u0444\u0435\u0440\u0435\u043d\u0441\u0430.<br \/>\u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430\u0445 \u043c\u044b \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043d\u0430\u0448\u0443 \u043c\u043e\u0434\u0435\u043b\u044c \u0432 onnx, \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0435\u0433\u043e, \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u043c onnx \u0432 TensorRT \u0438 \u0437\u0430\u0442\u0435\u043c \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u044c TensorRT \u0432 pytorch jit. \u041d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 pytorch \u0441\u0440\u0430\u0437\u0443 \u0432 TensorRT \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0434\u043b\u044f ViT, \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u0432 \u044d\u0442\u043e\u043c <a href=\"https:\/\/github.com\/pytorch\/TensorRT\/issues\/1860\" rel=\"noopener noreferrer nofollow\">issue<\/a>.<\/p>\n<h2>TensorRT fp16 vs pytorch fp16 (.half()) batch_size=512<\/h2>\n<p>Batch size = 512, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043d\u0435 \u0445\u0432\u0430\u0442\u0438\u043b\u043e VRAM \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 TensorRT \u043c\u043e\u0434\u0435\u043b\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0431\u041e\u043b\u044c\u0448\u0438\u0439 \u0431\u0430\u0442\u0447.<\/p>\n<p>.half()<br \/>260 \u0412\u0442 => 82 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u0430 \u043e\u0442 \u043f\u0438\u043a\u043e\u0432\u043e\u0439 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 (\u043f\u0440\u0438 480\u0412\u0442)<br \/>310 \u0412\u0442 => 90 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432<br \/>360 \u0412\u0442 => 95 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432<\/p>\n<p>TensorRT fp16<br \/>290 \u0412\u0442 => 81 \u043f\u0440\u043e\u0446\u0435\u043d\u0442 \u043e\u0442 \u043f\u0438\u043a\u043e\u0432\u043e\u0439 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 (\u043f\u0440\u0438 480\u0412\u0442)<br \/>340 \u0412\u0442 => 90 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432<br \/>390 \u0412\u0442 => 95 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432<\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u0418\u043d\u0444\u0435\u0440\u0435\u043d\u0441. \u0412\u0440\u0435\u043c\u044f \u043d\u0430 1 \u0431\u0430\u0442\u0447<\/figcaption><\/div>\n<\/figure>\n<figure class=\"full-width\">\n<div><figcaption>\u0418\u043d\u0444\u0435\u0440\u0435\u043d\u0441. 100 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u0440\u0435\u0436\u0438\u043c\u043e\u0432 \u0438\u043d\u0434\u0438\u0432\u0438\u0434\u0443\u0430\u043b\u044c\u043d\u043e<\/figcaption><\/div>\n<\/figure>\n<figure class=\"full-width\">\n<div><figcaption>\u0418\u043d\u0444\u0435\u0440\u0435\u043d\u0441. 100 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432 \u044d\u0442\u043e TensorRT fp16<\/figcaption><\/div>\n<\/figure>\n<h3>\u041e\u0431\u0449\u0438\u0435 \u0433\u0440\u0430\u0444\u0438\u043a\u0438<\/h3>\n<figure class=\"full-width\">\n<div><figcaption>\u0418\u043d\u0444\u0435\u0440\u0435\u043d\u0441. 100 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u0440\u0435\u0436\u0438\u043c\u043e\u0432 \u0438\u043d\u0434\u0438\u0432\u0438\u0434\u0443\u0430\u043b\u044c\u043d\u043e<\/figcaption><\/div>\n<\/figure>\n<figure class=\"full-width\">\n<div><figcaption>\u0418\u043d\u0444\u0435\u0440\u0435\u043d\u0441. 100 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432 \u044d\u0442\u043e  fp16 .half()<\/figcaption><\/div>\n<\/figure>\n<figure class=\"full-width\">\n<div><figcaption>Train. 100 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u0440\u0435\u0436\u0438\u043c\u043e\u0432 \u0438\u043d\u0434\u0438\u0432\u0438\u0434\u0443\u0430\u043b\u044c\u043d\u043e<\/figcaption><\/div>\n<\/figure>\n<figure class=\"full-width\">\n<div><figcaption>Train. 100 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432 \u044d\u0442\u043e  fp16 .half()<\/figcaption><\/div>\n<\/figure>\n<h2>\u0412\u044b\u0432\u043e\u0434\u044b<\/h2>\n<p>\u0415\u0441\u043b\u0438 \u0445\u043e\u0442\u0438\u0442\u0435 \u0447\u0442\u043e\u0431\u044b GPU \u043d\u0430\u0433\u0440\u0435\u0432\u0430\u043b\u0441\u044f \u043c\u0435\u043d\u044c\u0448\u0435:<\/p>\n<ul>\n<li>\n<p>\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u0431\u043e\u043b\u0435\u0435 \u043d\u0438\u0437\u043a\u0443\u044e \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c. \u042d\u0442\u043e \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0431\u044b\u0441\u0442\u0440\u0435\u0435, \u043d\u043e \u0438 \u043a\u0440\u0438\u0432\u0430\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c\/\u043c\u043e\u0449\u043d\u043e\u0441\u0442\u044c \u043d\u0430\u0441\u044b\u0449\u0430\u0435\u0442\u0441\u044f \u0431\u044b\u0441\u0442\u0440\u0435\u0435, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043d\u0438\u0437\u0438\u0442\u044c power limit \u0431\u0435\u0437 \u043e\u0441\u043e\u0431\u043e\u0433\u043e \u0443\u0449\u0435\u0440\u0431\u0430 \u0434\u043b\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438.<\/p>\n<\/li>\n<li>\n<p>330-360 \u0412\u0442 &#8212; \u0445\u043e\u0440\u043e\u0448\u0438\u0439 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d \u0434\u043b\u044f power limit. \u041c\u043e\u0436\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u0441\u0442\u043e\u043a\u043e\u0432\u043e\u0433\u043e power limit \u043d\u0435\u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u043d\u043e \u0434\u0430\u0436\u0435 \u0442\u0430\u043a\u043e\u0435 \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u0442\u044c GPU \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0445\u043b\u0430\u0434\u043d\u0435\u0435 (3-5 \u0433\u0440\u0430\u0434\u0443\u0441\u043e\u0432 \u0426\u0435\u043b\u044c\u0441\u0438\u044f) \u0438 \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c RPM \u0432\u0435\u043d\u0442\u0438\u043b\u044f\u0442\u043e\u0440\u043e\u0432.<br \/>\u0412 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u0438\u0440\u043e\u0441\u0442 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0435\u0449\u0435 \u0431\u043e\u043b\u044c\u0448\u0435. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u0435\u0439\u0447\u0430\u0441 \u044f \u0434\u0435\u043b\u0430\u044e \u0438\u043d\u0444\u0435\u0440\u0435\u043d\u0441 DDPM \u043c\u043e\u0434\u0435\u043b\u0438, \u0438 \u0441\u043d\u0438\u0436\u0435\u043d\u0438\u0435 power limit \u0441 390 \u0412\u0442 \u0434\u043e 300 \u0412\u0442 \u0441\u043d\u0438\u0436\u0430\u0435\u0442 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u043b\u0438\u0448\u044c \u043d\u0430 8 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432, \u043f\u0440\u0438\u0447\u0435\u043c \u0443\u0442\u0438\u043b\u0438\u0437\u0430\u0446\u0438\u044f GPU 100%.<\/p>\n<\/li>\n<\/ul>\n<p>\u041a\u043e\u0434 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043d\u0430 <a href=\"https:\/\/github.com\/qwertyforce\/optimal_power_limit_for_dl\" rel=\"noopener noreferrer nofollow\">Github<\/a><\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/785022\/\"> https:\/\/habr.com\/ru\/articles\/785022\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-364751","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/364751","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=364751"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/364751\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=364751"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=364751"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=364751"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}