Ubuntu服务器安装nvidia-430.64、cuda-10.1,cudnn-7.6.0和anaconda

7 篇文章 1 订阅
7 篇文章 1 订阅

配置环境

创建新用户

$ sudo useradd jiangcm -d /home/jiangcm/ -m
# 为新用户添加密码
$ sudo passwd jiangcm
# 为新用户增加sudoer权限
$ su root
$ sudo vim /etc/sudoers

在文本中添加命令

# 添加jiangcm ALL=(ALL)   ALL
jiangcm    ALL=(ALL:ALL) ALL

Nouveau禁用

查看是否安装nouveau:

ubuntu@ubuntu:~$ lsmod | grep nouveau
nouveau              1708032  0
video                  45056  1 nouveau
ttm                   106496  2 ast,nouveau
i2c_algo_bit           16384  3 igb,ast,nouveau
mxm_wmi                16384  1 nouveau
drm_kms_helper        172032  2 ast,nouveau
drm                   401408  5 drm_kms_helper,ast,ttm,nouveau
wmi                    24576  2 mxm_wmi,nouveau

禁用:

# 打开blacklist文件
$ sudo vim /etc/modprobe.d/blacklist.conf
# 将nouveau添加到命令中
blacklist nouveau
options nouveau modeset=0
# 保存文件后,更新
$ sudo update-initramfs -u
# 重新启动服务器
$ reboot
检查是否禁用
$ lspci | grep nouveau

安装gcc和cmake

# 安装
$ sudo apt-get install build-essential 
$ sudo apt-get install cmake
# 检测是否安装成功
$ gcc --version
$ cmake --version

根据型号下载并安装nvidia驱动,网上下载需要的版本:

查看GPU型号:

jiangcm@ubuntu:~/software$ lspci | grep -i vga
04:00.0 VGA compatible controller: NVIDIA Corporation Device 1e04 (rev a1)
05:00.0 VGA compatible controller: NVIDIA Corporation Device 1e04 (rev a1)
06:00.0 VGA compatible controller: NVIDIA Corporation Device 1e04 (rev a1)
07:00.0 VGA compatible controller: NVIDIA Corporation Device 1e04 (rev a1)
08:00.0 VGA compatible controller: NVIDIA Corporation Device 1e04 (rev a1)
0b:00.0 VGA compatible controller: NVIDIA Corporation Device 1e04 (rev a1)
0c:00.0 VGA compatible controller: NVIDIA Corporation Device 1e04 (rev a1)
0d:00.0 VGA compatible controller: NVIDIA Corporation Device 1e04 (rev a1)
0e:00.0 VGA compatible controller: NVIDIA Corporation Device 1e04 (rev a1)
0f:00.0 VGA compatible controller: NVIDIA Corporation Device 1e04 (rev a1)
12:00.0 VGA compatible controller: ASPEED Technology, Inc. ASPEED Graphics Family (rev 30)

根据PCI ID Repository查看版本,输入1e04,得到是2080Ti.

nvidia、cuda、cudnn和tensorflow版本的选择:

tensorflow与cuda版本对照表:

详细地址:tensorflow-cuda
在这里插入图片描述

cuda与nvidia驱动对照表

地址:cuda-nvidia
在这里插入图片描述

选用的版本如下:

NVIDIA-Linux-x86_64-430.64.run

cuda_10.1.105_418.39_linux.run

cudnn-10.1-linux-x64-v7.6.0.64.tgz

考虑到安装tensorflow1.X版本,后续会安装不同版本的cuda,到时候会切换不同版本的cuda,便于调用tensorflow1.X。

安装nvidia驱动

# Ctrl+Alt+F1 进入tty1终端模式,并且输入下面命令关闭显示管理:
$ sudo service lightdm stop
# 安装驱动
sudo ./NVIDIA-Linux-x86_64-430.64.run --no-opengl-files

步骤如下:
nvidia1
nvidia2

nvidia3
nvidia4

查看安装结果:

$ nvidia-smi

安装cuda

安装

下载指定版本的cuda和cudnn,我这里下载的是cuda_10.1.105_418.39_linux.runcudnn-10.1-linux-x64-v7.6.0.64.tgz

# cd进入cuda安装包(.run文件)所在的目录下,打开终端
$ sudo sh cuda_10.1.105_418.39_linux.run  					

第一选项为accept.

之后为取消Driver的安装,因为之前已经安装过了。通过Enter键可以取消。
cuda

然后在选择Install,进行安装。

配置环境

# 打开文件~/.bashrc
$ vvim ~/.bahsrc
# 添加命令到文本中
export PATH="/usr/local/cuda/bin:$PATH"
export LD_LIBRARY_PATH="/usr/lcoal/cuda/lib64:$LD_LIBRARY_PATH"
# 保存后激活
$ source ~/.bashrc

同时在/etc/profile中也配置相同的路径。

检测是否安装成功

$ cd /usr/local/cuda/samples/1_Utilities/deviceQuery
$ sudo make
$ ./deviceQuery

有如下结果表示安装成功:

jiangcm@ubuntu:/usr/local/cuda/samples/1_Utilities/deviceQuery$ ./deviceQuery 
./deviceQuery Starting...

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

Detected 10 CUDA Capable device(s)

Device 0: "GeForce RTX 2080 Ti"
  CUDA Driver Version / Runtime Version          10.1 / 10.1
  CUDA Capability Major/Minor version number:    7.5
  Total amount of global memory:                 11019 MBytes (11554717696 bytes)
  (68) Multiprocessors, ( 64) CUDA Cores/MP:     4352 CUDA Cores
  GPU Max Clock rate:                            1545 MHz (1.54 GHz)
  Memory Clock rate:                             7000 Mhz
  Memory Bus Width:                              352-bit
  L2 Cache Size:                                 5767168 bytes
  Maximum Texture Dimension Size (x,y,z)         1D=(131072), 2D=(131072, 65536), 3D=(16384, 16384, 16384)
  Maximum Layered 1D Texture Size, (num) layers  1D=(32768), 2048 layers
  Maximum Layered 2D Texture Size, (num) layers  2D=(32768, 32768), 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: 65536
  Warp size:                                     32
  Maximum number of threads per multiprocessor:  1024
  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): (2147483647, 65535, 65535)
  Maximum memory pitch:                          2147483647 bytes
  Texture alignment:                             512 bytes
  Concurrent copy and kernel execution:          Yes with 3 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 supports Compute Preemption:            Yes
  Supports Cooperative Kernel Launch:            Yes
  Supports MultiDevice Co-op Kernel Launch:      Yes
  Device PCI Domain ID / Bus ID / location ID:   0 / 4 / 0
  Compute Mode:
     < Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >
     ...

安装cudnn

解压cudnn

$ tar -xvf cudnn-10.1-linux-x64-v7.6.0.64.tgz

将文件复制到指定cuda的路径中,并更改权限

sudo cp cuda/include/cudnn.h /usr/local/cuda/include/ 
sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64/ 
sudo chmod a+r /usr/local/cuda/include/cudnn.h 
sudo chmod a+r /usr/local/cuda/lib64/libcudnn*

查看cudnn版本,确认安装成功

cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2

安装Anaconda

下载anaconda到本地.

# 安装
$ bash ./Anaconda3-5.3.1-Linux-x86_64.sh

...
pyopenssl
    A thin Python wrapper around (a subset of) the OpenSSL library.

kerberos (krb5, non-Windows platforms)
    A network authentication protocol designed to provide strong authentication for client/server applications by using secret-key cryptography.

cryptography
    A Python library which exposes cryptographic recipes and primitives.


Do you accept the license terms? [yes|no]
>>> yes

回车使用默认目录

Anaconda3 will now be installed into this location:
/home/jiangcm/anaconda3

  - Press ENTER to confirm the location
  - Press CTRL-C to abort the installation
  - Or specify a different location below

[/home/jiangcm/anaconda3] >>> 

是否把anaconda的bin添加到用户的环境变量中?输入yes

Do you wish the installer to initialize Anaconda3
in your /home/jiangcm/.bashrc ? [yes|no]
[no] >>> yes

是否安装VSCode,输入no

To install Visual Studio Code, you will need:
  - Administrator Privileges
  - Internet connectivity

Visual Studio Code License: https://code.visualstudio.com/license

Do you wish to proceed with the installation of Microsoft VSCode? [yes|no]
>>> no

重新打开一个窗口,输入

conda activte base

激活默认环境。安装成功。

ed:

  • Administrator Privileges
  • Internet connectivity

Visual Studio Code License: https://code.visualstudio.com/license

Do you wish to proceed with the installation of Microsoft VSCode? [yes|no]

no


重新打开一个窗口,输入

```shell
conda activte base

激活默认环境。安装成功。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值