This is the second part of CUDA-GPU tuning series where I’ll explain how to install CUDA Toolkit 10.1 on Ubuntu 18.04 LTS.
In the first part I’ve described how to properly install nVidia drivers on Ubuntu 18.04 LTS
Detailed instructions can be found on any of these two pages:
https://www.josip-pojatina.com/en/how-to-install-nvidia-driver-on-ubuntu-18-04-lts/
or
https://www.performatune.com/en/how-to-install-nvidia-driver-on-ubuntu-18-04-lts/
Although you can find more info about CUDA Toolkit installation at the following page:
https://docs.nvidia.com/cuda/cuda-installation-guide-linux/
there are a few important steps that are not mentioned there.
For that reason I want to further clarify installation process.
------------------------------------------------------------------------------------------------------------------------------------------------
#Check Ubuntu version:
user@hostname:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.2 LTS
Release: 18.04
Codename: bionic
------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------
#Determine Graphics card model
user@hostname:~$ lspci | grep -e VGA
00:02.0 VGA compatible controller: Intel Corporation HD Graphics P630 (rev 04)
01:00.0 VGA compatible controller: NVIDIA Corporation GM206GLM [Quadro M2200 Mobile] (rev a1)
#you can also use
user@hostname:~>nvidia-smi
------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------
#Alternatively you can execute the following steps
root@hostname:/home/user/Downloads# ubuntu-drivers devices
== /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0 ==
modalias : pci:v000010DEd00001436sv0000103Csd00008275bc03sc00i00
vendor : NVIDIA Corporation
model : GM206GLM [Quadro M2200 Mobile]
driver : nvidia-driver-390 - distro non-free recommended
driver : xserver-xorg-video-nouveau - distro free builtin
ubuntu-drivers autoinstall
------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------
#Nouveau disabling (open source graphical drivers)
root@hostname:/etc/modprobe.d# bash -c "echo blacklist nouveau > /etc/modprobe.d/blacklist-nvidia-nouveau.conf"
root@hostname:/etc/modprobe.d# bash -c "echo options nouveau modeset=0 >> /etc/modprobe.d/blacklist-nvidia-nouveau.conf"
root@hostname:/etc/modprobe.d# cat /etc/modprobe.d/blacklist-nvidia-nouveau.conf
blacklist nouveau
options nouveau modeset=0
------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------
#Wayland disabling
loginctl
user@hostname:~>loginctl
SESSION UID USER SEAT TTY
3 0 root pts/0
c1 121 gdm seat0 tty1
2 1000 jpext seat0 tty2
user@hostname:~>loginctl show-session 2 -p Type
Type=x11
root@hostname:~# vi /etc/gdm3/custom.conf
# Uncoment the line below to force the login screen to use Xorg
#WaylandEnable=false ---------> WaylandEnable=false
------------------------------------------------------------------------------------------------------------------------------------------------
#Verify You Have a Supported Version of Linux
uname -m && cat /etc/*release
root@hostname:/etc/apt/sources.list.d>uname -m && cat /etc/*release
x86_64
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.2 LTS"
NAME="Ubuntu"
VERSION="18.04.2 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.2 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic
#Verify the System Has gcc Installed
user@hostname:~$ gcc --version
gcc (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#Verify the System has the Correct Kernel Headers and Development Packages Installed
user@hostname:~$ uname -r
4.15.0-29-generic
#The kernel headers and development packages for the currently running kernel can be installed with:
root@hostname:~>apt-get install linux-headers-$(uname -r)
Reading package lists... Done
Building dependency tree
Reading state information... Done
linux-headers-4.15.0-29-generic is already the newest version (4.15.0-29.31).
0 upgraded, 0 newly installed, 0 to remove and 14 not upgraded.
#Choose an Installation Method
The CUDA Toolkit can be installed using either of two different installation mechanisms: distribution-specific packages (RPM and Deb packages), or a distribution-independent package (runfile packages).
The distribution-independent package has the advantage of working across a wider set of Linux distributions, but does not update the distribution's native package management system.
The distribution-specific packages interface with the distribution's native package management system. It is recommended to use the distribution-specific packages, where possible.
--> deb
#Download the NVIDIA CUDA Toolkit
http://developer.nvidia.com/cuda-downloads
https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&target_distro=Ubuntu&target_version=1804&target_type=deblocal
Download Verification
https://developer.download.nvidia.com/compute/cuda/10.1/Prod/docs/sidebar/md5sum.txt
8d1b233120c0d05ff6f6d5e37906faf5 cuda-repo-ubuntu1804-10-1-local-10.1.105-418.39_1.0-1_amd64.deb
$ md5sum <file>
user@hostname:~/Downloads>md5sum cuda-repo-ubuntu1804-10-1-local-10.1.105-418.39_1.0-1_amd64.deb
8d1b233120c0d05ff6f6d5e37906faf5 cuda-repo-ubuntu1804-10-1-local-10.1.105-418.39_1.0-1_amd64.deb
#Package Manager Installation
#Ubuntu
#Perform the pre-installation actions.
#Install repository meta-data
$ sudo dpkg -i cuda-repo-<distro>_<version>_<architecture>.deb
#Installing the CUDA public GPG key
When installing using the local repo:
$ sudo apt-key add /var/cuda-repo-<version>/7fa2af80.pub
#Update the Apt repository cache
$ sudo apt-get update
#Install CUDA
sudo apt-get install cuda
user@hostname:~/Downloads>sudo dpkg -i cuda-repo-ubuntu1804-10-1-local-10.1.105-418.39_1.0-1_amd64.deb
[sudo] password for user:
Selecting previously unselected package cuda-repo-ubuntu1804-10-1-local-10.1.105-418.39.
(Reading database ... 135800 files and directories currently installed.)
Preparing to unpack cuda-repo-ubuntu1804-10-1-local-10.1.105-418.39_1.0-1_amd64.deb ...
Unpacking cuda-repo-ubuntu1804-10-1-local-10.1.105-418.39 (1.0-1) ...
Setting up cuda-repo-ubuntu1804-10-1-local-10.1.105-418.39 (1.0-1) ...
The public CUDA GPG key does not appear to be installed.
To install the key, run this command:
sudo apt-key add /var/cuda-repo-10-1-local-10.1.105-418.39/7fa2af80.pub
user@hostname:~/Downloads>sudo apt-key add /var/cuda-repo-10-1-local-10.1.105-418.39/7fa2af80.pub
OK
user@hostname:~/Downloads>sudo apt-get update
Get:1 file:/var/cuda-repo-10-1-local-10.1.105-418.39 InRelease
Ign:1 file:/var/cuda-repo-10-1-local-10.1.105-418.39 InRelease
Get:2 file:/var/cuda-repo-10-1-local-10.1.105-418.39 Release [574 B]
Get:2 file:/var/cuda-repo-10-1-local-10.1.105-418.39 Release [574 B]
Get:3 file:/var/cuda-repo-10-1-local-10.1.105-418.39 Release.gpg [833 B]
Get:3 file:/var/cuda-repo-10-1-local-10.1.105-418.39 Release.gpg [833 B]
Get:4 file:/var/cuda-repo-10-1-local-10.1.105-418.39 Packages [24,0 kB]
Get:5 http://security.ubuntu.com/ubuntu bionic-security InRelease [88,7 kB]
Hit:6 http://hr.archive.ubuntu.com/ubuntu bionic InRelease
Hit:7 http://ppa.launchpad.net/linuxuprising/java/ubuntu bionic InRelease
Get:8 http://hr.archive.ubuntu.com/ubuntu bionic-updates InRelease [88,7 kB]
Get:9 http://hr.archive.ubuntu.com/ubuntu bionic-backports InRelease [74,6 kB]
Get:10 http://hr.archive.ubuntu.com/ubuntu bionic-updates/main amd64 DEP-11 Metadata [278 kB]
Get:11 http://security.ubuntu.com/ubuntu bionic-security/main amd64 DEP-11 Metadata [204 B]
Get:12 http://hr.archive.ubuntu.com/ubuntu bionic-updates/main DEP-11 48x48 Icons [66,6 kB]
Get:13 http://hr.archive.ubuntu.com/ubuntu bionic-updates/main DEP-11 64x64 Icons [123 kB]
Get:14 http://security.ubuntu.com/ubuntu bionic-security/universe amd64 DEP-11 Metadata [20,8 kB]
Get:15 http://security.ubuntu.com/ubuntu bionic-security/universe DEP-11 48x48 Icons [12,2 kB]
Get:16 http://security.ubuntu.com/ubuntu bionic-security/universe DEP-11 64x64 Icons [50,1 kB]
Get:17 http://hr.archive.ubuntu.com/ubuntu bionic-updates/universe amd64 DEP-11 Metadata [202 kB]
Get:18 http://security.ubuntu.com/ubuntu bionic-security/multiverse amd64 DEP-11 Metadata [2 464 B]
Get:19 http://hr.archive.ubuntu.com/ubuntu bionic-updates/universe DEP-11 48x48 Icons [190 kB]
Get:20 http://hr.archive.ubuntu.com/ubuntu bionic-updates/universe DEP-11 64x64 Icons [346 kB]
Get:21 http://hr.archive.ubuntu.com/ubuntu bionic-updates/multiverse amd64 DEP-11 Metadata [2 464 B]
Get:22 http://hr.archive.ubuntu.com/ubuntu bionic-backports/universe amd64 Packages [3 468 B]
Get:23 http://hr.archive.ubuntu.com/ubuntu bionic-backports/universe i386 Packages [3 460 B]
Get:24 http://hr.archive.ubuntu.com/ubuntu bionic-backports/universe amd64 DEP-11 Metadata [7 352 B]
Fetched 1 560 kB in 1s (1 177 kB/s)
Reading package lists... Done
user@hostname:~/Downloads>sudo apt-get install cuda
...
*** LICENSE AGREEMENT ***
By using this software you agree to fully comply with the terms and
conditions of the EULA (End User License Agreement). The EULA is located
at /usr/local/cuda-10.1/doc/EULA.txt. The EULA can also be found at
http://docs.nvidia.com/cuda/eula/index.html. If you do not agree to the
terms and conditions of the EULA, do not use the software.
...
A modprobe blacklist file has been created at /etc/modprobe.d to prevent Nouveau
from loading. This can be reverted by deleting the following file:
/etc/modprobe.d/nvidia-graphics-drivers.conf
A new initrd image has also been created. To revert, please regenerate your
initrd by running the following command after deleting the modprobe.d file:
`/usr/sbin/initramfs -u`
*****************************************************************************
*** Reboot your computer and verify that the NVIDIA graphics driver can ***
*** be loaded. ***
*****************************************************************************
...
nvidia:
Running module version sanity check.
- Original module
- No original module exists within this kernel
- Installation
- Installing to /lib/modules/4.15.0-29-generic/updates/dkms/
nvidia-modeset.ko:
Running module version sanity check.
- Original module
- No original module exists within this kernel
- Installation
- Installing to /lib/modules/4.15.0-29-generic/updates/dkms/
nvidia-drm.ko:
Running module version sanity check.
- Original module
- No original module exists within this kernel
- Installation
- Installing to /lib/modules/4.15.0-29-generic/updates/dkms/
nvidia-uvm.ko:
Running module version sanity check.
- Original module
- No original module exists within this kernel
- Installation
- Installing to /lib/modules/4.15.0-29-generic/updates/dkms/
depmod...
DKMS: install completed.
...
#Post-installation Actions
#Mandatory Actions
#Environment Setup
The PATH variable needs to include /usr/local/cuda-10.1/bin and /usr/local/cuda-10.1/NsightCompute-<tool-version>. <tool-version> refers to the version of Nsight Compute that ships with the CUDA toolkit, e.g. 2019.1.
To add this path to the PATH variable:
$ export PATH=/usr/local/cuda-10.1/bin:/usr/local/cuda-10.1/NsightCompute-2019.1${PATH:+:${PATH}}
#Recommended Actions
#Install Persistence Daemon
user@hostname:~/Downloads/NVIDIA_CUDA-10.1_Samples>/usr/bin/nvidia-persistenced --verbose
nvidia-persistenced failed to initialize. Check syslog for more details.
#Install Writable Samples
$ cuda-install-samples-10.1.sh <dir>
user@hostname:~/Downloads>cuda-install-samples-10.1.sh /home/user/Downloads/
Copying samples to /home/jpext/Downloads/NVIDIA_CUDA-10.1_Samples now...
Finished copying samples.
drwxrwxr-x 12 jpext jpext 4096 ožu 11 09:38 NVIDIA_CUDA-10.1_Samples
#Verify the Installation
#Verify the Driver Version
user@hostname:~/Downloads>cat /proc/driver/nvidia/version
NVRM version: NVIDIA UNIX x86_64 Kernel Module 390.116 Sun Jan 27 07:21:36 PST 2019
GCC version: gcc version 7.3.0 (Ubuntu 7.3.0-27ubuntu1~18.04)
#Compiling the Examples
user@hostname:~/Downloads/NVIDIA_CUDA-10.1_Samples>nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2019 NVIDIA Corporation
Built on Fri_Feb__8_19:08:17_PST_2019
Cuda compilation tools, release 10.1, V10.1.105
user@hostname:~/Downloads/NVIDIA_CUDA-10.1_Samples>make
make[1]: Entering directory '/home/jpext/Downloads/NVIDIA_CUDA-10.1_Samples/0_Simple/simpleAssert_nvrtc'
g++ -I../../common/inc -I/usr/local/cuda-10.1/include -o simpleAssert.o -c simpleAssert.cpp
g++ -o simpleAssert_nvrtc simpleAssert.o -L/usr/local/cuda-10.1/lib64/stubs -lcuda -lnvrtc
mkdir -p ../../bin/x86_64/linux/release
cp simpleAssert_nvrtc ../../bin/x86_64/linux/release
make[1]: Leaving directory '/home/jpext/Downloads/NVIDIA_CUDA-10.1_Samples/0_Simple/simpleAssert_nvrtc'
make[1]: Entering directory '/home/jpext/Downloads/NVIDIA_CUDA-10.1_Samples/0_Simple/clock_nvrtc'
g++ -I../../common/inc -I/usr/local/cuda-10.1/include -o clock.o -c clock.cpp
g++ -o clock_nvrtc clock.o -L/usr/local/cuda-10.1/lib64/stubs -lcuda -lnvrtc
mkdir -p ../../bin/x86_64/linux/release
cp clock_nvrtc ../../bin/x86_64/linux/release
make[1]: Leaving directory '/home/jpext/Downloads/NVIDIA_CUDA-10.1_Samples/0_Simple/clock_nvrtc'
make[1]: Entering directory '/home/jpext/Downloads/NVIDIA_CUDA-10.1_Samples/0_Simple/simpleTexture'
/usr/local/cuda-10.1/bin/nvcc -ccbin g++ -I../../common/inc -m64 -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35 -gencode arch=compute_37,code=sm_37 -gencode arch=compute_50,code=sm_50 -gencode arch=compute_52,code=sm_52 -gencode arch=compute_60,code=sm_60 -gencode arch=compute_61,code=sm_61 -gencode arch=compute_70,code=sm_70 -gencode arch=compute_75,code=sm_75 -gencode arch=compute_75,code=compute_75 -o simpleTexture.o -c simpleTexture.cu
simpleTexture.cu: In function ‘void runTest(int, char**)’:
simpleTexture.cu:178:75: warning: ‘cudaError_t cudaMemcpyToArray(cudaArray_t, size_t, size_t, const void*, size_t, cudaMemcpyKind)’ is deprecated [-Wdeprecated-declarations]
checkCudaErrors(cudaMemcpyToArray(cuArray,
... ^
make[1]: Leaving directory '/home/jpext/Downloads/NVIDIA_CUDA-10.1_Samples/7_CUDALibraries/boxFilterNPP'
Finished building CUDA samples
#Running the Binaries
user@hostname:~>cd Downloads/NVIDIA_CUDA-10.1_Samples/bin/x86_64/linux/release/
user@hostname:~/Downloads/NVIDIA_CUDA-10.1_Samples/bin/x86_64/linux/release>deviceQuery
user@hostname:~/Downloads/NVIDIA_CUDA-10.1_Samples/bin/x86_64/linux/release>deviceQuery
deviceQuery Starting...
CUDA Device Query (Runtime API) version (CUDART static linking)
cudaGetDeviceCount returned 100
-> no CUDA-capable device is detected
Result = FAIL
#After adding LD_LIBRARY_PATH & Vulkan drivers & reboot
user@hostname:~>vi .profile
export PATH=/usr/local/cuda-10.1/bin:/usr/local/cuda-10.1/NsightCompute-2019.1:.:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-10.1/lib64:$LD_LIBRARY_PATH
Terminal --> Profiles --> Command --> Enable "Run command as a login shell"
user@hostname:~/Downloads/NVIDIA_CUDA-10.1_Samples/bin/x86_64/linux/release>deviceQuery
deviceQuery Starting...
CUDA Device Query (Runtime API) version (CUDART static linking)
Detected 1 CUDA Capable device(s)
Device 0: "Quadro M2200"
CUDA Driver Version / Runtime Version 10.1 / 10.1
CUDA Capability Major/Minor version number: 5.2
Total amount of global memory: 4044 MBytes (4240179200 bytes)
( 8) Multiprocessors, (128) CUDA Cores/MP: 1024 CUDA Cores
GPU Max Clock rate: 1036 MHz (1.04 GHz)
Memory Clock rate: 2754 Mhz
Memory Bus Width: 128-bit
L2 Cache Size: 1048576 bytes
Maximum Texture Dimension Size (x,y,z) 1D=(65536), 2D=(65536, 65536), 3D=(4096, 4096, 4096)
Maximum Layered 1D Texture Size, (num) layers 1D=(16384), 2048 layers
Maximum Layered 2D Texture Size, (num) layers 2D=(16384, 16384), 2048 layers
Total amount of constant memory: 65536 bytes
Total amount of shared memory per block: 49152 bytes
Total number of registers available per block: 65536
Warp size: 32
Maximum number of threads per multiprocessor: 2048
Maximum number of threads per block: 1024
Max dimension size of a thread block (x,y,z): (1024, 1024, 64)
Max dimension size of a grid size (x,y,z): (2147483647, 65535, 65535)
Maximum memory pitch: 2147483647 bytes
Texture alignment: 512 bytes
Concurrent copy and kernel execution: Yes with 2 copy engine(s)
Run time limit on kernels: Yes
Integrated GPU sharing Host Memory: No
Support host page-locked memory mapping: Yes
Alignment requirement for Surfaces: Yes
Device has ECC support: Disabled
Device supports Unified Addressing (UVA): Yes
Device supports Compute Preemption: No
Supports Cooperative Kernel Launch: No
Supports MultiDevice Co-op Kernel Launch: No
Device PCI Domain ID / Bus ID / location ID: 0 / 1 / 0
Compute Mode:
< Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >
deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 10.1, CUDA Runtime Version = 10.1, NumDevs = 1
Result = PASS
#Installing Vulkan
root@hostname:~>apt install libvulkan1 mesa-vulkan-drivers vulkan-utils
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
libbsd0:i386 libdrm-amdgpu1:i386 libdrm-intel1:i386 libdrm-nouveau2:i386 libdrm-radeon1:i386 libdrm2:i386 libedit2:i386 libelf1:i386 libexpat1:i386 libffi6:i386 libgl1:i386 libgl1-mesa-dri:i386 libglapi-mesa:i386 libglvnd0:i386 libglx-mesa0:i386 libglx0:i386
libllvm7:i386 libnvidia-common-390 libpciaccess0:i386 libsensors4:i386 libstdc++6:i386 libwayland-client0:i386 libwayland-server0:i386 libx11-6:i386 libx11-xcb1:i386 libxau6:i386 libxcb-dri2-0:i386 libxcb-dri3-0:i386 libxcb-glx0:i386 libxcb-present0:i386
libxcb-sync1:i386 libxcb1:i386 libxdamage1:i386 libxdmcp6:i386 libxext6:i386 libxfixes3:i386 libxshmfence1:i386 libxxf86vm1:i386
Use 'apt autoremove' to remove them.
The following NEW packages will be installed:
libvulkan1 mesa-vulkan-drivers vulkan-utils
0 upgraded, 3 newly installed, 0 to remove and 15 not upgraded.
Need to get 1 569 kB of archives.
After this operation, 6 692 kB of additional disk space will be used.
Get:1 http://hr.archive.ubuntu.com/ubuntu bionic-updates/universe amd64 libvulkan1 amd64 1.1.70+dfsg1-1ubuntu0.18.04.1 [93,4 kB]
Get:2 http://hr.archive.ubuntu.com/ubuntu bionic-updates/universe amd64 mesa-vulkan-drivers amd64 18.2.2-0ubuntu1~18.04.2 [1 387 kB]
Get:3 http://hr.archive.ubuntu.com/ubuntu bionic-updates/universe amd64 vulkan-utils amd64 1.1.70+dfsg1-1ubuntu0.18.04.1 [88,7 kB]
Fetched 1 569 kB in 1s (1 837 kB/s)
Selecting previously unselected package libvulkan1:amd64.
(Reading database ... 150232 files and directories currently installed.)
Preparing to unpack .../libvulkan1_1.1.70+dfsg1-1ubuntu0.18.04.1_amd64.deb ...
Unpacking libvulkan1:amd64 (1.1.70+dfsg1-1ubuntu0.18.04.1) ...
Selecting previously unselected package mesa-vulkan-drivers:amd64.
Preparing to unpack .../mesa-vulkan-drivers_18.2.2-0ubuntu1~18.04.2_amd64.deb ...
Unpacking mesa-vulkan-drivers:amd64 (18.2.2-0ubuntu1~18.04.2) ...
Selecting previously unselected package vulkan-utils.
Preparing to unpack .../vulkan-utils_1.1.70+dfsg1-1ubuntu0.18.04.1_amd64.deb ...
Unpacking vulkan-utils (1.1.70+dfsg1-1ubuntu0.18.04.1) ...
Setting up libvulkan1:amd64 (1.1.70+dfsg1-1ubuntu0.18.04.1) ...
Setting up mesa-vulkan-drivers:amd64 (18.2.2-0ubuntu1~18.04.2) ...
Setting up vulkan-utils (1.1.70+dfsg1-1ubuntu0.18.04.1) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
In the next article I’ll describe how you can get all details from your nVidia graphical card that I’ll use to optimize CUDA GPU operations.
Comments