0%

CUDA的安装

[TOC]

NVIDIA

Nvidia显卡驱动安装

CentOS7/RHEL

安装依赖包

1
2
3
yum -y update
yum -y groupinstall "GNOME Desktop" "Development Tools"
yum -y install kernel-devel

下载最新的NVIDIA驱动,==> http://www.nvidia.com/object/unix.html ==> Latest Long Lived Branch version

增加自动内核编辑的选项

1
2
yum -y install epel-release
yum -y install dkms

重新启动系统确保系统使用的为最新的内核版本。

编辑 /etc/default/grub在 “GRUB_CMDLINE_LINUX”增加rd.driver.blacklist=nouveau nouveau.modeset=0

更新包含上述更改的grub文件

1
grub2-mkconfig -o /boot/grub2/grub.cfg

编辑或创建文件`/etc/modprobe.d/blacklist.conf并增加内容blacklist nouveau

备份旧的initramfs文件并创建一个新的

1
2
3
4
mv /boot/initramfs-(uname -r).img /boot/initramfs-(uname -r)-nouveau.img

dracut /boot/initramfs-$(uname -r).img $(uname -r)

重启机器,切换到文本模式,systemctl isolate multi-user.target,运行sh NVIDIA-Linux-x86_64-*.run,选项全部选yes即可。

CUDA Toolkit安装

Redhat/CentOS

下载最新的CUDA Toolkit文件 (run文件,不要下载rpm)
==> https://developer.nvidia.com/cuda-downloads ==> Linux ==> x86_64 ==> RHEL/CentOS ==> 7 ==> runfile (local)

sh cuda_*.run
在安装NVIDIA driver的时候选no,因为我们已经在前面安装了,一般CUDA内置的会旧一些。其他选项默认即可。

添加环境变量:

1
2
3
$ export PATH=/usr/local/cuda-9.2/bin:$PATH
$ export LD_LIBRARY_PATH=/usr/local/cuda-9.2/lib64:$LD_LIBRARY_PATH

过程

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
sudo ./cuda_9.2.88_396.26_linux.run 
Logging to /tmp/cuda_install_6554.log
Using more to view the EULA.
End User License Agreement
--------------------------


Preface
-------

The Software License Agreement in Chapter 1 and the Supplement
in Chapter 2 contain license terms and conditions that govern
the use of NVIDIA software. By accepting this agreement, you
agree to comply with all the terms and conditions applicable
to the product(s) included herein.


NVIDIA Driver


Description

This package contains the operating system driver and
fundamental system software components for NVIDIA GPUs.


NVIDIA CUDA Toolkit


Description

The NVIDIA CUDA Toolkit provides command-line and graphical
tools for building, debugging and optimizing the performance
of applications accelerated by NVIDIA GPUs, runtime and math
libraries, and documentation including programming guides,
user manuals, and API references.


Default Install Location of CUDA Toolkit

Windows platform:

%ProgramFiles%\NVIDIA GPU Computing Toolkit\CUDA\v#.#

Linux platform:

/usr/local/cuda-#.#

Mac platform:

/Developer/NVIDIA/CUDA-#.#


NVIDIA CUDA Samples


Description

This package includes over 100+ CUDA examples that demonstrate
various CUDA programming principles, and efficient CUDA
implementation of algorithms in specific application domains.


Default Install Location of CUDA Samples

Windows platform:

%ProgramData%\NVIDIA Corporation\CUDA Samples\v#.#

Linux platform:

/usr/local/cuda-#.#/samples

and

$HOME/NVIDIA_CUDA-#.#_Samples

Mac platform:

/Developer/NVIDIA/CUDA-#.#/samples


NVIDIA Nsight Visual Studio Edition (Windows only)


Description

NVIDIA Nsight Development Platform, Visual Studio Edition is a
development environment integrated into Microsoft Visual
Studio that provides tools for debugging, profiling, analyzing
and optimizing your GPU computing and graphics applications.


Default Install Location of Nsight Visual Studio Edition

Windows platform:

%ProgramFiles(x86)%\NVIDIA Corporation\Nsight Visual Studio Edition #.#


1. NVIDIA Software License Agreement
------------------------------------


Release Date: October 20, 2016
------------------------------


IMPORTANT NOTICE -- READ BEFORE DOWNLOADING, INSTALLING,
COPYING OR USING THE LICENSED SOFTWARE:
--------------------------------------------------------

This Software License Agreement ("SLA”), made and entered
into as of the time and date of click through action
(“Effective Date”), is a legal agreement between you and
NVIDIA Corporation ("NVIDIA") and governs the use of the
NVIDIA computer software and the documentation made available
for use with such NVIDIA software. By downloading, installing,
copying, or otherwise using the NVIDIA software and/or
documentation, you agree to be bound by the terms of this SLA.
If you do not agree to the terms of this SLA, do not download,
install, copy or use the NVIDIA software or documentation. IF
YOU ARE ENTERING INTO THIS SLA ON BEHALF OF A COMPANY OR OTHER
LEGAL ENTITY, YOU REPRESENT THAT YOU HAVE THE LEGAL AUTHORITY
TO BIND THE ENTITY TO THIS SLA, IN WHICH CASE “YOU” WILL
MEAN THE ENTITY YOU REPRESENT. IF YOU DON’T HAVE SUCH
AUTHORITY, OR IF YOU DON’T ACCEPT ALL THE TERMS AND
CONDITIONS OF THIS SLA, THEN NVIDIA DOES NOT AGREE TO LICENSE
THE LICENSED SOFTWARE TO YOU, AND YOU MAY NOT DOWNLOAD,
INSTALL, COPY OR USE IT.


1.1. License


1.1.1. License Grant

Subject to the terms of the AGREEMENT, NVIDIA hereby grants
you a non-exclusive, non-transferable license, without the
right to sublicense (except as expressly set forth in a
Supplement), during the applicable license term unless earlier
terminated as provided below, to have Authorized Users install
and use the Software, including modifications (if expressly
permitted in a Supplement), in accordance with the
Documentation. You are only licensed to activate and use
Licensed Software for which you a have a valid license, even
if during the download or installation you are presented with
other product options. No Orders are binding on NVIDIA until
accepted by NVIDIA. Your Orders are subject to the AGREEMENT.

SLA Supplements

Certain Licensed Software licensed under this SLA may be
subject to additional terms and conditions that will be
presented to you in a Supplement for acceptance prior to the
delivery of such Licensed Software under this SLA and the
applicable Supplement. Licensed Software will only be
delivered to you upon your acceptance of all applicable terms.


1.1.2. Limited Purposes Licenses

If your license is provided for one of the purposes indicated
below, then notwithstanding contrary terms in Section 1.1 or
in a Supplement, such licenses are for internal use and do not
include any right or license to sub-license and distribute the
Licensed Software or its output in any way in any public
release, however limited, and/or in any manner that provides
third parties with use of or access to the Licensed Software
or its functionality or output, including (but not limited to)
external alpha or beta testing or development phases. Further:

1.

Evaluation License: You may use evaluation licenses solely
for your internal evaluation of the Licensed Software for
broader adoption within your Enterprise or in connection
with a NVIDIA product purchase decision, and such licenses
have an expiration date as indicated by NVIDIA in its sole
discretion (or ninety days from the date of download if no
other duration is indicated).

2.

Educational/Academic License: You may use
educational/academic licenses solely for educational
purposes and all users must be enrolled or employed by an
academic institution. If you do not meet NVIDIA’s
academic program requirements for educational
institutions, you have no rights under this license.

3.

Test/Development License. You may use test/development
licenses solely for your internal development, testing
and/or debugging of your software applications or for
interoperability testing with the Licensed Software, and
such licenses have an expiration date as indicated by
NVIDIA in its sole discretion (or one year from the date
of download if no other duration is indicated). NVIDIA
Confidential Information under the AGREEMENT includes
output from Licensed Software developer tools identified
as “Pro” versions, where the output reveals
functionality or performance data pertinent to NVIDIA
hardware or software products.


1.1.3. Pre-release Licenses

With respect to alpha, beta, preview, and other pre-release
Software and Documentation (“Pre-Release Licensed
Software”) delivered to you under the AGREEMENT you
acknowledge and agree that such Pre-Release Licensed Software
(i) may not be fully functional, may contain errors or design
flaws, and may have reduced or different security, privacy,
accessibility, availability, and reliability standards
relative to commercially provided NVIDIA software and
documentation, and (ii) use of such Pre-Release Licensed
Software may result in unexpected results, loss of data,
project delays or other unpredictable damage or loss.
THEREFORE, PRE-RELEASE LICENSED SOFTWARE IS NOT INTENDED FOR
USE, AND SHOULD NOT BE USED, IN PRODUCTION OR
BUSINESS-CRITICAL SYSTEMS. NVIDIA has no obligation to make
available a commercial version of any Pre-Release Licensed
Software and NVIDIA has the right to abandon development of
Pre-Release Licensed Software at any time without liability.


1.1.4. Enterprise and Contractor Usage

You may allow your Enterprise employees and Contractors to
access and use the Licensed Software pursuant to the terms of
the AGREEMENT solely to perform work on your behalf, provided
further that with respect to Contractors: (i) you obtain a
written agreement from each Contractor which contains terms
and obligations with respect to access to and use of Licensed
Software no less protective of NVIDIA than those set forth in
the AGREEMENT, and (ii) such Contractor’s access and use
expressly excludes any sublicensing or distribution rights for
the Licensed Software. You are responsible for the compliance
with the terms and conditions of the AGREEMENT by your
Enterprise and Contractors. Any act or omission that, if
committed by you, would constitute a breach of the AGREEMENT
shall be deemed to constitute a breach of the AGREEMENT if
committed by your Enterprise or Contractors.


1.1.5. Services

Except as expressly indicated in an Order, NVIDIA is under no
obligation to provide support for the Licensed Software or to
provide any patches, maintenance, updates or upgrades under
the AGREEMENT. Unless patches, maintenance, updates or
upgrades are provided with their separate governing terms and
conditions, they constitute Licensed Software licensed to you
under the AGREEMENT.


1.2. Limitations


1.2.1. License Restrictions

Except as expressly authorized in the AGREEMENT, you agree
that you will not (nor authorize third parties to): (i) copy
and use Software that was licensed to you for use in one or
more NVIDIA hardware products in other unlicensed products
(provided that copies solely for backup purposes are allowed);
(ii) reverse engineer, decompile, disassemble (except to the
extent applicable laws specifically require that such
activities be permitted) or attempt to derive the source code,
underlying ideas, algorithm or structure of Software provided
to you in object code form; (iii) sell, transfer, assign,
distribute, rent, loan, lease, sublicense or otherwise make
available the Licensed Software or its functionality to third
parties (a) as an application services provider or service
bureau, (b) by operating hosted/virtual system environments,
(c) by hosting, time sharing or providing any other type of
services, or (d) otherwise by means of the internet; (iv)
modify, translate or otherwise create any derivative works of
any Licensed Software; (v) remove, alter, cover or obscure any
proprietary notice that appears on or with the Licensed
Software or any copies thereof; (vi) use the Licensed
Software, or allow its use, transfer, transmission or export
in violation of any applicable export control laws, rules or
regulations; (vii) distribute, permit access to, or sublicense
the Licensed Software as a stand-alone product; (viii) bypass,
disable, circumvent or remove any form of copy protection,
encryption, security or digital rights management or
authentication mechanism used by NVIDIA in connection with the
Licensed Software, or use the Licensed Software together with
any authorization code, serial number, or other copy
protection device not supplied by NVIDIA directly or through
an authorized reseller; (ix) use the Licensed Software for the
purpose of developing competing products or technologies or
assisting a third party in such activities; (x) use the
Licensed Software with any system or application where the use
or failure of such system or application can reasonably be
expected to threaten or result in personal injury, death, or
catastrophic loss including, without limitation, use in
connection with any nuclear, avionics, navigation, military,
medical, life support or other life critical application
(“Critical Applications”), unless the parties have entered
into a Critical Applications agreement; (xi) distribute any
modification or derivative work you make to the Licensed
Software under or by reference to the same name as used by
NVIDIA; or (xii) use the Licensed Software in any manner that
would cause the Licensed Software to become subject to an Open
Source License. Nothing in the AGREEMENT shall be construed to
give you a right to use, or otherwise obtain access to, any
source code from which the Software or any portion thereof is
compiled or interpreted. You acknowledge that NVIDIA does not
design, test, manufacture or certify the Licensed Software for
use in the context of a Critical Application and NVIDIA shall
not be liable to you or any third party, in whole or in part,
for any claims or damages arising from such use. You agree to
defend, indemnify and hold harmless NVIDIA and its Affiliates,
and their respective employees, contractors, agents, officers
and directors, from and against any and all claims, damages,
obligations, losses, liabilities, costs or debt, fines,
restitutions and expenses (including but not limited to
attorney’s fees and costs incident to establishing the right
of indemnification) arising out of or related to you and your
Enterprise, and their respective employees, contractors,
agents, distributors, resellers, end users, officers and
directors use of Licensed Software outside of the scope of the
AGREEMENT or any other breach of the terms of the AGREEMENT.


1.2.2. Third Party License Obligations

You acknowledge and agree that the Licensed Software may
include or incorporate third party technology (collectively
“Third Party Components”), which is provided for use in or
with the Software and not otherwise used separately. If the
Licensed Software includes or incorporates Third Party
Components, then the third-party pass-through terms and
conditions (“Third Party Terms”) for the particular Third
Party Component will be bundled with the Software or otherwise
made available online as indicated by NVIDIA and will be
incorporated by reference into the AGREEMENT. In the event of
any conflict between the terms in the AGREEMENT and the Third
Party Terms, the Third Party Terms shall govern. Copyright to
Third Party Components are held by the copyright holders
indicated in the copyright notices indicated in the Third
Party Terms.

Audio/Video Encoders and Decoders

You acknowledge and agree that it is your sole responsibility
to obtain any additional third party licenses required to
make, have made, use, have used, sell, import, and offer for
sale your products or services that include or incorporate any
Third Party Components and content relating to audio and/or
video encoders and decoders from, including but not limited
to, Microsoft, Thomson, Fraunhofer IIS, Sisvel S.p.A.,
MPEG-LA, and Coding Technologies as NVIDIA does not grant to
you under the AGREEMENT any necessary patent or other rights
with respect to audio and/or video encoders and decoders.


1.2.3. Limited Rights

Your rights in the Licensed Software are limited to those
expressly granted under the AGREEMENT and no other licenses
are granted whether by implication, estoppel or otherwise.
NVIDIA reserves all rights, title and interest in and to the
Licensed Software not expressly granted under the AGREEMENT.


1.3. Confidentiality

Neither party will use the other party’s Confidential
Information, except as necessary for the performance of the
AGREEMENT, nor will either party disclose such Confidential
Information to any third party, except to personnel of NVIDIA
and its Affiliates, you, your Enterprise, your Enterprise
Contractors, and each party’s legal and financial advisors
that have a need to know such Confidential Information for the
performance of the AGREEMENT, provided that each such
personnel, employee and Contractor is subject to a written
agreement that includes confidentiality obligations consistent
with those set forth herein. Each party will use all
reasonable efforts to maintain the confidentiality of all of
the other party’s Confidential Information in its possession
or control, but in no event less than the efforts that it
ordinarily uses with respect to its own Confidential
Information of similar nature and importance. The foregoing
obligations will not restrict either party from disclosing the
other party’s Confidential Information or the terms and
conditions of the AGREEMENT as required under applicable
securities regulations or pursuant to the order or requirement
of a court, administrative agency, or other governmental body,
provided that the party required to make such disclosure (i)
gives reasonable notice to the other party to enable it to
contest such order or requirement prior to its disclosure
(whether through protective orders or otherwise), (ii) uses
reasonable effort to obtain confidential treatment or similar
protection to the fullest extent possible to avoid such public
disclosure, and (iii) discloses only the minimum amount of
information necessary to comply with such requirements.


1.4. Ownership

You are not obligated to disclose to NVIDIA any modifications
that you, your Enterprise or your Contractors make to the
Licensed Software as permitted under the AGREEMENT. As between
the parties, all modifications are owned by NVIDIA and
licensed to you under the AGREEMENT unless otherwise expressly
provided in a Supplement. The Licensed Software and all
modifications owned by NVIDIA, and the respective Intellectual
Property Rights therein, are and will remain the sole and
exclusive property of NVIDIA or its licensors, whether the
Licensed Software is separate from or combined with any other
products or materials. You shall not engage in any act or
omission that would impair NVIDIA’s and/or its licensors’
Intellectual Property Rights in the Licensed Software or any
Do you accept the previously read EULA?
accept/decline/quit: accept

Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 396.26?
(y)es/(n)o/(q)uit: y

Do you want to install the OpenGL libraries?
(y)es/(n)o/(q)uit [ default is yes ]:

Do you want to run nvidia-xconfig?
This will update the system X configuration file so that the NVIDIA X driver
is used. The pre-existing X configuration file will be backed up.
This option should not be used on systems that require a custom
X configuration, such as systems with multiple GPU vendors.
(y)es/(n)o/(q)uit [ default is no ]: y

Install the CUDA 9.2 Toolkit?
(y)es/(n)o/(q)uit: y

Enter Toolkit Location
[ default is /usr/local/cuda-9.2 ]:

Do you want to install a symbolic link at /usr/local/cuda?
(y)es/(n)o/(q)uit: y

Install the CUDA 9.2 Samples?
(y)es/(n)o/(q)uit: y

Enter CUDA Samples Location
[ default is /home/leo ]: /home/leo/cuda-example

Installing the NVIDIA display driver...
Installing the CUDA Toolkit in /usr/local/cuda-9.2 ...
Missing recommended library: libGLU.so
Missing recommended library: libXi.so
Missing recommended library: libXmu.so

Installing the CUDA Samples in /home/leo/cuda-example ...
Copying samples to /home/leo/cuda-example/NVIDIA_CUDA-9.2_Samples now...
Finished copying samples.

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

Driver: Installed
Toolkit: Installed in /usr/local/cuda-9.2
Samples: Installed in /home/leo/cuda-example, but missing recommended libraries

Please make sure that
- PATH includes /usr/local/cuda-9.2/bin
- LD_LIBRARY_PATH includes /usr/local/cuda-9.2/lib64, or, add /usr/local/cuda-9.2/lib64 to /etc/ld.so.conf and run ldconfig as root

To uninstall the CUDA Toolkit, run the uninstall script in /usr/local/cuda-9.2/bin
To uninstall the NVIDIA Driver, run nvidia-uninstall

Please see CUDA_Installation_Guide_Linux.pdf in /usr/local/cuda-9.2/doc/pdf for detailed information on setting up CUDA.

Logfile is /tmp/cuda_install_6554.log

问题集锦

  1. ERROR: Unable to load the ‘nvidia-drm’ kernel module.

One probable reason is that the system is boot from UEFI but Secure Boot option is turned on in the BIOS setting. Turn it off and the problem will be solved.

  1. Error: You Appear To Be Running An X Server; Please Exit X Before Installing
    1
    2
    3
    4
    5
    6
    7
    8
    9
    1.按住CTRL+ALT+F1 进入命令行

    2.sudo service lightdm stop 或者 sudo stop lightdm

    3.sudo init 3

    4.安装驱动程序:#: sudo ./NVIDIA-Linux-x86_64-177.67-pkg2.run //当前目录下执行NVIDIA驱动程序

    5.按照提示安装完成,简单方法重启就好了 sudo reboot
处无为之事,行不言之教;作而弗始,生而弗有,为而弗恃,功成不居!

欢迎关注我的其它发布渠道