How to Check CUDA Version Easily - VarHowto

文章推薦指數: 80 %
投票人數:10人

Perhaps the easiest way to check a file. Run cat /usr/local/cuda/version.txt · Another method is through the cuda-toolkit package command nvcc . LogInRegisterSearchSkiptothecontentCloseMenuROSShowsubmenuROSNoeticInstallROSMelodicSeeAll⟶Self-HostedExploreShowsubmenuLinuxRaspberryPiNginxPythonWordPressLaTexBibTexAllCategories⟶🙋ForumsShowsubmenu🙋AskAnything💡TodayILearnedForumIndex→TwitterVarHowtopageonFacebookHereyouwilllearnhowtocheckNVIDIACUDAversionin3ways:nvccfromCUDAtoolkit,nvidia-smifromNVIDIAdriver,andsimplycheckingafile.Usingoneofthesemethods,youwillbeabletoseetheCUDAversionregardlessthesoftwareyouareusing,suchasPyTorch,TensorFlow,conda(Miniconda/Anaconda)orinsidedocker.LinuxContentsPrerequisiteWhatisCUDA?Method1—UsenvcctocheckCUDAversionWhatisnvcc?Method2—CheckCUDAversionbynvidia-smifromNVIDIALinuxdriverWhatisnvidia-smi?Method3—cat/usr/local/cuda/version.txt3waystocheckCUDAversion🙋AskauthorinForum💬Leaveareply+9PrerequisiteYoushouldhaveNVIDIAdriverinstalledonyoursystem,aswellasNvidiaCUDAtoolkit,aka,CUDA,beforewestart.Ifyouhaven’t,youcaninstallitbyrunningsudoaptinstallnvidia-cuda-toolkit.WhatisCUDA?CUDAisageneralparallelcomputingarchitectureandprogrammingmodeldevelopedbyNVIDIAforitsgraphicscards(GPUs).UsingCUDA,PyTorchorTensorFlowdeveloperswilldramaticallyincreasetheperformanceofPyTorchorTensorFlowtrainingmodels,utilizingGPUresourceseffectively.InGPU-acceleratedtechnology,thesequentialportionofthetaskrunsontheCPUforoptimizedsingle-threadedperformance,whilethecomputed-intensivesegment,likePyTorchtechnology,runsparallelviaCUDAatthousandsofGPUcores.WhenusingCUDA,developerscanwriteafewbasickeywordsincommonlanguagessuchasC,C++,Python,andimplementparallelism.Method1—UsenvcctocheckCUDAversionIfyouhaveinstalledthecuda-toolkitsoftwareeitherfromtheofficialUbunturepositoriesviasudoaptinstallnvidia-cuda-toolkit,orbydownloadingandinstallingitmanuallyfromtheofficialNVIDIAwebsite,youwillhavenvccinyourpath(tryecho$PATH)anditslocationwillbe/usr/bin/nvcc(by runningwhich nvcc).TocheckCUDAversionwithnvcc,runnvcc--versionYoucanseesimilaroutputinthescreenshotbelow.ThelastlineshowsyouversionofCUDA.Theversionhereis10.1.Yours mayvary,andcanbeeither10.0,10.1, 10.2orevenolderversionssuchas9.0,9.1and9.2.Afterthescreenshotyouwillfindthefulltextoutputtoo.vh@varhowto-com:~$nvcc--version nvcc:NVIDIA(R)Cudacompilerdriver Copyright(c)2005-2019NVIDIACorporation BuiltonSun_Jul_28_19:07:16_PDT_2019 Cudacompilationtools,release10.1,V10.1.243Whatisnvcc?nvccistheNVIDIACUDACompiler,thusthename.ItisthekeywrapperfortheCUDAcompilersuite.Forotherusageofnvcc,youcanuseittocompileandlinkbothhostandGPUcode.Checkoutnvcc‘smanpageformoreinformation.Method2—CheckCUDAversionbynvidia-smifromNVIDIALinuxdriverThesecondwaytocheckCUDAversionistorunnvidia-smi,whichcomesfromdownloadingtheNVIDIAdriver,specificallytheNVIDIA-utilspackage.YoucaninstalleitherNvidiadriverfromtheofficialrepositoriesofUbuntu,orfromtheNVIDIAwebsite.$whichnvidia-smi /usr/bin/nvidia-smi $dpkg-S/usr/bin/nvidia-smi nvidia-utils-440:/usr/bin/nvidia-smiTocheckCUDAversionwithnvidia-smi,directlyrunnvidia-smiYoucanseesimilaroutputin thescreenshotbelow.Theversionisatthetoprightoftheoutput.Here’smyversionisCUDA10.2.Youmayhave10.0,10.1oreventheolderversion9.0or9.1or9.2 installed.Importantly,exceptforCUDAversion.Therearemore detailsinthenvidia-smioutput, driverversion(440.100),GPUname,GPUfanpercentage,powerconsumption/capability,memoryusage,canalsobefoundhere.YoucanalsofindtheprocesseswhichusetheGPUatthe moment.Thisishelpfulifyouwanttoseeifyourmodelorsystemis usingGPUsuchas PyTorchorTensorFlow.Hereisthefulltextoutput:vh@varhowto-com:~$nvidia-smi TueJul0710:07:262020 +-----------------------------------------------------------------------------+ |NVIDIA-SMI440.100DriverVersion:440.100CUDAVersion:10.2| |-------------------------------+----------------------+----------------------+ |GPUNamePersistence-M|Bus-IdDisp.A|VolatileUncorr.ECC| |FanTempPerfPwr:Usage/Cap|Memory-Usage|GPU-UtilComputeM.| |===============================+======================+======================| |0GeForceGTX1070Off|00000000:01:00.0On|N/A| |31%48CP035W/151W|2807MiB/8116MiB|1%Default| +-------------------------------+----------------------+----------------------+ +-----------------------------------------------------------------------------+ |Processes:GPUMemory| |GPUPIDTypeProcessnameUsage| |=============================================================================| |01582G/usr/lib/xorg/Xorg262MiB| |02481G/usr/lib/xorg/Xorg1646MiB| |02686G/usr/bin/gnome-shell563MiB| |03244G…AAAAAAAAAAAACAAAAAAAAAA=--shared-files319MiB| +-----------------------------------------------------------------------------+Whatisnvidia-smi?nvidia-smi(NVSMI)isNVIDIASystemManagementInterfaceprogram.ItisalsoknownasNVSMI.nvidia-smiprovidesmonitoringandmaintenancecapabilitiesforalloftjeFermi’sTesla,Quadro,GRIDandGeForceNVIDIAGPUs andhigherarchitecturefamilies.Formostfunctions,GeForceTitanSeriesproductsaresupportedwithonlylittledetailgivenfortherestoftheGeforcerange.NVSMIisalsoacross-platformapplicationthatsupportsbothcommonNVIDIAdriver-supportedLinuxdistrosand64-bitversionsofWindowsstartingwithWindowsServer2008R2.Metricsmaybeuseddirectlybyusersviastdout,orstoredviaCSVandXMLformatsforscriptingpurposes.Formoreinformation,checkoutthemanpageofnvidia-smi.Method3—cat/usr/local/cuda/version.txtcat/usr/local/cuda/version.txtNotethatifyouinstallNvidiadriverandCUDAfromUbuntu20.04’sownofficialrepositorythisapproachmaynotwork.3waystocheckCUDAversionTimeNeeded:5minutesTherearebasicallythreewaystocheckCUDAversion.Onemustworkifnottheother.PerhapstheeasiestwaytocheckafileRuncat/usr/local/cuda/version.txtNote:thismaynotworkonUbuntu20.04Anothermethodisthroughthecuda-toolkitpackagecommandnvcc.Simplerunnvcc--version.Thecudaversionisinthelastlineoftheoutput.TheotherwayisfromtheNVIDIAdriver'snvidia-smicommandyouhaveinstalled.Simplyrunnvidia-smi.Theversionisintheheaderofthetableprinted.Toolsnvccnvidia-smiMaterialsUbuntuRelated+9TweetByVarHowtoEditorWelcometoVarHowto!ProfilePosts2replieson“HowtoCheckCUDAVersionEasily”[…]PyTorchversionhigherthan1.7.1shouldalsowork.Forexample,ifyouuseLinuxandCUDA11(howtocheckCUDAversion),installPyTorchbythefollowing[…]0[…]PyTorchversionhigherthan1.7.1shouldalsowork.Forexample,ifyouuseLinuxandCUDA11(howtocheckCUDAversion),installPyTorchbythefollowing[…]0LeaveaReplyCancelreplyYouremailaddresswillnotbepublished.Requiredfieldsaremarked*CommentMarkdownissupported(e.g.,`code`)LearnMoreName*Email*Savemyname,email,andwebsiteinthisbrowserforthenexttimeIcomment.Notifymeoffollow-upcommentsbyemail.Notifymeofnewpostsbyemail.VarHowtousesAkismettoreducespam.Learnhowyourcommentdataisprocessed.ΔHomeAboutVarHowtoPrivacyPolicyContactUsTwitterVarHowtopageonFacebookSubscribetoVarHowtoYou'llreceiveemailsofnewposts.EmailAddressSubscribe



請為這篇文章評分?