Установка CUDA 7.5 на Ubuntu 16.04 — TechCave

Для начала нам необходимо установить проприетарные драйвера NVIDIA VGA на Ubuntu 16.04 Xenial Xerus. Давайте начнем с обнаружения модели карты NVIDIA

Установка CUDA 7.5 на Ubuntu 16.04

Высокопроизводительные вычисления

Установка CUDA 7.5 на Ubuntu 16.04

Для начала нам необходимо установить проприетарные драйвера NVIDIA VGA на Ubuntu 16.04 Xenial Xerus. Давайте начнем с обнаружения модели карты NVIDIA.

Откройте терминал и введите следующую команду:

$ lshw -numeric -C display
или
$ lspci -vnn | grep VGA

Приведенная выше команда выведет номер модели вашей карты NVIDIA. Например:

$ lspci -vnn | grep VGA
01:00.0 VGA compatible controller [0300]: NVIDIA Corporation GK104 [GeForce GTX 680] [10de:1180] (rev a1) (prog-if 00 [VGA controller])

Карта установленная в системе, это GeForce GTX 680. На следующем этапе мы будем использовать эту информацию, чтобы найти правильный драйвер NVIDIA внутри репозитория пакетов Ubuntu. Но, сначала давайте перейдем в браузере на страницу поиска драйвера NVIDIA и введем параметры видеокарты:

 

После завершения поиска необходимо запомнить номер драйвера для вашей видеокарты:

Version: 	361.42
Release Date: 	2016.3.30
Operating System: 	Linux 64-bit
Language: 	English (US)
File Size: 	82.74 MB 

Номер версии драйвера 361.42. Теперь, узнав номер драйвера для нашей видеокарты будем ставить его из репозитория Ubuntu, используя команду apt-get:

VERSION: 304
$ sudo apt-get install nvidia-304
VERSION: 340
$ sudo apt-get install nvidia-340
VERSION: 361
$ sudo apt-get install nvidia-361
...
Done.

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

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

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

depmod........

DKMS: install completed.
Setting up ocl-icd-libopencl1:amd64 (2.2.8-1) ...
Setting up nvidia-opencl-icd-361 (361.42-0ubuntu1) ...
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-18-generic
Building initial module for 4.4.0-18-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-18-generic/updates/dkms/

depmod....

DKMS: install completed.
Setting up nvidia-prime (0.8.2) ...
Setting up screen-resolution-extra (0.17.1) ...
Setting up nvidia-settings (361.42-0ubuntu1) ...
Setting up vdpau-driver-all:amd64 (1.1.1-3ubuntu1) ...
Processing triggers for libc-bin (2.23-0ubuntu2) ...
Processing triggers for initramfs-tools (0.122ubuntu6) ...
update-initramfs: Generating /boot/initrd.img-4.4.0-18-generic
Processing triggers for ureadahead (0.100.0-19) ...
Processing triggers for dbus (1.10.6-1ubuntu3) ...

Теперь необходимо перезагрузить систему. После перезагрузки, вы сможет получить доступ к меню конфигурации NVIDIA:

Теперь установим CUDA.

Скачайте файл CUDA.run с сайта NVIDIA. Я использовал этот http://developer.download.nvidia.com/compute/cuda/7.5/Prod/local_installers/cuda_7.5.18_linux.run.

Далее необходимо выполнить следующие команды:

$ chmod 755 cuda_7.5.18_linux.run
$ sudo ./cuda_7.5.18_linux.run --override

"--override" необходим для того, чтобы вы не получили сообщение об ошибке «Toolkit:  Installation Failed. Using unsupported Compiler.»

Драйвер NVIDIA, который идет в файле .run, мы устанавливать не будем, так как мы уже установили более новую версию в самом начале статьи.

Ответы на вопросы установщика должны быть такие:

$ sudo ./cuda_7.5.18_linux.run --override

-------------------------------------------------------------
Do you accept the previously read EULA? (accept/decline/quit): accept
You are attempting to install on an unsupported configuration. Do you wish to continue? ((y)es/(n)o) [ default is no ]: y
Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 352.39? ((y)es/(n)o/(q)uit): n
Install the CUDA 7.5 Toolkit? ((y)es/(n)o/(q)uit): y
Enter Toolkit Location [ default is /usr/local/cuda-7.5 ]:
Do you want to install a symbolic link at /usr/local/cuda? ((y)es/(n)o/(q)uit): y
Install the CUDA 7.5 Samples? ((y)es/(n)o/(q)uit): y
Enter CUDA Samples Location [ default is /home/kinghorn ]: /usr/local/cuda-7.5
Installing the CUDA Toolkit in /usr/local/cuda-7.5 ...
Finished copying samples.

===========
= Summary =
===========

Driver:   Not Selected
Toolkit:  Installed in /usr/local/cuda-7.5
Samples:  Installed in /usr/local/cuda-7.5

Для настройки окружения CUDA нужно изменить несколько файлов:

$ sudo emacs -nw /etc/profile.d/cuda.sh

export PATH=$PATH:/usr/local/cuda/bin

$ sudo emacs -nw /etc/ld.so.conf.d/cuda.conf

/usr/local/cuda/lib64

$ source /etc/profile.d/cuda.conf

$ sudo ldconfig

Далее необходимо сделать некоторые изменения для того, чтобы можно было использовать компилятор gcc 5. Закомментируйте строку 115 в файле host_config.h

$ sudo emacs -nw /usr/local/cuda/include/host_config.h

line: 115 comment out error
//#error -- unsupported GNU version! gcc versions later than 4.9 are not supported!

Теперь давайте попробуем скомпилировать примеры. Скопируйте примеры CUDA в свой домашний каталог. 

$ rsync -av /usr/local/cuda/samples .

Далее нам необходимо поправить файл findglib.mk, так как мы установили более новую версию драйверов. Изменим для этого одну строчку.

$ emacs -nw findgllib.mk
line : 61  changed nvidia-352 to nvidia-361
UBUNTU_PKG_NAME = "nvidia-361"

Компилируем.

$ make

Вот и все.

15:04
8079

13:30
+1
поставил CUDA 8 для того чтобы в OBS с FFmpeg 3.2.4 записывать на NVENC

никакого NVENC не поставилось
зря качал 2 гб
Mint 18.1 x64
02:13
NVENC находится в NVIDIA Video Codec SDK

Посмотрите еще вот эту статью на хабре "Быстрое кодирование видео в Linux c Nvidia NVENC с SDK 7.5 и ffmpeg 3.0.2 на Nvidia GTX 960/970/980"
Олег
00:53
+1
При попытке сделать make сэмплов выскакивает куча ошибок:
make[1]: вход в каталог «/home/olezha/NVIDIA_CUDA-7.5_Samples/0_Simple/cppOverload»
"/usr/local/cuda-7.5"/bin/nvcc -ccbin g++ -I../../common/inc -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_52,code=compute_52 -o cppOverload.o -c cppOverload.cu
/usr/lib/gcc/x86_64-linux-gnu/6/include/stddef.h(436): error: identifier «nullptr» is undefined

/usr/lib/gcc/x86_64-linux-gnu/6/include/stddef.h(436): error: expected a ";"

/usr/include/x86_64-linux-gnu/c++/6/bits/c++config.h(205): error: expected a ";"

/usr/include/c++/6/exception(63): error: expected a ";"

/usr/include/c++/6/exception(69): error: expected a ";"

/usr/include/c++/6/exception(77): error: expected a ";"

/usr/include/c++/6/exception(85): error: expected a ";"

/usr/include/c++/6/exception(95): error: expected a "{"

/usr/include/c++/6/bits/exception_ptr.h(64): error: function «std::current_exception» returns incomplete type «std::__exception_ptr::exception_ptr»

/usr/include/c++/6/bits/exception_ptr.h(64): error: expected a "{"

/usr/include/c++/6/bits/exception_ptr.h(71): error: namespace «std» has no member «rethrow_exception»

/usr/include/c++/6/bits/exception_ptr.h(81): error: expected a ";"

/usr/include/c++/6/bits/exception_ptr.h(83): error: expected a ";"

/usr/include/c++/6/bits/exception_ptr.h(84): error: expected a ";"

/usr/include/c++/6/bits/exception_ptr.h(86): error: expected a ";"

/usr/include/c++/6/bits/exception_ptr.h(88): error: declaration is incompatible with previous «std::current_exception»
(64): here

/usr/include/c++/6/bits/exception_ptr.h(88): error: use of a local type to declare a function

/usr/include/c++/6/bits/exception_ptr.h(88): error: expected a ";"

/usr/include/c++/6/bits/exception_ptr.h(89): error: use of a local type to declare a function

/usr/include/c++/6/bits/exception_ptr.h(92): error: expected a ";"

/usr/include/c++/6/bits/exception_ptr.h(94): error: expected a ";"

/usr/include/c++/6/bits/exception_ptr.h(97): error: incomplete type is not allowed

/usr/include/c++/6/bits/exception_ptr.h(97): error: expected a ";"

/usr/include/c++/6/bits/exception_ptr.h(118): error: expected a ";"

/usr/include/c++/6/bits/exception_ptr.h(128): error: expected a ";"

/usr/include/c++/6/bits/exception_ptr.h(145): error: use of a local type to declare a function

/usr/include/c++/6/bits/exception_ptr.h(146): error: expected a ";"

/usr/include/c++/6/bits/exception_ptr.h(149): error: expected a ";"

/usr/include/c++/6/bits/exception_ptr.h(154): error: use of a local type to declare a function

/usr/include/c++/6/bits/exception_ptr.h(155): error: expected a ";"

/usr/include/c++/6/bits/exception_ptr.h(158): error: use of a local type to declare a function

/usr/include/c++/6/bits/exception_ptr.h(159): error: expected a ";"

/usr/include/c++/6/bits/exception_ptr.h(162): error: use of a local type to declare a function

/usr/include/c++/6/bits/exception_ptr.h(163): error: expected a ";"

/usr/include/c++/6/bits/exception_ptr.h(171): error: expected a ";"

/usr/include/c++/6/bits/exception_ptr.h(197): error: expected a ";"

/usr/include/c++/6/bits/move.h(47): error: expected a ";"

/usr/include/c++/6/type_traits(71): error: identifier «constexpr» is undefined

/usr/include/c++/6/type_traits(71): error: template parameter "_Tp" may not be redeclared in this scope

/usr/include/c++/6/type_traits(71): error: expected a ";"

/usr/include/c++/6/type_traits(72): error: member «std::integral_constant<_Tp, __v>::_Tp» is not a type name

/usr/include/c++/6/type_traits(73): error: member «std::integral_constant<_Tp, __v>::_Tp» is not a type name

/usr/include/c++/6/type_traits(74): error: identifier «constexpr» is undefined

/usr/include/c++/6/type_traits(79): error: identifier «constexpr» is undefined

/usr/include/c++/6/type_traits(79): error: «value_type» has already been declared in the current scope

/usr/include/c++/6/type_traits(79): error: expected a ";"

/usr/include/c++/6/type_traits(84): error: identifier «constexpr» is undefined

/usr/include/c++/6/type_traits(84): error: "_Tp" is not a function or static data member

/usr/include/c++/6/type_traits(93): error: expected a declaration

/usr/include/c++/6/type_traits(93): error: expected a ";"

/usr/include/c++/6/type_traits(126): error: space required between adjacent ">" delimiters of nested template argument lists (">>" is the right shift operator)

/usr/include/c++/6/type_traits(242): error: identifier «char16_t» is undefined

/usr/include/c++/6/type_traits(246): error: identifier «char32_t» is undefined

/usr/include/c++/6/type_traits(246): error: class «std::__is_integral_helper<<error-type>>» has already been defined

/usr/include/c++/6/type_traits(344): error: identifier "__float128" is undefined

/usr/include/c++/6/type_traits(460): error: expected a ">"

/usr/include/c++/6/type_traits(464): error: expected a ">"

/usr/include/c++/6/type_traits(472): error: expected a ">"

/usr/include/c++/6/type_traits(476): error: expected a ">"

/usr/include/c++/6/type_traits(484): error: expected a ">"

/usr/include/c++/6/type_traits(488): error: expected a ">"

/usr/include/c++/6/type_traits(496): error: expected a ">"

/usr/include/c++/6/type_traits(500): error: expected a ">"

/usr/include/c++/6/type_traits(508): error: expected a ">"

/usr/include/c++/6/type_traits(512): error: expected a ">"

/usr/include/c++/6/type_traits(520): error: expected a ">"

/usr/include/c++/6/type_traits(524): error: expected a ">"

/usr/include/c++/6/type_traits(532): error: expected a ">"

/usr/include/c++/6/type_traits(536): error: expected a ">"

/usr/include/c++/6/type_traits(544): error: expected a ">"

/usr/include/c++/6/type_traits(548): error: expected a ">"

/usr/include/c++/6/type_traits(558): error: namespace «std» has no member «nullptr_t»

/usr/include/c++/6/type_traits(579): error: space required between adjacent ">" delimiters of nested template argument lists (">>" is the right shift operator)

/usr/include/c++/6/type_traits(585): error: space required between adjacent ">" delimiters of nested template argument lists (">>" is the right shift operator)

/usr/include/c++/6/type_traits(592): error: space required between adjacent ">" delimiters of nested template argument lists (">>" is the right shift operator)

/usr/include/c++/6/type_traits(599): error: space required between adjacent ">" delimiters of nested template argument lists (">>" is the right shift operator)

/usr/include/c++/6/type_traits(609): error: space required between adjacent ">" delimiters of nested template argument lists (">>" is the right shift operator)

/usr/include/c++/6/type_traits(635): error: space required between adjacent ">" delimiters of nested template argument lists (">>" is the right shift operator)

/usr/include/c++/6/type_traits(745): error: space required between adjacent ">" delimiters of nested template argument lists (">>" is the right shift operator)

/usr/include/c++/6/type_traits(759): error: expected a ";"

/usr/include/c++/6/type_traits(774): error: space required between adjacent ">" delimiters of nested template argument lists (">>" is the right shift operator)

/usr/include/c++/6/type_traits(784): error: expected a ")"

/usr/include/c++/6/type_traits(795): error: an explicit template argument list is not allowed on this declaration

/usr/include/c++/6/type_traits(795): error: expected a type specifier

/usr/include/c++/6/type_traits(795): error: function returning function is not allowed

/usr/include/c++/6/type_traits(795): error: expected a ";"

/usr/include/c++/6/type_traits(801): error: space required between adjacent ">" delimiters of nested template argument lists (">>" is the right shift operator)

/usr/include/c++/6/type_traits(802): error: space required between adjacent ">" delimiters of nested template argument lists (">>" is the right shift operator)

/usr/include/c++/6/type_traits(832): error: identifier «noexcept» is undefined

/usr/include/c++/6/type_traits(832): error: function call is not allowed in a constant expression

/usr/include/c++/6/type_traits(832): error: function call is not allowed in a constant expression

/usr/include/c++/6/type_traits(832): error: this operator is not allowed in a template argument expression

/usr/include/c++/6/type_traits(843): error: an explicit template argument list is not allowed on this declaration

/usr/include/c++/6/type_traits(843): error: expected a type specifier

/usr/include/c++/6/type_traits(843): error: function returning function is not allowed

/usr/include/c++/6/type_traits(843): error: expected a ";"

/usr/include/c++/6/type_traits(849): error: space required between adjacent ">" delimiters of nested template argument lists (">>" is the right shift operator)

/usr/include/c++/6/type_traits(850): error: space required between adjacent ">" delimiters of nested template argument lists (">>" is the right shift operator)

/usr/include/c++/6/type_traits(875): error: function returning function is not allowed

/usr/include/c++/6/type_traits(886): error: an explicit template argument list is not allowed on this declaration

Error limit reached.
100 errors detected in the compilation of "/tmp/tmpxft_0000080e_00000000-22_cppOverload.compute_52.cpp1.ii".
Compilation terminated.
Makefile:229: ошибка выполнения рецепта для цели «cppOverload.o»
make[1]: *** [cppOverload.o] Ошибка 4
make[1]: выход из каталога «/home/olezha/NVIDIA_CUDA-7.5_Samples/0_Simple/cppOverload»
Makefile:52: ошибка выполнения рецепта для цели «0_Simple/cppOverload/Makefile.ph_build»
make: *** [0_Simple/cppOverload/Makefile.ph_build] Ошибка 2

Авторизация

Пользователи

Zhenya
Лариса Аксиненко
Dmitry Loginov
Dimas Potapov
Ваня Берёзкин
Володя Рудомаха
adanick
Марина Викторовна
Георгiй Москвитинъ