{"id":3028,"date":"2023-10-29T13:22:27","date_gmt":"2023-10-29T05:22:27","guid":{"rendered":"http:\/\/xinyixx.com\/?p=3028"},"modified":"2023-10-29T13:23:04","modified_gmt":"2023-10-29T05:23:04","slug":"rocm","status":"publish","type":"post","link":"https:\/\/www.xinyixx.com\/index.php\/2023\/10\/29\/rocm\/","title":{"rendered":"\u7b80\u5355\u4ecb\u7ecd\u4e00\u4e0bROCm\u4ee5\u53ca\u5982\u4f55\u90e8\u7f72"},"content":{"rendered":"\n<p>1.ROCm\u4e0b\u8f7d<br>1.1\u4e0b\u8f7d\u5b89\u88c5<br><em><code>\u6ce8\u610f\uff1aROCm\u76ee\u524d\u4ec5\u9650\u5728Linux\u7cfb\u7edf\u4e0b\u53ef\u7528\uff0cWindows\u6682\u4e0d\u652f\u6301<\/code><\/em><\/p>\n\n\n\n<p>\u5b89\u88c5\u6b65\u9aa4\u5982\u4e0b \u5b98\u7f51\u4e0b\u8f7d:amdgpu-install_xxxxxx.xxxxxx_all.deb amd\u5b98\u7f51\u94fe\u63a5: [<a href=\"https:\/\/www.amd.com\/en\/support\/kb\/release-notes\/rn-amdgpu-unified-linux-22-20\" target=\"_blank\" rel=\"noopener\" title=\"\">https:\/\/www.amd.com\/en\/support\/kb\/release-notes\/rn-amdgpu-unified-linux-22-20<\/a>]<\/p>\n\n\n\n<p><code>sudo apt update &amp;&amp; sudo apt upgrade<br>sudo apt install wget gnupg2<br>wget https:\/\/repo.radeon.com\/amdgpu-install\/5.4\/ubuntu\/jammy\/amdgpu-install_5.4.50400-1_all.deb<br>sudo apt install .\/amdgpu-install_5.4.50400-1_all.deb<br>wget https:\/\/repo.radeon.com\/amdgpu-install\/5.4\/ubuntu\/focal\/amdgpu-install_5.4.50400-1_all.deb<br>sudo apt-get install .\/amdgpu-install_5.4.50400-1_all.deb<br>sudo amdgpu-install --usecase=rocm,hip,mllib --no-dkms<br>sudo usermod -a -G video,render $LOGNAME<\/code><\/p>\n\n\n\n<p><br>1.2\u9a8c\u8bc1<\/p>\n\n\n\n<p><code>rocm-smi<br>\/opt\/rocm\/bin\/rocminfo<br>\/opt\/rocm\/opencl\/bin\/clinfo<\/code><\/p>\n\n\n\n<p><br>2.ROCm\u4ecb\u7ecd<br>ROCm\u662fAMD\u7684\u5f00\u6e90GPU\u8ba1\u7b97\u8f6f\u4ef6\u5806\u6808\uff0c\u65e8\u5728\u63d0\u4f9b\u4e00\u4e2a\u53ef\u79fb\u690d\u3001\u9ad8\u6027\u80fd\u7684GPU\u8ba1\u7b97\u5e73\u53f0\u3002ROCm\u652f\u6301AMD\u7684GPU\u548cAPU\uff0c\u4ee5\u53cax86\u548cARM\u67b6\u6784\u7684\u5904\u7406\u5668\uff0c\u63d0\u4f9b\u4e86\u4e0eCUDA\u76f8\u4f3c\u7684\u7f16\u7a0b\u6a21\u578b\uff0c\u4f7f\u5f97\u5728AMD GPU\u4e0a\u7f16\u5199\u548c\u8fd0\u884cGPU\u8ba1\u7b97\u5e94\u7528\u7a0b\u5e8f\u53d8\u5f97\u66f4\u52a0\u5bb9\u6613\u3002<\/p>\n\n\n\n<p>ROCm\u7684\u4e3b\u8981\u7ec4\u6210\u90e8\u5206\u5305\u62ec\uff1a<\/p>\n\n\n\n<p>ROCm\u9a71\u52a8\u7a0b\u5e8f\uff1a\u7528\u4e8e\u7ba1\u7406AMD GPU\u548cAPU\u7684\u786c\u4ef6\u8d44\u6e90\uff0c\u63d0\u4f9bGPU\u8ba1\u7b97\u6240\u9700\u7684\u57fa\u672c\u529f\u80fd\u3002<\/p>\n\n\n\n<p>ROCm\u7f16\u8bd1\u5668\uff1a\u5305\u62ecAMD\u7684HIP\u7f16\u8bd1\u5668\u548cHCC\u7f16\u8bd1\u5668\uff0c\u7528\u4e8e\u5c06HIP\u548cC++ AMP\u4ee3\u7801\u7f16\u8bd1\u4e3a\u5e95\u5c42GPU\u6307\u4ee4\u3002<\/p>\n\n\n\n<p>ROCm\u8fd0\u884c\u65f6\u5e93\uff1a\u5305\u62ecAMD\u7684HIP\u8fd0\u884c\u65f6\u5e93\u548cHCC\u8fd0\u884c\u65f6\u5e93\uff0c\u63d0\u4f9bGPU\u8ba1\u7b97\u6240\u9700\u7684\u6838\u5fc3\u529f\u80fd\uff0c\u5982\u5185\u5b58\u7ba1\u7406\u3001\u7ebf\u7a0b\u8c03\u5ea6\u3001\u5e76\u53d1\u63a7\u5236\u7b49\u3002<\/p>\n\n\n\n<p>ROCm\u5de5\u5177\u96c6\uff1a\u5305\u62ecAMD\u7684GPU\u8c03\u8bd5\u5668\u3001\u6027\u80fd\u5206\u6790\u5668\u3001\u4ee3\u7801\u4f18\u5316\u5de5\u5177\u7b49\uff0c\u7528\u4e8e\u5e2e\u52a9\u5f00\u53d1\u4eba\u5458\u8c03\u8bd5\u548c\u4f18\u5316GPU\u8ba1\u7b97\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n\n\n\n<p>ROCm\u7684\u76ee\u6807\u662f\u6210\u4e3a\u4e00\u4e2a\u5168\u9762\u7684GPU\u8ba1\u7b97\u5e73\u53f0\uff0c\u652f\u6301\u5404\u79cd\u7f16\u7a0b\u8bed\u8a00\u548c\u5e94\u7528\u573a\u666f\u3002\u5b83\u5df2\u7ecf\u5f97\u5230\u4e86\u5e7f\u6cdb\u7684\u5e94\u7528\uff0c\u5c24\u5176\u662f\u5728\u6df1\u5ea6\u5b66\u4e60\u3001\u79d1\u5b66\u8ba1\u7b97\u548c\u5927\u6570\u636e\u5206\u6790\u7b49\u9886\u57df\u3002<\/p>\n\n\n\n<p>ROCm\u662fAMD\u7684\u4e00\u4e2a\u8f6f\u4ef6\u5e73\u53f0\uff0c\u7528\u6765\u52a0\u901fGPU\u8ba1\u7b97<br>A\u5361\u4e0a\u7f16\u7a0b\u6a21\u578b\u4f7f\u7528\u7684\u662fHIP\u6216\u8005OpenCL\uff0c\u800c\u8fd0\u884c\u73af\u5883\u662fROCm<br>N\u5361\u4e0a\uff0c\u7f16\u7a0b\u6a21\u578b\u662fCUDA\uff0c\u8fd0\u884c\u73af\u5883\u4e5f\u662fCUDA<br>Important features include the following<br>rocFFT\uff1a\u5feb\u901f\u5085\u91cc\u53f6\u53d8\u6362\u5e93\uff0c\u7528\u4e8e\u52a0\u901f\u9891\u57df\u8ba1\u7b97\u4efb\u52a1\u3002<br>rocBLAS\uff1a\u57fa\u672c\u7ebf\u6027\u4ee3\u6570\u5b50\u7a0b\u5e8f\u5e93\uff0c\u7528\u4e8e\u52a0\u901f\u77e9\u9635\u8ba1\u7b97\u4efb\u52a1\u3002<br>rocRAND\uff1a\u968f\u673a\u6570\u751f\u6210\u5e93\uff0c\u7528\u4e8e\u751f\u6210\u968f\u673a\u6570\u5e8f\u5217\u3002<br>rocSPARSE\uff1a\u7a00\u758f\u77e9\u9635\u8ba1\u7b97\u5e93\uff0c\u7528\u4e8e\u52a0\u901f\u7a00\u758f\u77e9\u9635\u8ba1\u7b97\u4efb\u52a1\u3002<\/p>\n\n\n\n<p>3.HIP<br>HIP\uff08Heterogeneous-Compute Interface for Portability\uff09\u662fAMD\u5f00\u53d1\u7684\u4e00\u79cdGPU\u7f16\u7a0b\u6a21\u578b\uff0c\u65e8\u5728\u5b9e\u73b0GPU\u4ee3\u7801\u7684\u53ef\u79fb\u690d\u6027\u3002HIP\u63d0\u4f9b\u4e86\u4e00\u7ec4C++\u7c7b\u548c\u51fd\u6570\uff0c\u5141\u8bb8\u5f00\u53d1\u4eba\u5458\u5728AMD\u548cNVIDIA GPU\u4e0a\u7f16\u5199\u53ef\u79fb\u690d\u7684\u4ee3\u7801\u3002HIP\u7684\u7f16\u7a0b\u6a21\u578b\u4e0eCUDA\u76f8\u4f3c\uff0c\u4f46\u662f\u5b83\u662f\u4e00\u4e2a\u5f00\u653e\u7684\u6807\u51c6\uff0c\u4e0d\u4f9d\u8d56\u4e8e\u4efb\u4f55\u7279\u5b9a\u7684GPU\u5382\u5546\u3002<\/p>\n\n\n\n<p>HIP\u662f\u4e00\u79cd\u7f16\u7a0b\u6a21\u578b\uff0c\u5bf9\u6807CUDA\u7f16\u7a0b\u6a21\u578b\u3002<br>HIP \u53ef\u4ee5\u8bf4\u662f CUDA API \u7684\u201d\u5c71\u5be8\u514b\u9686\u201c\u7248\u3002\u9664\u4e86\u4e00\u4e9b\u4e0d\u5e38\u7528\u7684\u529f\u80fd\uff08e.g. managed memory\uff09\u5916\uff0c\u51e0\u4e4e\u5168\u76d8\u62f7\u8d1d CUDA API\uff0c\u662f CUDA \u7684\u4e00\u4e2a\u5b50\u96c6\u3002<br>HIP is a C++ runtime API \u3002\u6211\u4eec\u4f7f\u7528C++\u8bed\u8a00\uff0c\u53ef\u4ee5\u8c03\u7528HIP\u7684API\u6765\u8fdb\u884c\u7f16\u7a0b\u3002<br>HIP\u53ef\u4ee5\u8fd0\u884c\u5728ROCm\u5e73\u53f0\uff0c\u4e5f\u53ef\u4ee5\u8fd0\u884c\u5728CUDA\u5e73\u53f0\u3002<br>\u6240\u4ee5\u4ed6\u53ef\u4ee5\u8fd0\u884c\u5728A\u5361\uff0c\u4f46\u662f\u4e5f\u53ef\u4ee5\u8fd0\u884c\u5728N\u5361\u4e0a\uff08N\u5361\u4e3b\u8981\u8fd8\u662fCUDA\uff09 \u3002<br>HIP \u7684API\u548cCUDA\u975e\u5e38\u7c7b\u4f3c\uff0c\u5927\u591a\u6570\u60c5\u51b5\u4e0b\u4ed6\u4eec\u4ee3\u7801\u7a0d\u52a0\u4fee\u6539\u5c31\u53ef\u4ee5\u76f4\u63a5\u8f6c\u6362\u3002<\/p>\n\n\n\n<p>3.1.CUDA\u8f6cHIP<br>HIP\u63d0\u4f9b\u4e86\u79fb\u690d\u5de5\u5177 \u201chipify\u201d\uff0c\u53ef\u4ee5\u5e2e\u52a9\u4f60\u5c06cuda\u6e90\u4ee3\u7801\u8f6c\u6362\u6210HIP\u3002\u867d\u7136HIP\u548cCUDA\u5177\u6709\u76f8\u4f3c\u7684\u7f16\u7a0b\u6a21\u578b\uff0c\u4f46\u662f\u5b83\u4eec\u5728\u4e00\u4e9b\u7ec6\u8282\u4e0a\u6709\u6240\u4e0d\u540c\uff0c\u56e0\u6b64\u8f6c\u6362\u540e\u7684\u4ee3\u7801\u53ef\u80fd\u9700\u8981\u8fdb\u884c\u4e00\u4e9b\u624b\u52a8\u8c03\u6574\u548c\u4fee\u6539\uff0c\u4ee5\u786e\u4fdd\u5176\u5728AMD GPU\u4e0a\u80fd\u591f\u6b63\u786e\u8fd0\u884c\u3002<br>\u6b64\u5916\uff0c\u7531\u4e8eAMD\u548cNVIDIA GPU\u5177\u6709\u4e0d\u540c\u7684\u67b6\u6784\u548c\u6307\u4ee4\u96c6\uff0c\u56e0\u6b64\u5728\u4e0d\u540c\u7684GPU\u4e0a\u8fd0\u884cHIP\u548cCUDA\u5e94\u7528\u7a0b\u5e8f\u65f6\uff0c\u6027\u80fd\u53ef\u80fd\u4f1a\u6709\u6240\u5dee\u5f02\u3002\u56e0\u6b64\uff0c\u5728\u5c06CUDA\u5e94\u7528\u7a0b\u5e8f\u79fb\u690d\u5230AMD GPU\u4e0a\u65f6\uff0c\u9700\u8981\u8fdb\u884c\u4e00\u4e9b\u6027\u80fd\u6d4b\u8bd5\u548c\u4f18\u5316\uff0c\u4ee5\u786e\u4fdd\u5176\u5728AMD GPU\u4e0a\u80fd\u591f\u83b7\u5f97\u6700\u4f73\u6027\u80fd\u3002<\/p>\n\n\n\n<p>\u94fe\u63a5: <a href=\"https:\/\/www.anandtech.com\/show\/9792\/amd-sc15-boltzmann-initiative-announced-c-and-cuda-compilers-for-amd-gpus.\" target=\"_blank\" rel=\"noopener\" title=\"\">https:\/\/www.anandtech.com\/show\/9792\/amd-sc15-boltzmann-initiative-announced-c-and-cuda-compilers-for-amd-gpus<\/a><\/p>\n\n\n\n<p>cuda\u4ee3\u7801a\u5361\u5b9e\u73b0<\/p>\n\n\n\n<p>3.2 HIPify<br>\u94fe\u63a5: [<a href=\"https:\/\/docs.amd.com\/bundle\/HIPify-Reference-Guide-v5.4\/page\/HIPify.html\" target=\"_blank\" rel=\"noopener\" title=\"\">https:\/\/docs.amd.com\/bundle\/HIPify-Reference-Guide-v5.4\/page\/HIPify.html<\/a>]<\/p>\n\n\n\n<p>HIPify\u662fAMD ROCm\u8f6f\u4ef6\u5806\u6808\u7684\u6838\u5fc3\u7ec4\u4ef6\u4e4b\u4e00\uff0c\u4e5f\u88ab\u8bb8\u591a\u5176\u4ed6GPU\u8f6f\u4ef6\u5806\u6808\u6240\u652f\u6301\u3002\u5b83\u4f7f\u5f97\u5c06\u73b0\u6709\u7684CUDA\u4ee3\u7801\u79fb\u690d\u5230AMD GPU\u4e0a\u53d8\u5f97\u66f4\u52a0\u5bb9\u6613\uff0c\u4ece\u800c\u52a0\u901f\u5e94\u7528\u7a0b\u5e8f\u7684\u5f00\u53d1\u548c\u90e8\u7f72\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1.ROCm\u4e0b\u8f7d1.1\u4e0b\u8f7d\u5b89\u88c5\u6ce8\u610f\uff1aROCm\u76ee\u524d\u4ec5\u9650\u5728Linux\u7cfb\u7edf\u4e0b\u53ef\u7528\uff0cWindows\u6682\u4e0d\u652f\u6301 \u5b89\u88c5\u6b65\u9aa4\u5982 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":"","footnotes":""},"categories":[1],"tags":[],"class_list":["post-3028","post","type-post","status-publish","format-standard","hentry","category-other","entry"],"_links":{"self":[{"href":"https:\/\/www.xinyixx.com\/index.php\/wp-json\/wp\/v2\/posts\/3028","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xinyixx.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xinyixx.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xinyixx.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xinyixx.com\/index.php\/wp-json\/wp\/v2\/comments?post=3028"}],"version-history":[{"count":0,"href":"https:\/\/www.xinyixx.com\/index.php\/wp-json\/wp\/v2\/posts\/3028\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.xinyixx.com\/index.php\/wp-json\/wp\/v2\/media?parent=3028"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xinyixx.com\/index.php\/wp-json\/wp\/v2\/categories?post=3028"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xinyixx.com\/index.php\/wp-json\/wp\/v2\/tags?post=3028"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}