﻿{"id":1930,"date":"2022-08-08T13:39:06","date_gmt":"2022-08-08T13:39:06","guid":{"rendered":"http:\/\/81.70.49.155\/?p=1930"},"modified":"2023-01-12T10:12:08","modified_gmt":"2023-01-12T10:12:08","slug":"%e5%8c%97%e4%ba%ac%e5%b9%b6%e8%a1%8c%e7%a7%91%e6%8a%80gpu-cuda-fortran%e8%ae%a1%e7%ae%97%e5%b9%b3%e5%8f%b0%e9%85%8d%e7%bd%ae","status":"publish","type":"post","link":"http:\/\/81.70.49.155\/?p=1930","title":{"rendered":"\u5317\u4eac\u5e76\u884c\u79d1\u6280GPU-CUDA Fortran\u8ba1\u7b97\u5e73\u53f0\u914d\u7f6e"},"content":{"rendered":"<h3>\n\t\u542f\u7528MPI OpenMP<br \/>\n<\/h3>\n<h3>\n\tmodule load nvhpc\/nvhpc\/21.7_cuda11.0_openmpi4.0.5_gcc7.5_qd<br \/>\n<\/h3>\n<h3>\n\t<br \/>\n<\/h3>\n<h3>\n\t\u8c03\u7528ifort \u7f16\u8bd1\u5668<br \/>\n<\/h3>\n<h3>\n\t<b><span style=\"background-color:#00D5FF;\">&nbsp;module load intel\/parallelstudio\/2017.1.5<\/span><\/b><br \/>\n<\/h3>\n<h3>\n\t<b><br \/>\n<\/b><br \/>\n<\/h3>\n<h3>\n\t<b>Step1 <\/b><b>\u62a2\u5360\u4e00\u4e2a<\/b><b>GPU<\/b><b>\u8ba1\u7b97\u8282\u70b9<\/b><br \/>\n<\/h3>\n<p class=\"MsoNormal\">\n\t<b><\/b>\n<\/p>\n<p class=\"MsoNormal\">\n\t<span style=\"background-color:#00D5FF;\">[scv1172@ln01 xyqtest2022]$ salloc --gpus=1<\/span>\n<\/p>\n<p class=\"MsoNormal\">\n\tsalloc:Pending job allocation 308347\n<\/p>\n<p class=\"MsoNormal\">\n\tsalloc:job 308347 queued and waiting for resources\n<\/p>\n<p class=\"MsoNormal\">\n\tsalloc:job 308347 has been allocated resources\n<\/p>\n<p class=\"MsoNormal\">\n\tsalloc:Granted job allocation 308347\n<\/p>\n<p class=\"MsoNormal\">\n\tsalloc:Waiting for resource configuration\n<\/p>\n<p class=\"MsoNormal\">\n\tsalloc:Nodes g0001 are ready for job&nbsp; (\u627e\u5230\u7684\u8ba1\u7b97\u8282\u70b9\u4e3ag0001)\n<\/p>\n<p class=\"MsoNormal\">\n\t&nbsp;\n<\/p>\n<h3>\n\t<b>Step2 <\/b><b>\u7528<\/b><b>ssh<\/b><b>\u547d\u4ee4\u52a0\u8f7d\u627e\u5230\u7684\u8282\u70b9<\/b><b> <span>g0001<\/span><\/b><br \/>\n<\/h3>\n<p class=\"MsoNormal\">\n\t<span style=\"background-color:#00D5FF;\">[scv1172@ln01 xyqtest2022]$ ssh g0001<\/span>\n<\/p>\n<p class=\"MsoNormal\">\n\tWarning:Permanently added 'g0001,192.168.11.1' (ECDSA) to the list of known hosts.\n<\/p>\n<p class=\"MsoNormal\">\n\t[scv1172@g0001 ~]$\n<\/p>\n<p class=\"MsoNormal\">\n\t\u4ee5\u4e0a\u7ed3\u679c\u8868\u660e\u52a0\u8f7dg0001\u8282\u70b9\u6210\u529f\n<\/p>\n<p class=\"MsoNormal\">\n\t&nbsp;\n<\/p>\n<h3>\n\t<b>Step3 <\/b><b>\u67e5\u8be2<\/b><b>NVHPC<\/b><b>\uff1a\u7528<\/b><b> <span>module ava<\/span><\/b><b>\u547d\u4ee4\u67e5\u627e<\/b><b> <\/b><b>\u662f\u5426\u5b89\u88c5<\/b><b>nvhpc<\/b><b>\uff0c\u4ee5\u53ca\u7248\u672c<\/b><br \/>\n<\/h3>\n<p class=\"MsoNormal\">\n\t<span style=\"background-color:#00D5FF;\">[scv1172@g0001 ~]$ module ava nvhpc<\/span>\n<\/p>\n<p class=\"MsoNormal\">\n\t-------------------<br \/>\n\/data\/apps\/modulefiles --------------------------\n<\/p>\n<p class=\"MsoNormal\">\n\tnvhpc\/nvhpc\/20.7_cuda10.1_openmpi3.1.5\n<\/p>\n<p class=\"MsoNormal\">\n\tnvhpc\/nvhpc\/20.7_cuda10.2_openmpi3.1.5\n<\/p>\n<p class=\"MsoNormal\">\n\tnvhpc\/nvhpc\/21.7_cuda11.0_openmpi4.0.5_gcc7.5_qd\n<\/p>\n<p class=\"MsoNormal\">\n\tnvhpc\/nvhpc_byo_compiler\/20.7_cuda10.1\n<\/p>\n<p class=\"MsoNormal\">\n\tnvhpc\/nvhpc_byo_compiler\/20.7_cuda10.2\n<\/p>\n<p class=\"MsoNormal\">\n\tnvhpc\/nvhpc_byo_compiler\/21.7_cuda11.0_gcc7.5\n<\/p>\n<p class=\"MsoNormal\">\n\tnvhpc\/nvhpc_nompi\/20.7_cuda10.1\n<\/p>\n<p class=\"MsoNormal\">\n\tnvhpc\/nvhpc_nompi\/20.7_cuda10.2\n<\/p>\n<p class=\"MsoNormal\">\n\tnvhpc\/nvhpc_nompi\/21.7_cuda11.0_gcc7.5_qd\n<\/p>\n<p class=\"MsoNormal\">\n\t&nbsp;\n<\/p>\n<h3>\n\t<b>Step 4 <\/b><b>\u7528<\/b><b>module load<\/b><b>\u52a0\u8f7d\u76f8\u5e94\u7248\u672c\u7684<\/b><b>nvhpc<\/b><br \/>\n<\/h3>\n<p class=\"MsoNormal\">\n\t<span style=\"background-color:#00D5FF;\">[scv1172@g0001 ~]$ module load nvhpc\/nvhpc_nompi\/21.7_cuda11.0_gcc7.5_qd<\/span>\n<\/p>\n<p class=\"MsoNormal\">\n\t&nbsp;\n<\/p>\n<h3>\n\t<b>Step 5 <\/b><b>\u7528<\/b><b>which<\/b><b>\u547d\u4ee4\u68c0\u67e5<\/b><b>nvhpc<\/b><b>\u7684\u52a0\u8f7d\u662f\u5426\u6210\u529f<\/b><br \/>\n<\/h3>\n<p class=\"MsoNormal\">\n\t<span style=\"background-color:#00D5FF;\">[scv1172@g0001 xyqtest2022]$ which nvfortran<\/span>\n<\/p>\n<p class=\"MsoNormal\">\n\t\/data\/apps\/nvhpc\/nvhpc_21.7\/Linux_x86_64\/21.7\/compilers\/bin\/nvfortran\n<\/p>\n<p class=\"MsoNormal\">\n\t[scv1172@g0001<br \/>\nxyqtest2022]$\n<\/p>\n<p class=\"MsoNormal\">\n\t\u4ee5\u4e0a\u7ed3\u679c\u8868\u660e\u76f8\u5e94\u7248\u672c\u7684nvhpc\u52a0\u8f7d\u6210\u529f\n<\/p>\n<p class=\"MsoNormal\">\n\t\u5229\u7528\u4ee5\u4e0a5\u6b65\u5219\u53ef\u4ee5\u5bf9Cuda-GPU\u7684\u8ba1\u7b97\u8282\u70b9\u8fdb\u6027\u914d\u7f6e\n<\/p>\n<p class=\"MsoNormal\">\n\t\n<\/p>\n<h3>\n\t<span style=\"background-color:#E53333;\">~~~~~~\u6d4b\u8bd5\u4ee3\u7801(\u547d\u540d\u4e3atest.cuf)~~~~~~~~~~~~<\/span><br \/>\n<\/h3>\n<p class=\"MsoNormal\">\n\tprogram deviceQuery<br \/>\n&nbsp;use cudafor<br \/>\n&nbsp;type (cudaDeviceProp) :: prop<br \/>\n&nbsp;integer :: nDevices=0, i, ierr<br \/>\n&nbsp;! Number of CUDA -capable devices<br \/>\nierr = cudaGetDeviceCount(nDevices)<br \/>\n&nbsp;if (nDevices == 0) then<br \/>\nwrite(*,\"(\/,'No CUDA devices found ',\/)\")<br \/>\n&nbsp;stop<br \/>\n&nbsp;else if (nDevices == 1) then<br \/>\n&nbsp;write(*,\"(\/,'One CUDA device found ',\/)\")<br \/>\n&nbsp;else<br \/>\n&nbsp;write(*,\"(\/,i0,' CUDA devices found ',\/)\") nDevices<br \/>\n&nbsp;end if<\/p>\n<p>! Loop over devices<br \/>\n&nbsp;do i = 0, nDevices -1<br \/>\n&nbsp;write(*,\"('Device Number: ',i0)\") i<br \/>\n&nbsp;ierr = cudaGetDeviceProperties(prop , i)<br \/>\n&nbsp;! General device info<br \/>\n&nbsp;write(*,\"(' Device Name: ',a)\") trim(prop%name)<br \/>\n&nbsp;write(*,\"(' Compute Capability: ',i0,'.',i0)\") &amp;<br \/>\n&nbsp;prop%major , prop%minor<br \/>\n&nbsp;write(*,\"(' Number of Multiprocessors: ',i0)\") &amp;<br \/>\n&nbsp;prop%multiProcessorCount<br \/>\nwrite(*,\"(' Max Threads per Multiprocessor: ',i0)\") &amp;<br \/>\n&nbsp;prop%maxThreadsPerMultiprocessor<br \/>\n&nbsp;write(*,\"(' Global Memory (GB): ',f9.3,\/)\") &amp;<br \/>\n&nbsp;prop%totalGlobalMem \/1024.0**3<\/p>\n<p>&nbsp;! Execution Configuration<br \/>\n&nbsp;write(*,\"(' Execution Configuration Limits ')\")<br \/>\n&nbsp;write(*,\"(' Max Grid Dims: ',2(i0,' x '),i0)\") &amp;<br \/>\n&nbsp;prop%maxGridSize<br \/>\n&nbsp;write(*,\"(' Max Block Dims: ',2(i0,' x '),i0)\") &amp;<br \/>\n&nbsp;prop%maxThreadsDim<br \/>\n&nbsp;write(*,\"(' Max Threads per Block: ',i0 ,\/)\") &amp;<br \/>\n&nbsp;prop%maxThreadsPerBlock<br \/>\n&nbsp;enddo<br \/>\nend program deviceQuery\n<\/p>\n<p>\n\t\n<\/p>\n<h3>\n\t<span style=\"background-color:#E53333;\">~~~~~~~~~~~~~\u7f16\u8bd1\u8fd0\u884c~~~~~~~~~~~~~~~~~<\/span><br \/>\n<\/h3>\n<p>\n\t\n<\/p>\n<p class=\"MsoNormal\">\n\t<span style=\"background-color:#00D5FF;\">&nbsp;<\/span><span style=\"background-color:#00D5FF;\">[scv1172@g0001 xyqtest2022]$ nvfortran *.cuf -o ou<\/span><span style=\"background-color:#00D5FF;\">t<\/span>\n<\/p>\n<p class=\"MsoNormal\">\n\t<span style=\"background-color:#00D5FF;\">&nbsp;<\/span><span style=\"background-color:#00D5FF;\">[scv1172@g0001 xyqtest2022]$ .\/out<\/span><br \/>\nOne CUDA device found&nbsp;<br \/>\nDevice Number: 0<br \/>\n&nbsp;Device Name: Tesla V100-SXM2-32GB<br \/>\n&nbsp;Compute Capability: 7.0<br \/>\n&nbsp;Number of Multiprocessors: 80<br \/>\n&nbsp;Max Threads per Multiprocessor: 2048<br \/>\n&nbsp;Global Memory (GB):&nbsp; &nbsp; 31.749<br \/>\n&nbsp;Execution Configuration Limits&nbsp;<br \/>\n&nbsp;Max Grid Dims: 2147483647 x 65535 x 65535<br \/>\n&nbsp;Max Block Dims: 1024 x 1024 x 64<br \/>\n&nbsp;Max Threads per Block: 1024\n<\/p>\n<p>\n\t<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u542f\u7528MPI OpenMP module load nvhpc\/nvhpc\/21.7_cuda11.0_open &hellip; <a href=\"http:\/\/81.70.49.155\/?p=1930\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u201c\u5317\u4eac\u5e76\u884c\u79d1\u6280GPU-CUDA Fortran\u8ba1\u7b97\u5e73\u53f0\u914d\u7f6e\u201d<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[],"views":1449,"_links":{"self":[{"href":"http:\/\/81.70.49.155\/index.php?rest_route=\/wp\/v2\/posts\/1930"}],"collection":[{"href":"http:\/\/81.70.49.155\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/81.70.49.155\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/81.70.49.155\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/81.70.49.155\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1930"}],"version-history":[{"count":6,"href":"http:\/\/81.70.49.155\/index.php?rest_route=\/wp\/v2\/posts\/1930\/revisions"}],"predecessor-version":[{"id":1963,"href":"http:\/\/81.70.49.155\/index.php?rest_route=\/wp\/v2\/posts\/1930\/revisions\/1963"}],"wp:attachment":[{"href":"http:\/\/81.70.49.155\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1930"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/81.70.49.155\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1930"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/81.70.49.155\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1930"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}