前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Ubuntu18.04下安装CUDA

Ubuntu18.04下安装CUDA

作者头像
foochane
发布2019-05-23 15:49:40
1.7K0
发布2019-05-23 15:49:40
举报
文章被收录于专栏:foochanefoochane

1.下载 cuda.xxx.run 文件

https://developer.nvidia.com/cuda-downloads,下载 cuda_9.1.85_387.26_linux.run文件

2.在终端运行该条指令即可:

$ sudo sh cuda_9.1.85_387.26_linux.run --no-opengl-libs

之后是一些提示信息,ctrl+c 直接结束后输入 accept。 在提示是否安装显卡驱动时,一定选择 no(之前安装过对应显卡版本的驱动). 其他各项提示选择是,并默认安装路径即可。提示有 y 的输入 y,没有则按 enter 键。

代码语言:javascript
复制
$ sudo sh cuda_9.1.85_387.26_linux.run 
[sudo] password for fc: 
Logging to /tmp/cuda_install_8138.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.

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 387.26?
(y)es/(n)o/(q)uit: n

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

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

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

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

Enter CUDA Samples Location
 [ default is /home/fc ]: 

Installing the CUDA Toolkit in /usr/local/cuda-9.1 ...
Missing recommended library: libGLU.so
Missing recommended library: libX11.so
Missing recommended library: libXi.so
Missing recommended library: libXmu.so
Missing recommended library: libGL.so

Installing the CUDA Samples in /home/fc ...
Copying samples to /home/fc/NVIDIA_CUDA-9.1_Samples now...
Finished copying samples.

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

Driver:   Not Selected
Toolkit:  Installed in /usr/local/cuda-9.1
Samples:  Installed in /home/fc, but missing recommended libraries

Please make sure that
 -   PATH includes /usr/local/cuda-9.1/bin
 -   LD_LIBRARY_PATH includes /usr/local/cuda-9.1/lib64, or, add /usr/local/cuda-9.1/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.1/bin

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

***WARNING: Incomplete installation! This installation did not install the CUDA Driver. A driver of version at least 384.00 is required for CUDA 9.1 functionality to work.
To install the driver using this installer, run the following command, replacing <CudaInstaller> with the name of this run file:
    sudo <CudaInstaller>.run -silent -driver

Logfile is /tmp/cuda_install_8138.log
Signal caught, cleaning up

之后声明一下环境变量,并将其写入到 ~/.bashrc 文件(在用户目录下)的尾部,输入内容如下

代码语言:javascript
复制
export PATH=/usr/local/cuda-9.1/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-9.1/lib64:$LD_LIBRARY_PATH

保存退出,并输入下面指令使环境变量立刻生效:

代码语言:javascript
复制
$source ~/.bashrc

3.设置环境变量和动态链接库,在命令行输入:

代码语言:javascript
复制
$ sudo vim /etc/profile

在打开的文件末尾加入:

代码语言:javascript
复制
export PATH=/usr/local/cuda/bin:$PATH

4.创建链接文件

代码语言:javascript
复制
$ sudo vim /etc/ld.so.conf.d/cuda.conf

在打开的文件中添加如下语句:

代码语言:javascript
复制
/usr/local/cuda/lib64

保存退出,然后执行

代码语言:javascript
复制
$ sudo ldconfig 

使链接立即生效。

5.测试 cuda 的 Samples

切换到 CUDA 9.1 Samples 默认安装路径(即在/home/用户/ work/NVIDIA_CUDA-9.1_Samples 目录下), 终端下输入

代码语言:javascript
复制
$ cd NVIDIA_CUDA-9.1_Samples
$ sudo make all -j4
$ cd bin/x86_64/linux/release
$ ./deviceQuery

如果 CUDA 安装成功,则有:

代码语言:javascript
复制
$ ./deviceQuery
./deviceQuery Starting...

 CUDA Device Query (Runtime API) version (CUDART static linking)

Detected 1 CUDA Capable device(s)

Device 0: "GeForce GT 635M"
  CUDA Driver Version / Runtime Version          9.0 / 8.0
  CUDA Capability Major/Minor version number:    2.1
  Total amount of global memory:                 1985 MBytes (2081619968 bytes)
  ( 2) Multiprocessors, ( 48) CUDA Cores/MP:     96 CUDA Cores
  GPU Max Clock rate:                            950 MHz (0.95 GHz)
  Memory Clock rate:                             900 Mhz
  Memory Bus Width:                              128-bit
  L2 Cache Size:                                 131072 bytes
  Maximum Texture Dimension Size (x,y,z)         1D=(65536), 2D=(65536, 65535), 3D=(2048, 2048, 2048)
  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: 32768
  Warp size:                                     32
  Maximum number of threads per multiprocessor:  1536
  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): (65535, 65535, 65535)
  Maximum memory pitch:                          2147483647 bytes
  Texture alignment:                             512 bytes
  Concurrent copy and kernel execution:          Yes with 1 copy engine(s)
  Run time limit on kernels:                     No
  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 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 = 9.0, CUDA Runtime Version = 8.0, NumDevs = 1, Device0 = GeForce GT 635M
Result = PASS

6.卸载CUDA

在/usr/local/cuda/bin 目录下,有cuda 自带的卸载工具uninstall_cuda_9.1.pl

代码语言:javascript
复制
$ cd /usr/local/cuda/bin
$ sudo ./uninstall_cuda_9.1.pl
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2018.07.30 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 1.下载 cuda.xxx.run 文件
  • 2.在终端运行该条指令即可:
  • 3.设置环境变量和动态链接库,在命令行输入:
  • 4.创建链接文件
  • 5.测试 cuda 的 Samples
  • 6.卸载CUDA
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档