Sunday 29 January 2017

How to install NVIDIA CUDA on Ubuntu

CUDA is NVIDIA's parallel computing framework which allows code to be executed on NVIDIA GPUs.


In this article I am going to go over CUDA installation steps one by one, with detailed output for the reference. I am using Ubuntu 16.04.

Can I use CUDA on my machine?


We have to find out whether graphic card is CUDA-compatible. Let's first retrieve the name of the graphic card. We can use lspci tool for that:


$ lspci | grep VGA
01:00.0 VGA compatible controller: NVIDIA Corporation GK107 [GeForce GT 640 OEM] (rev a1)



Then we have to check whether the graphic card is listed among CUDA-compatible GPUs

GeForce GT 640 is on the list so we are ready to go.

How to install CUDA?


To be able to harvest the power of CUDA-enabled GPU we have to install CUDA Toolkit. On its download page we have to choose a platform and the architecture of the target system. We are on Linux and we can determine architecture like here:


$ uname -m
x86_64



CUDA Download page:


Now, at the time of writing, toolkit's version is 8.0. I decided to use Debian (.deb) installer which comes as a cuda-repo-ubuntu1604-8-0-local_8.0.44-1_amd64.deb file (~1.8GB). Once file is downloaded, we can install it:


$ sudo dpkg -i cuda-repo-ubuntu1604-8-0-local_8.0.44-1_amd64.deb

[sudo] password for bojan:
(Reading database ... 230085 files and directories currently installed.)
Preparing to unpack cuda-repo-ubuntu1604-8-0-local_8.0.44-1_amd64.deb ...
Unpacking cuda-repo-ubuntu1604-8-0-local (8.0.44-1) over (8.0.34-1) ...
Setting up cuda-repo-ubuntu1604-8-0-local (8.0.44-1) ...
OK




$ sudo apt-get update

Get:1 file:/var/cuda-repo-8-0-local InRelease
Ign:1 file:/var/cuda-repo-8-0-local InRelease
Get:2 file:/var/libopencv4tegra-repo InRelease
Ign:2 file:/var/libopencv4tegra-repo InRelease
Get:3 file:/var/visionworks-repo InRelease
Ign:3 file:/var/visionworks-repo InRelease
Get:4 file:/var/visionworks-sfm-repo InRelease
Ign:4 file:/var/visionworks-sfm-repo InRelease
Get:5 file:/var/visionworks-tracking-repo InRelease
Ign:5 file:/var/visionworks-tracking-repo InRelease
Get:6 file:/var/cuda-repo-8-0-local Release [574 B]
Get:6 file:/var/cuda-repo-8-0-local Release [574 B]
Get:7 file:/var/libopencv4tegra-repo Release [347 B]
Get:7 file:/var/libopencv4tegra-repo Release [347 B]
Get:8 file:/var/visionworks-repo Release [698 B]
Get:8 file:/var/visionworks-repo Release [698 B]
Get:9 file:/var/visionworks-sfm-repo Release [702 B]
Get:9 file:/var/visionworks-sfm-repo Release [702 B]
Get:10 file:/var/visionworks-tracking-repo Release [707 B]
Get:10 file:/var/visionworks-tracking-repo Release [707 B]
Get:11 file:/var/cuda-repo-8-0-local Release.gpg [819 B]
Get:11 file:/var/cuda-repo-8-0-local Release.gpg [819 B]
Hit:15 http://gb.archive.ubuntu.com/ubuntu xenial InRelease
Get:16 http://gb.archive.ubuntu.com/ubuntu xenial-updates InRelease [102 kB]
Get:18 file:/var/cuda-repo-8-0-local Packages [22.7 kB]
Get:19 http://security.ubuntu.com/ubuntu xenial-security InRelease [102 kB]
Get:20 http://gb.archive.ubuntu.com/ubuntu xenial-backports InRelease [102 kB]
Get:21 http://gb.archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages [459 kB]
Get:22 http://gb.archive.ubuntu.com/ubuntu xenial-updates/main i386 Packages [451 kB]
Get:23 http://gb.archive.ubuntu.com/ubuntu xenial-updates/universe amd64 Packages [387 kB]
Ign:24 http://dl.google.com/linux/chrome/deb stable InRelease
Hit:25 http://dl.google.com/linux/chrome/deb stable Release
Get:27 http://gb.archive.ubuntu.com/ubuntu xenial-updates/universe i386 Packages [382 kB]
Get:28 http://gb.archive.ubuntu.com/ubuntu xenial-updates/multiverse amd64 Packages [8,080 B]
Get:29 http://gb.archive.ubuntu.com/ubuntu xenial-updates/multiverse i386 Packages [6,876 B]
Fetched 2,000 kB in 8s (245 kB/s)
Reading package lists... Done
W: Invalid 'Date' entry in Release file /var/lib/apt/lists/_var_libopencv4tegra-repo_Release
W: Invalid 'Date' entry in Release file /var/lib/apt/lists/_var_visionworks-repo_Release
W: Invalid 'Date' entry in Release file /var/lib/apt/lists/_var_visionworks-sfm-repo_Release
W: Invalid 'Date' entry in Release file /var/lib/apt/lists/_var_visionworks-tracking-repo_Release
W: Invalid 'Date' entry in Release file /var/lib/apt/lists/partial/_var_cuda-repo-8-0-local_Release




$ sudo apt-get install cuda

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
bbswitch-dkms cuda-8-0 cuda-command-line-tools-8-0 cuda-core-8-0 cuda-cublas-8-0 cuda-cublas-dev-8-0 cuda-cudart-8-0 cuda-cudart-dev-8-0 cuda-cufft-8-0 cuda-cufft-dev-8-0 cuda-curand-8-0
cuda-curand-dev-8-0 cuda-cusolver-8-0 cuda-cusolver-dev-8-0 cuda-cusparse-8-0 cuda-cusparse-dev-8-0 cuda-demo-suite-8-0 cuda-documentation-8-0 cuda-driver-dev-8-0 cuda-drivers cuda-license-8-0
cuda-misc-headers-8-0 cuda-npp-8-0 cuda-npp-dev-8-0 cuda-nvgraph-8-0 cuda-nvgraph-dev-8-0 cuda-nvml-dev-8-0 cuda-nvrtc-8-0 cuda-nvrtc-dev-8-0 cuda-runtime-8-0 cuda-samples-8-0 cuda-toolkit-8-0
cuda-visual-tools-8-0 dkms lib32gcc1 libc6-i386 libcuda1-367 libjansson4 libxnvctrl0 nvidia-367 nvidia-367-dev nvidia-modprobe nvidia-opencl-icd-367 nvidia-prime nvidia-settings ocl-icd-libopencl1
screen-resolution-extra
Suggested packages:
bumblebee
The following NEW packages will be installed
bbswitch-dkms cuda cuda-8-0 cuda-demo-suite-8-0 cuda-drivers cuda-runtime-8-0 dkms lib32gcc1 libc6-i386 libcuda1-367 libjansson4 libxnvctrl0 nvidia-367 nvidia-367-dev nvidia-modprobe
nvidia-opencl-icd-367 nvidia-prime nvidia-settings ocl-icd-libopencl1 screen-resolution-extra
The following packages will be upgraded:
cuda-command-line-tools-8-0 cuda-core-8-0 cuda-cublas-8-0 cuda-cublas-dev-8-0 cuda-cudart-8-0 cuda-cudart-dev-8-0 cuda-cufft-8-0 cuda-cufft-dev-8-0 cuda-curand-8-0 cuda-curand-dev-8-0
cuda-cusolver-8-0 cuda-cusolver-dev-8-0 cuda-cusparse-8-0 cuda-cusparse-dev-8-0 cuda-documentation-8-0 cuda-driver-dev-8-0 cuda-license-8-0 cuda-misc-headers-8-0 cuda-npp-8-0 cuda-npp-dev-8-0
cuda-nvgraph-8-0 cuda-nvgraph-dev-8-0 cuda-nvml-dev-8-0 cuda-nvrtc-8-0 cuda-nvrtc-dev-8-0 cuda-samples-8-0 cuda-toolkit-8-0 cuda-visual-tools-8-0
28 to upgrade, 20 to newly install, 0 to remove and 63 not to upgrade.
Need to get 78.0 MB/1,383 MB of archives.
After this operation, 380 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 file:/var/cuda-repo-8-0-local cuda-license-8-0 8.0.44-1 [27.6 kB]
Get:2 file:/var/cuda-repo-8-0-local cuda-misc-headers-8-0 8.0.44-1 [1,078 kB]
Get:3 http://gb.archive.ubuntu.com/ubuntu xenial-updates/main amd64 dkms all 2.2.0.3-2ubuntu11.3 [66.1 kB]
Get:4 file:/var/cuda-repo-8-0-local cuda-core-8-0 8.0.44-1 [19.9 MB]
Get:5 file:/var/cuda-repo-8-0-local cuda-cudart-8-0 8.0.44-1 [135 kB]
Get:6 file:/var/cuda-repo-8-0-local cuda-driver-dev-8-0 8.0.44-1 [14.1 kB]
Get:7 file:/var/cuda-repo-8-0-local cuda-cudart-dev-8-0 8.0.44-1 [1,074 kB]
Get:8 http://gb.archive.ubuntu.com/ubuntu xenial-updates/main amd64 libc6-i386 amd64 2.23-0ubuntu5 [2,329 kB]
Get:9 file:/var/cuda-repo-8-0-local cuda-command-line-tools-8-0 8.0.44-1 [26.1 MB]
Get:10 file:/var/cuda-repo-8-0-local cuda-nvrtc-8-0 8.0.44-1 [9,583 kB]
Get:11 file:/var/cuda-repo-8-0-local cuda-nvrtc-dev-8-0 8.0.44-1 [10.8 kB]
Get:12 file:/var/cuda-repo-8-0-local cuda-cusolver-8-0 8.0.44-1 [29.3 MB]
Get:13 file:/var/cuda-repo-8-0-local cuda-cusolver-dev-8-0 8.0.44-1 [6,817 kB]
Get:14 file:/var/cuda-repo-8-0-local cuda-cublas-8-0 8.0.44-1 [26.6 MB]
Get:15 file:/var/cuda-repo-8-0-local cuda-cublas-dev-8-0 8.0.44-1 [56.9 MB]
Get:16 file:/var/cuda-repo-8-0-local cuda-cufft-8-0 8.0.44-1 [117 MB]
Get:17 file:/var/cuda-repo-8-0-local cuda-cufft-dev-8-0 8.0.44-1 [94.7 MB]
Get:18 file:/var/cuda-repo-8-0-local cuda-curand-8-0 8.0.44-1 [43.7 MB]
Get:19 file:/var/cuda-repo-8-0-local cuda-curand-dev-8-0 8.0.44-1 [67.7 MB]
Get:20 file:/var/cuda-repo-8-0-local cuda-cusparse-8-0 8.0.44-1 [28.8 MB]
Get:21 file:/var/cuda-repo-8-0-local cuda-cusparse-dev-8-0 8.0.44-1 [29.6 MB]
Get:22 file:/var/cuda-repo-8-0-local cuda-npp-8-0 8.0.44-1 [157 MB]
Get:23 file:/var/cuda-repo-8-0-local cuda-npp-dev-8-0 8.0.44-1 [82.5 MB]
Get:24 http://gb.archive.ubuntu.com/ubuntu xenial/main amd64 lib32gcc1 amd64 1:6.0.1-0ubuntu1 [46.6 kB]
Get:25 http://gb.archive.ubuntu.com/ubuntu xenial-updates/restricted amd64 nvidia-367 amd64 367.57-0ubuntu0.16.04.1 [69.8 MB]
Get:26 file:/var/cuda-repo-8-0-local cuda-samples-8-0 8.0.44-1 [101 MB]
Get:27 file:/var/cuda-repo-8-0-local cuda-documentation-8-0 8.0.44-1 [108 MB]
Get:28 file:/var/cuda-repo-8-0-local cuda-nvml-dev-8-0 8.0.44-1 [48.1 kB]
Get:29 file:/var/cuda-repo-8-0-local cuda-nvgraph-8-0 8.0.44-1 [2,947 kB]
Get:30 file:/var/cuda-repo-8-0-local cuda-nvgraph-dev-8-0 8.0.44-1 [3,027 kB]
Get:31 file:/var/cuda-repo-8-0-local cuda-visual-tools-8-0 8.0.44-1 [285 MB]
Get:32 file:/var/cuda-repo-8-0-local cuda-toolkit-8-0 8.0.44-1 [2,892 B]
Get:33 file:/var/cuda-repo-8-0-local nvidia-modprobe 367.48-0ubuntu1 [16.9 kB]
Get:34 file:/var/cuda-repo-8-0-local libxnvctrl0 367.48-0ubuntu1 [18.8 kB]
Get:35 file:/var/cuda-repo-8-0-local nvidia-settings 367.48-0ubuntu1 [866 kB]
Get:36 file:/var/cuda-repo-8-0-local cuda-drivers 367.48-1 [2,402 B]
Get:37 file:/var/cuda-repo-8-0-local cuda-runtime-8-0 8.0.44-1 [2,576 B]
Get:38 file:/var/cuda-repo-8-0-local cuda-demo-suite-8-0 8.0.44-1 [4,988 kB]
Get:39 file:/var/cuda-repo-8-0-local cuda-8-0 8.0.44-1 [2,556 B]
Get:40 file:/var/cuda-repo-8-0-local cuda 8.0.44-1 [2,504 B]
Get:41 http://gb.archive.ubuntu.com/ubuntu xenial-updates/restricted amd64 nvidia-367-dev amd64 367.57-0ubuntu0.16.04.1 [80.8 kB]
Get:42 http://gb.archive.ubuntu.com/ubuntu xenial-updates/restricted amd64 libcuda1-367 amd64 367.57-0ubuntu0.16.04.1 [2,708 kB]
Get:43 http://gb.archive.ubuntu.com/ubuntu xenial/main amd64 screen-resolution-extra all 0.17.1 [11.4 kB]
Get:44 http://gb.archive.ubuntu.com/ubuntu xenial/main amd64 libjansson4 amd64 2.7-3 [26.9 kB]
Get:45 http://gb.archive.ubuntu.com/ubuntu xenial/main amd64 ocl-icd-libopencl1 amd64 2.2.8-1 [29.7 kB]
Get:46 http://gb.archive.ubuntu.com/ubuntu xenial-updates/restricted amd64 nvidia-opencl-icd-367 amd64 367.57-0ubuntu0.16.04.1 [2,903 kB]
Get:47 http://gb.archive.ubuntu.com/ubuntu xenial/main amd64 bbswitch-dkms amd64 0.8-3ubuntu1 [11.6 kB]
Get:48 http://gb.archive.ubuntu.com/ubuntu xenial/main amd64 nvidia-prime amd64 0.8.2 [11.1 kB]
Fetched 78.0 MB in 4min 57s (262 kB/s)
Extract templates from packages: 100%
(Reading database ... 230095 files and directories currently installed.)
Preparing to unpack .../cuda-license-8-0_8.0.44-1_amd64.deb ...
Unpacking cuda-license-8-0 (8.0.44-1) over (8.0.34-1) ...
Preparing to unpack .../cuda-misc-headers-8-0_8.0.44-1_amd64.deb ...
Unpacking cuda-misc-headers-8-0 (8.0.44-1) over (8.0.34-1) ...
Preparing to unpack .../cuda-core-8-0_8.0.44-1_amd64.deb ...
Unpacking cuda-core-8-0 (8.0.44-1) over (8.0.34-1) ...
Preparing to unpack .../cuda-cudart-8-0_8.0.44-1_amd64.deb ...
Unpacking cuda-cudart-8-0 (8.0.44-1) over (8.0.34-1) ...
Preparing to unpack .../cuda-driver-dev-8-0_8.0.44-1_amd64.deb ...
Unpacking cuda-driver-dev-8-0 (8.0.44-1) over (8.0.34-1) ...
Preparing to unpack .../cuda-cudart-dev-8-0_8.0.44-1_amd64.deb ...
Unpacking cuda-cudart-dev-8-0 (8.0.44-1) over (8.0.34-1) ...
Preparing to unpack .../cuda-command-line-tools-8-0_8.0.44-1_amd64.deb ...
Unpacking cuda-command-line-tools-8-0 (8.0.44-1) over (8.0.34-1) ...
Preparing to unpack .../cuda-nvrtc-8-0_8.0.44-1_amd64.deb ...
Unpacking cuda-nvrtc-8-0 (8.0.44-1) over (8.0.34-1) ...
Preparing to unpack .../cuda-nvrtc-dev-8-0_8.0.44-1_amd64.deb ...
Unpacking cuda-nvrtc-dev-8-0 (8.0.44-1) over (8.0.34-1) ...
Preparing to unpack .../cuda-cusolver-8-0_8.0.44-1_amd64.deb ...
Unpacking cuda-cusolver-8-0 (8.0.44-1) over (8.0.34-1) ...
Preparing to unpack .../cuda-cusolver-dev-8-0_8.0.44-1_amd64.deb ...
Unpacking cuda-cusolver-dev-8-0 (8.0.44-1) over (8.0.34-1) ...
Preparing to unpack .../cuda-cublas-8-0_8.0.44-1_amd64.deb ...
Unpacking cuda-cublas-8-0 (8.0.44-1) over (8.0.34-1) ...
Preparing to unpack .../cuda-cublas-dev-8-0_8.0.44-1_amd64.deb ...
Unpacking cuda-cublas-dev-8-0 (8.0.44-1) over (8.0.34-1) ...
Preparing to unpack .../cuda-cufft-8-0_8.0.44-1_amd64.deb ...
Unpacking cuda-cufft-8-0 (8.0.44-1) over (8.0.34-1) ...
Preparing to unpack .../cuda-cufft-dev-8-0_8.0.44-1_amd64.deb ...
Unpacking cuda-cufft-dev-8-0 (8.0.44-1) over (8.0.34-1) ...
Preparing to unpack .../cuda-curand-8-0_8.0.44-1_amd64.deb ...
Unpacking cuda-curand-8-0 (8.0.44-1) over (8.0.34-1) ...
Preparing to unpack .../cuda-curand-dev-8-0_8.0.44-1_amd64.deb ...
Unpacking cuda-curand-dev-8-0 (8.0.44-1) over (8.0.34-1) ...
Preparing to unpack .../cuda-cusparse-8-0_8.0.44-1_amd64.deb ...
Unpacking cuda-cusparse-8-0 (8.0.44-1) over (8.0.34-1) ...
Preparing to unpack .../cuda-cusparse-dev-8-0_8.0.44-1_amd64.deb ...
Unpacking cuda-cusparse-dev-8-0 (8.0.44-1) over (8.0.34-1) ...
Preparing to unpack .../cuda-npp-8-0_8.0.44-1_amd64.deb ...
Unpacking cuda-npp-8-0 (8.0.44-1) over (8.0.34-1) ...
Preparing to unpack .../cuda-npp-dev-8-0_8.0.44-1_amd64.deb ...
Unpacking cuda-npp-dev-8-0 (8.0.44-1) over (8.0.34-1) ...
Preparing to unpack .../cuda-samples-8-0_8.0.44-1_amd64.deb ...
Unpacking cuda-samples-8-0 (8.0.44-1) over (8.0.34-1) ...
Preparing to unpack .../cuda-documentation-8-0_8.0.44-1_amd64.deb ...
Unpacking cuda-documentation-8-0 (8.0.44-1) over (8.0.34-1) ...
Preparing to unpack .../cuda-nvml-dev-8-0_8.0.44-1_amd64.deb ...
Unpacking cuda-nvml-dev-8-0 (8.0.44-1) over (8.0.34-1) ...
Preparing to unpack .../cuda-nvgraph-8-0_8.0.44-1_amd64.deb ...
Unpacking cuda-nvgraph-8-0 (8.0.44-1) over (8.0.34-1) ...
Preparing to unpack .../cuda-nvgraph-dev-8-0_8.0.44-1_amd64.deb ...
Unpacking cuda-nvgraph-dev-8-0 (8.0.44-1) over (8.0.34-1) ...
Preparing to unpack .../cuda-visual-tools-8-0_8.0.44-1_amd64.deb ...
Unpacking cuda-visual-tools-8-0 (8.0.44-1) over (8.0.34-1) ...
Preparing to unpack .../cuda-toolkit-8-0_8.0.44-1_amd64.deb ...
Unpacking cuda-toolkit-8-0 (8.0.44-1) over (8.0.34-1) ...
Selecting previously unselected package dkms.
Preparing to unpack .../dkms_2.2.0.3-2ubuntu11.3_all.deb ...
Unpacking dkms (2.2.0.3-2ubuntu11.3) ...
Selecting previously unselected package libc6-i386.
Preparing to unpack .../libc6-i386_2.23-0ubuntu5_amd64.deb ...
Unpacking libc6-i386 (2.23-0ubuntu5) ...
Selecting previously unselected package lib32gcc1.
Preparing to unpack .../lib32gcc1_1%3a6.0.1-0ubuntu1_amd64.deb ...
Unpacking lib32gcc1 (1:6.0.1-0ubuntu1) ...
Selecting previously unselected package nvidia-367.
Preparing to unpack .../nvidia-367_367.57-0ubuntu0.16.04.1_amd64.deb ...
Unpacking nvidia-367 (367.57-0ubuntu0.16.04.1) ...
Selecting previously unselected package nvidia-367-dev.
Preparing to unpack .../nvidia-367-dev_367.57-0ubuntu0.16.04.1_amd64.deb ...
Unpacking nvidia-367-dev (367.57-0ubuntu0.16.04.1) ...
Selecting previously unselected package libcuda1-367.
Preparing to unpack .../libcuda1-367_367.57-0ubuntu0.16.04.1_amd64.deb ...
Unpacking libcuda1-367 (367.57-0ubuntu0.16.04.1) ...
Selecting previously unselected package nvidia-modprobe.
Preparing to unpack .../nvidia-modprobe_367.48-0ubuntu1_amd64.deb ...
Unpacking nvidia-modprobe (367.48-0ubuntu1) ...
Selecting previously unselected package screen-resolution-extra.
Preparing to unpack .../screen-resolution-extra_0.17.1_all.deb ...
Unpacking screen-resolution-extra (0.17.1) ...
Selecting previously unselected package libjansson4:amd64.
Preparing to unpack .../libjansson4_2.7-3_amd64.deb ...
Unpacking libjansson4:amd64 (2.7-3) ...
Selecting previously unselected package libxnvctrl0.
Preparing to unpack .../libxnvctrl0_367.48-0ubuntu1_amd64.deb ...
Unpacking libxnvctrl0 (367.48-0ubuntu1) ...
Selecting previously unselected package nvidia-settings.
Preparing to unpack .../nvidia-settings_367.48-0ubuntu1_amd64.deb ...
Unpacking nvidia-settings (367.48-0ubuntu1) ...
Selecting previously unselected package ocl-icd-libopencl1:amd64.
Preparing to unpack .../ocl-icd-libopencl1_2.2.8-1_amd64.deb ...
Unpacking ocl-icd-libopencl1:amd64 (2.2.8-1) ...
Selecting previously unselected package nvidia-opencl-icd-367.
Preparing to unpack .../nvidia-opencl-icd-367_367.57-0ubuntu0.16.04.1_amd64.deb ...
Unpacking nvidia-opencl-icd-367 (367.57-0ubuntu0.16.04.1) ...
Selecting previously unselected package cuda-drivers.
Preparing to unpack .../cuda-drivers_367.48-1_amd64.deb ...
Unpacking cuda-drivers (367.48-1) ...
Selecting previously unselected package cuda-runtime-8-0.
Preparing to unpack .../cuda-runtime-8-0_8.0.44-1_amd64.deb ...
Unpacking cuda-runtime-8-0 (8.0.44-1) ...
Selecting previously unselected package cuda-demo-suite-8-0.
Preparing to unpack .../cuda-demo-suite-8-0_8.0.44-1_amd64.deb ...
Unpacking cuda-demo-suite-8-0 (8.0.44-1) ...
Selecting previously unselected package cuda-8-0.
Preparing to unpack ..././cuda-8-0_8.0.44-1_amd64.deb ...
Unpacking cuda-8-0 (8.0.44-1) ...
Selecting previously unselected package cuda.
Preparing to unpack ..././cuda_8.0.44-1_amd64.deb ...
Unpacking cuda (8.0.44-1) ...
Selecting previously unselected package bbswitch-dkms.
Preparing to unpack .../bbswitch-dkms_0.8-3ubuntu1_amd64.deb ...
Unpacking bbswitch-dkms (0.8-3ubuntu1) ...
Selecting previously unselected package nvidia-prime.
Preparing to unpack .../nvidia-prime_0.8.2_amd64.deb ...
Unpacking nvidia-prime (0.8.2) ...
Processing triggers for man-db (2.7.5-1) ...
Processing triggers for libc-bin (2.23-0ubuntu5) ...
Processing triggers for ureadahead (0.100.0-19) ...
ureadahead will be reprofiled on next reboot
Processing triggers for dbus (1.10.6-1ubuntu3.1) ...
Processing triggers for bamfdaemon (0.5.3~bzr0+16.04.20160824-0ubuntu1) ...
Rebuilding /usr/share/applications/bamf-2.index...
Processing triggers for gnome-menus (3.13.3-6ubuntu3.1) ...
Processing triggers for desktop-file-utils (0.22-1ubuntu5) ...
Processing triggers for mime-support (3.59ubuntu1) ...
Processing triggers for doc-base (0.10.7) ...
Processing 1 added doc-base file...
Setting up cuda-license-8-0 (8.0.44-1) ...
*** 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-8.0/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.

Setting up cuda-misc-headers-8-0 (8.0.44-1) ...
Setting up cuda-core-8-0 (8.0.44-1) ...
Setting up cuda-cudart-8-0 (8.0.44-1) ...
Setting up cuda-driver-dev-8-0 (8.0.44-1) ...
Setting up cuda-cudart-dev-8-0 (8.0.44-1) ...
Setting up cuda-command-line-tools-8-0 (8.0.44-1) ...
Setting up cuda-nvrtc-8-0 (8.0.44-1) ...
Setting up cuda-nvrtc-dev-8-0 (8.0.44-1) ...
Setting up cuda-cusolver-8-0 (8.0.44-1) ...
Setting up cuda-cusolver-dev-8-0 (8.0.44-1) ...
Setting up cuda-cublas-8-0 (8.0.44-1) ...
Setting up cuda-cublas-dev-8-0 (8.0.44-1) ...
Setting up cuda-cufft-8-0 (8.0.44-1) ...
Setting up cuda-cufft-dev-8-0 (8.0.44-1) ...
Setting up cuda-curand-8-0 (8.0.44-1) ...
Setting up cuda-curand-dev-8-0 (8.0.44-1) ...
Setting up cuda-cusparse-8-0 (8.0.44-1) ...
Setting up cuda-cusparse-dev-8-0 (8.0.44-1) ...
Setting up cuda-npp-8-0 (8.0.44-1) ...
Setting up cuda-npp-dev-8-0 (8.0.44-1) ...
Setting up cuda-samples-8-0 (8.0.44-1) ...
Setting up cuda-documentation-8-0 (8.0.44-1) ...
Setting up cuda-nvml-dev-8-0 (8.0.44-1) ...
Setting up cuda-nvgraph-8-0 (8.0.44-1) ...
Setting up cuda-nvgraph-dev-8-0 (8.0.44-1) ...
Setting up cuda-visual-tools-8-0 (8.0.44-1) ...
Setting up cuda-toolkit-8-0 (8.0.44-1) ...
Setting up dkms (2.2.0.3-2ubuntu11.3) ...
Setting up libc6-i386 (2.23-0ubuntu5) ...
Setting up lib32gcc1 (1:6.0.1-0ubuntu1) ...
Setting up nvidia-367 (367.57-0ubuntu0.16.04.1) ...
update-alternatives: using /usr/lib/nvidia-367/ld.so.conf to provide /etc/ld.so.conf.d/x86_64-linux-gnu_GL.conf (x86_64-linux-gnu_gl_conf) in auto mode
update-alternatives: using /usr/lib/nvidia-367/ld.so.conf to provide /etc/ld.so.conf.d/x86_64-linux-gnu_EGL.conf (x86_64-linux-gnu_egl_conf) in auto mode
update-alternatives: using /usr/lib/nvidia-367/alt_ld.so.conf to provide /etc/ld.so.conf.d/i386-linux-gnu_GL.conf (i386-linux-gnu_gl_conf) in auto mode
update-alternatives: using /usr/lib/nvidia-367/alt_ld.so.conf to provide /etc/ld.so.conf.d/i386-linux-gnu_EGL.conf (i386-linux-gnu_egl_conf) in auto mode
update-alternatives: using /usr/share/nvidia-367/glamor.conf to provide /usr/share/X11/xorg.conf.d/glamoregl.conf (glamor_conf) in auto mode
update-initramfs: deferring update (trigger activated)
INFO:Enable nvidia-367
DEBUG:Parsing /usr/share/ubuntu-drivers-common/quirks/lenovo_thinkpad
DEBUG:Parsing /usr/share/ubuntu-drivers-common/quirks/put_your_quirks_here
DEBUG:Parsing /usr/share/ubuntu-drivers-common/quirks/dell_latitude
Adding system user `nvidia-persistenced' (UID 121) ...
Adding new group `nvidia-persistenced' (GID 129) ...
Adding new user `nvidia-persistenced' (UID 121) with group `nvidia-persistenced' ...
Not creating home directory `/'.
Loading new nvidia-367-367.57 DKMS files...
First Installation: checking all kernels...
Building only for 4.4.0-59-generic
Building for architecture x86_64
Building initial module for 4.4.0-59-generic
Done.

nvidia_367:
Running module version sanity check.
- Original module
- No original module exists within this kernel
- Installation
- Installing to /lib/modules/4.4.0-59-generic/updates/dkms/

nvidia_367_modeset.ko:
Running module version sanity check.
- Original module
- No original module exists within this kernel
- Installation
- Installing to /lib/modules/4.4.0-59-generic/updates/dkms/

nvidia_367_drm.ko:
Running module version sanity check.
- Original module
- No original module exists within this kernel
- Installation
- Installing to /lib/modules/4.4.0-59-generic/updates/dkms/

nvidia_367_uvm.ko:
Running module version sanity check.
- Original module
- No original module exists within this kernel
- Installation
- Installing to /lib/modules/4.4.0-59-generic/updates/dkms/

depmod......

DKMS: install completed.
Setting up nvidia-367-dev (367.57-0ubuntu0.16.04.1) ...
Setting up libcuda1-367 (367.57-0ubuntu0.16.04.1) ...
Setting up nvidia-modprobe (367.48-0ubuntu1) ...
Setting up screen-resolution-extra (0.17.1) ...
Setting up libjansson4:amd64 (2.7-3) ...
Setting up libxnvctrl0 (367.48-0ubuntu1) ...
Setting up nvidia-settings (367.48-0ubuntu1) ...
Setting up ocl-icd-libopencl1:amd64 (2.2.8-1) ...
Setting up nvidia-opencl-icd-367 (367.57-0ubuntu0.16.04.1) ...
Setting up cuda-drivers (367.48-1) ...
Setting up cuda-runtime-8-0 (8.0.44-1) ...
Setting up cuda-demo-suite-8-0 (8.0.44-1) ...
Setting up cuda-8-0 (8.0.44-1) ...
Setting up cuda (8.0.44-1) ...
Setting up bbswitch-dkms (0.8-3ubuntu1) ...
Loading new bbswitch-0.8 DKMS files...
First Installation: checking all kernels...
Building only for 4.4.0-59-generic
Building initial module for 4.4.0-59-generic
Done.

bbswitch:
Running module version sanity check.
- Original module
- No original module exists within this kernel
- Installation
- Installing to /lib/modules/4.4.0-59-generic/updates/dkms/

depmod....

DKMS: install completed.
Setting up nvidia-prime (0.8.2) ...
Processing triggers for libc-bin (2.23-0ubuntu5) ...
Processing triggers for initramfs-tools (0.122ubuntu8.8) ...
update-initramfs: Generating /boot/initrd.img-4.4.0-59-generic
Processing triggers for dbus (1.10.6-1ubuntu3.1) ...
Processing triggers for ureadahead (0.100.0-19) ...



Let's verify that CUDA paths have been added to PATH and LD_LIBRARY_PATH:


$ echo $PATH

/usr/local/cuda-8.0/bin:/home/bojan/bin:/home/bojan/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

$ echo $LD_LIBRARY_PATH

/usr/local/cuda-8.0/lib64:



Now let's build and run one of the CUDA examples:


/usr/local/cuda-8.0/bin$ ./cuda-install-samples-8.0.sh ~
Copying samples to /home/bojan/NVIDIA_CUDA-8.0_Samples now...
Finished copying samples.




/usr/local/cuda-8.0/bin$ cd ~/NVIDIA_CUDA-8.0_Samples/5_Simulations/nbody




~/NVIDIA_CUDA-8.0_Samples/5_Simulations/nbody$ make

/usr/local/cuda-8.0/bin/nvcc -ccbin g++ -I../../common/inc -m64 -ftz=true -gencode arch=compute_20,code=sm_20 -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_60,code=compute_60 -o bodysystemcuda.o -c bodysystemcuda.cu
nvcc warning : The 'compute_20', 'sm_20', and 'sm_21' architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
/usr/local/cuda-8.0/bin/nvcc -ccbin g++ -I../../common/inc -m64 -ftz=true -gencode arch=compute_20,code=sm_20 -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_60,code=compute_60 -o nbody.o -c nbody.cpp
nvcc warning : The 'compute_20', 'sm_20', and 'sm_21' architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
/usr/local/cuda-8.0/bin/nvcc -ccbin g++ -I../../common/inc -m64 -ftz=true -gencode arch=compute_20,code=sm_20 -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_60,code=compute_60 -o render_particles.o -c render_particles.cpp
nvcc warning : The 'compute_20', 'sm_20', and 'sm_21' architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
/usr/local/cuda-8.0/bin/nvcc -ccbin g++ -m64 -gencode arch=compute_20,code=sm_20 -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_60,code=compute_60 -o nbody bodysystemcuda.o nbody.o render_particles.o -L/usr/lib/"nvidia-367" -lGL -lGLU -lX11 -lglut
nvcc warning : The 'compute_20', 'sm_20', and 'sm_21' architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
mkdir -p ../../bin/x86_64/linux/release
cp nbody ../../bin/x86_64/linux/release




~/NVIDIA_CUDA-8.0_Samples/5_Simulations/nbody$ ./nbody

Run "nbody -benchmark [-numbodies=<numBodies>]" to measure performance.
-fullscreen (run n-body simulation in fullscreen mode)
-fp64 (use double precision floating point values for simulation)
-hostmem (stores simulation data in host memory)
-benchmark (run benchmark to measure performance)
-numbodies=<N> (number of bodies (>= 1) to run in simulation)
-device=<d> (where d=0,1,2.... for the CUDA device to use)
-numdevices=<i> (where i=(number of CUDA devices > 0) to use for simulation)
-compare (compares simulation results running once on the default GPU and once on the CPU)
-cpu (run n-body simulation on the CPU)
-tipsy=<file.bin> (load a tipsy model file for simulation)

NOTE: The CUDA Samples are not meant for performance measurements. Results may vary when GPU Boost is enabled.

modprobe: ERROR: could not insert 'nvidia_367_uvm': No such device
Error: only 0 Devices available, 1 requested. Exiting.



The last error means that NVIDIA's driver nvidia_367_uvm has not been loaded. CUDA installer installs a new NVIDIA driver. Version of the driver depends on the version of the CUDA Toolkit. In order to load the new driver we have to reboot the system after which we can use nvidia-settings tool in order to verify that Nvidia driver v367 is loaded.

If we run:


$ nvidia-settings

** Message: PRIME: No offloading required. Abort
** Message: PRIME: is it supported? no



...NVIDIA Settings dialog appears and we can verify the version of the NVIDIA driver which is 367 after reboot:


If we try to run the nbody example again, it should launch with no errors and look like this:


This proves that CUDA installation was successful. Yay! :)

References:
CUDA Quick Start Guide

No comments: