linux安装 cuda.run,Ubuntu18.04下安装CUDA和cudnn

安装前需要注意的问题:

1 需要安装对应的驱动,具体参考下图:

00c37b09f0f3

安装过程可以参考:Ubuntu18.04安装nvidia显卡驱动

2 由于Cuda-9只支持gcc-6以下的版本,而Ubuntu18.04系统默认安装的gcc-7版,所以需要gcc降级,具体可以查看:linux下gcc、g++不同版本的安装和切换

1.下载 cuda.xxx.run 文件

这里需要注意的是cuda 9 并没有 18.04的安装包,所以下载16.04的版本,这里安装时没有问题的

00c37b09f0f3

00c37b09f0f3

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

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

之后是一些提示信息,ctrl+c 直接结束后输入 accept。

在提示是否安装显卡驱动时,一定选择 no(之前安装过对应显卡版本的驱动).

其他各项提示选择是,并默认安装路径即可。提示有 y 的输入 y,没有则按 enter 键。

$ 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 with the name of this run file:

sudo .run -silent -driver

Logfile is /tmp/cuda_install_8138.log

Signal caught, cleaning up

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

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

export LD_LIBRARY_PATH=/usr/local/cuda-9.1/lib64:$LD_LIBRARY_PATH

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

$source ~/.bashrc

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

$ sudo vim /etc/profile

在打开的文件末尾加入:

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

4.创建链接文件

$ sudo vim /etc/ld.so.conf.d/cuda.conf

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

/usr/local/cuda/lib64

保存退出,然后执行

$ sudo ldconfig

使链接立即生效。

5.测试 cuda 的 Samples

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

$ cd NVIDIA_CUDA-9.1_Samples

$ sudo make all -j4

$ cd bin/x86_64/linux/release

$ ./deviceQuery

如果 CUDA 安装成功,则有:

$ ./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

$ cd /usr/local/cuda/bin

$ sudo ./uninstall_cuda_9.1.pl

7 安装cudnn

00c37b09f0f3

并依次安装:

$ sudo dpkg -i libcudnn7_7.1.3.16-1+cuda9.1_amd64.deb

$ sudo dpkg -i libcudnn7-dev_7.1.3.16-1+cuda9.1_amd64.deb

$ sudo dpkg -i libcudnn7-doc_7.1.3.16-1+cuda9.1_amd64.deb

  • 0
    点赞
  • 0
    收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
©️2022 CSDN 皮肤主题:游动-白 设计师:我叫白小胖 返回首页
评论
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值