How to install CUDA on Ubuntu 20.04 Focal Fossa Linux
文章推薦指數: 80 %
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
延伸文章資訊
- 1Installation Guide Windows :: CUDA Toolkit Documentation
- 2Win10 安裝CUDA、cuDNN 教學. 上一篇有介紹如何 ... - Medium
上一篇有介紹如何在Ubuntu 安裝CUDA、cuDNN,本篇將要來介紹Win10 的CUDA、cuDNN 安裝教學. 安裝流程分為以下步驟,作業系統使用Windows 10.
- 3Start Locally | PyTorch
- 4CUDA Compatibility :: NVIDIA Data Center GPU Driver Documentation
- 5GPU 支援
GPU 支援 · 這個頁面中的內容 · Pip 套件. 舊版TensorFlow · 硬體需求 · 軟體需求 · Linux 設定. 使用apt 安裝CUDA · Windows 設定.