服务器重装和配置:Ubuntu16.04 + Anaconda3 + GTX1080驱动 + CUDA8 + cuDNN + 常用工具安装

前一篇[基于Ubuntu16.04的GeForce GTX 1080驱动安装,遇到的问题及对应的解决方法]是在机器原有系统上安装GPU驱动,后来决定备份数据后重装系统,让服务器环境更干净清爽。

 

1.安装操作系统Ubuntu16.04

采用U盘启动安装的方式:

=> 插入系统U盘,开启电源

=> 按Delete键进入BIOS界面,在"Boot"中把"USB KEY"设到最高优先级(把Hard Disk设置到第二优先级,装好系统后拔掉U盘就会直接从硬盘启动),然后在"Save & Exit"中选择保存修改并重启

=> 按F11键进入选择系统菜单界面,这里选"Install Ubuntu"

=> 按照提示安装系统,选择语言,地区,划分分区等,这里是120G的sda,1T的sdb,32G内存,大致划分方法如下:

sda
  /boot 1G
  SWAP 32G
  / (120-1-32)G
sdb
  /home 1T

 

2.更新源

安装好系统后,先更新源,方便后面能比较快地下载各种软件包。

备份/etc/apt/sources.list,然后将内容全部替代为:

# deb cdrom:[Ubuntu 16.04 LTS _Xenial Xerus_ - Release amd64 (20160420.1)]/ xenial main restricted

# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.

deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
##测试版源
deb http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse
# 源码
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
##测试版源
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse
# Canonical 合作伙伴和附加
deb http://archive.canonical.com/ubuntu/ xenial partner
deb http://extras.ubuntu.com/ubuntu/ xenial main

然后进行更新:

$ sudo apt-get update
$ sudo apt-get upgrade

 

3.安装常用的工具

(1)terminator

$ sudo apt-get install terminator

=> 退出之前的终端,再重新ctrl+alt+t就可以进入新装的terminator

=> 在Preference设置终端背景,透明度,字体类型和大小等等

(2)vim

$ sudo apt-get install vim

(3)ssh

$ sudo apt-get install openssh-server

(本地机器ssh免密码登录服务器设置参考:http://www.cnblogs.com/bymo/p/7390619.html

(4)Sogou Pinyin输入法

下载deb安装包然后 sudo dpkg -i sogoupinyin_2.1.0.0086_amd64.deb

(详细参考:http://blog.csdn.net/leijiezhang/article/details/53707181

(5)google-chrome

# 将下载源加入到系统的源列表
$ sudo wget http://www.linuxidc.com/files/repo/google-chrome.list -P /etc/apt/sources.list.d/
#导入谷歌软件的公钥,用于下面步骤中对下载软件进行验证。如果顺利的话,命令将返回“OK”
$ wget -q -O - https://dl.google.com/linux/linux_signing_key.pub  | sudo apt-key add -
$ sudo apt-get update
$ sudo apt-get install google-chrome-stable
#启动
$ /usr/bin/google-chrome-stable

安装参考:https://www.cnblogs.com/don9/p/7289830.html

如果启动失败,解决方法参考:http://blog.csdn.net/qq_22551385/article/details/78172178

 

4.编程/深度学习环境配置

(1) Anaconda3

=> 从清华大学开源软件镜像站下载安装包 Anaconda3-5.0.1-Linux-x86_64.sh

=> 官方安装指南:https://docs.anaconda.com/anaconda/install/linux

$ sudo bash Anaconda3-5.0.1-Linux-x86_64.sh

期间会请求授权信息,输入yes;提示安装路径,默认是/home/<user>/anaconda3,本文修改到/opt/anaconda3;提示是否要将Anaconda的安装路径添加到PATH环境变量中,输入yes

(安装和其它测试参考:http://blog.csdn.net/huangjuegeek/article/details/73556763http://blog.csdn.net/xiaerwoailuo/article/details/70054429

 

(2)安装GTX1080驱动(nvidia367.27)

sudo add-apt-repository ppa:graphics-drivers/ppa  #第一次运行如果出现警告,按回车继续
sudo apt-get update
sudo apt-get install nvidia-367
sudo apt-get install mesa-common-dev
sudo apt-get install freeglut3-dev  

之后重启系统让GTX1080显卡驱动生效,然后用nvidia-smi命令可以查看到显卡设备

(之前这篇[基于Ubuntu16.04的GeForce GTX 1080驱动安装,遇到的问题及对应的解决方法]遇到那么多问题主要是因为之前的系统装过GTX1060的驱动,而本次在全新系统中的安装是比较顺畅的)

 

(3)下载和安装CUDA

=> GTX1080对应下载CUDA8(注意要登录账号才能下载),选择Ubuntu16.04系统runfile安装方案,1.4G

=> 执行 sudo sh cuda_8.0.27_linux.run 进行安装,安装过程中会有下面几个安装提示,后面的warning可以忽略

-------------------------------------------------------------
Do you accept the previously read EULA?
accept/decline/quit: accept  

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

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

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

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

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

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

Installing the CUDA Toolkit in /usr/local/cuda-8.0 ...
Missing recommended library: libXi.so
Missing recommended library: libXmu.so

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

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

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

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

To uninstall the CUDA Toolkit, run the uninstall script in /usr/local/cuda-8.0/bin

Please see CUDA_Installation_Guide_Linux.pdf in /usr/local/cuda-8.0/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 361.00 is required for CUDA 8.0 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_2761.log

 

安装完毕后,再声明一下环境变量,并将其写入到 ~/.bashrc 的尾部:

export PATH=$PATH:/usr/local/cuda-8.0/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-8.0/lib64

保存后,在终端输入 source ~/.bashrc 命令使修改生效.

后面的样例测试参考http://www.cnblogs.com/bymo/p/7987415.html

 

(4)安装cuDNN

=> 下载页面:https://developer.nvidia.com/rdp/cudnn-download

  同样需要登录账号才能下载,勾选同意License之后会出现各种版本的下载链接,前面装的是cuda_8.0.27所以这里对应下载cuDNN v6.0 (April 27, 2017), for CUDA 8.0,选择cuDNN v6.0 Library for Linux下载tgz文件)
=> 安装指导页面:http://docs.nvidia.com/deeplearning/sdk/cudnn-install/index.html 

  解压安装包,将相关链接库复制到cudn安装路径下的对应目录中:

# Unzip the cuDNN package.
$ tar -xzvf cudnn-8.0-linux-x64-v6.0.tgz
$ cd cuda
# Copy the following files into the CUDA Toolkit directory.
$ 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 /usr/local/cuda/lib64/libcudnn*

 

(5)virtualenv

sudo apt-get install python-virtualenv

虚拟环境virtualenv的配置和使用参考:http://www.cnblogs.com/bymo/p/7341338.html

 

后面有空的时候再配置一下Vim,先这样啦,晚安~

 

==========================================================

补充:

sudo pip install ipython
sudo pip install jupyter

 

posted @ 2017-12-14 10:40  焦距  阅读(1678)  评论(0编辑  收藏  举报