How to install CUDA on Ubuntu 20.04 Focal Fossa Linux

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

How to install CUDA toolkit from CUDA repository · In case you have not done so yet, make sure that you have installed the Nvdia driver for your ... Skiptocontent Menu Ubuntu Ubuntu20.04Guide Ubuntu18.04 Debian Redhat/CentOS/AlmaLinux Fedora KaliLinux ThepurposeofthistutorialistoshowtoinstallCUDAonUbuntu20.04FocalFossaLinux. TheNvidiaCUDAtoolkitisanextensionoftheGPUparallelcomputingplatformandprogrammingmodel.TheNvidiaCUDAinstallationconsistsofinclusionoftheofficialNvidiaCUDArepositoryfollowedbytheinstallationofrelevantmetapackageandconfiguringpaththetheexecutableCUDAbinaries. Inthistutorialyouwilllearn: HowtoinstallCUDAtoolkitfromUbuntuRepository HowtoinstallCUDAtoolkitfromCUDArepository HowtocompileexampleCUDACcodeandexecuteprogram HowtoCheckCUDAversion   CUDAonUbuntu20.04FocalFossaLinux SoftwareRequirementsandConventionsUsed SoftwareRequirementsandLinuxCommandLineConventions Category Requirements,ConventionsorSoftwareVersionUsed System InstalledUbuntu20.04orupgradedUbuntu20.04FocalFossa Software CUDA Other PrivilegedaccesstoyourLinuxsystemasrootorviathesudocommand. Conventions #–requiresgivenlinuxcommandstobeexecutedwithrootprivilegeseitherdirectlyasarootuserorbyuseofsudocommand $–requiresgivenlinuxcommandstobeexecutedasaregularnon-privilegeduser HowtoinstallCUDAonUbuntu20.04stepbystepinstructions HowtoinstallCUDAtoolkitfromUbuntuRepository AlthoughyoumightnotendupwiththelatestCUDAtoolkitversion,theeasiestwaytoinstallCUDAonUbuntu20.04istoperformtheinstallationfromUbuntu’sstandardrepositories. ToinstallCUDAexecutethefollowingcommands: $sudoaptupdate $sudoaptinstallnvidia-cuda-toolkit Allshouldbereadynow.CheckyourCUDAversion: $nvcc--version nvcc:NVIDIA(R)Cudacompilerdriver Copyright(c)2005-2019NVIDIACorporation BuiltonSun_Jul_28_19:07:16_PDT_2019 Cudacompilationtools,release10.1,V10.1.243 NOTE ToinstalllatestandmoreuptodateCUDAversionseebelowHowtoinstallCUDAtoolkitfromCUDArepositorysection. ConfirmtheCUDAtoolkitinstallationbysampleCUDACcodecompilation.SeethebellowCompileaSampleCUDAcodesection. HowtoinstallCUDAtoolkitfromCUDArepository Incaseyouhavenotdonesoyet,makesurethatyouhaveinstalledtheNvdiadriverforyourVGA.TodosofollowourguideonHowtoinstalltheNVIDIAdriversonUbuntu20.04FocalFossaLinux. SetupNvidaCUDArepository.ExecutethefollowingcommandstoenableCUDArepository. $sudowget-O/etc/apt/preferences.d/cuda-repository-pin-600https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-ubuntu2004.pin $sudoapt-keyadv--fetch-keyshttps://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/7fa2af80.pub $sudoadd-apt-repository"debhttp://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64//" AtthisstageallshouldbereadytoinstallCUDA.Executethetwofollowingaptcommands: $sudoaptupdate $sudoaptinstallcuda Onceready,setyourpathtopointtoCUDAbinaries: $echo'exportPATH=/usr/local/cuda/bin${PATH:+:${PATH}}'>>~/.bashrc CheckCUDAversiontoconfirmtheinstallation: $nvcc--version nvcc:NVIDIA(R)Cudacompilerdriver Copyright(c)2005-2019NVIDIACorporation BuiltonWed_Oct_23_19:24:38_PDT_2019 Cudacompilationtools,release10.2,V10.2.89 CompileaSampleCUDAcode ConfirmtheinstallationbycompilinganexampleCUDACcode.Savethefollowingcodeintoafilenamedeg.hello.cu: #include __global__ voidsaxpy(intn,floata,float*x,float*y) { inti=blockIdx.x*blockDim.x+threadIdx.x; if(i>>(N,2.0f,d_x,d_y); cudaMemcpy(y,d_y,N*sizeof(float),cudaMemcpyDeviceToHost); floatmaxError=0.0f; for(inti=0;i



請為這篇文章評分?