Ubuntu 16.04 搭建 RStudio Server + Jupyter Notebook Server + TensorFlow-GPU 服务器

1.安装Ubuntu 16.04 操作系统

  • 安装过程不在此赘述

2.Ubuntu切换国内源

  • 修改etc/apt/source.list文件,替换内容为(以下可选):
  • 清华大学
# deb cdrom:[Ubuntu 16.04 LTS _Xenial Xerus_ - Release amd64 (20160420.1)]/ xenial main restricted
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security multiverse
  • 阿里云
# deb cdrom:[Ubuntu 16.04 LTS _Xenial Xerus_ - Release amd64 (20160420.1)]/ xenial main restricted
deb-src http://archive.ubuntu.com/ubuntu xenial main restricted #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties
deb http://archive.canonical.com/ubuntu xenial partner
deb-src http://archive.canonical.com/ubuntu xenial partner
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse
  • 东北大学
deb-src http://mirror.neu.edu.cn/ubuntu/ xenial main restricted #Added by software-properties
deb http://mirror.neu.edu.cn/ubuntu/ xenial main restricted
deb-src http://mirror.neu.edu.cn/ubuntu/ xenial restricted multiverse universe #Added by software-properties
deb http://mirror.neu.edu.cn/ubuntu/ xenial-updates main restricted
deb-src http://mirror.neu.edu.cn/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties
deb http://mirror.neu.edu.cn/ubuntu/ xenial universe
deb http://mirror.neu.edu.cn/ubuntu/ xenial-updates universe
deb http://mirror.neu.edu.cn/ubuntu/ xenial multiverse
deb http://mirror.neu.edu.cn/ubuntu/ xenial-updates multiverse
deb http://mirror.neu.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirror.neu.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties
deb http://archive.canonical.com/ubuntu xenial partner
deb-src http://archive.canonical.com/ubuntu xenial partner
deb http://mirror.neu.edu.cn/ubuntu/ xenial-security main restricted
deb-src http://mirror.neu.edu.cn/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties
deb http://mirror.neu.edu.cn/ubuntu/ xenial-security universe
deb http://mirror.neu.edu.cn/ubuntu/ xenial-security multiverse
  • 更新
$ sudo apt-get update
$ sudo apt-get upgrade

3.下载并安装r-base-core

  • 见另一篇文章:《Ubuntu 14.04 R 数据分析 环境 搭建,非虚拟机只需跳过前面VMware的步骤》

4.下载并安装RStudio-Server

  • 直接下载链接中的deb,双击安装
https://download2.rstudio.org/rstudio-server-1.1.456-amd64.deb

5.查看和切换RStudio-Server状态

  • 查看
$ sudo rstudio-server status
  • 开启
$ sudo rstudio-server start
  • 关闭
$ sudo rstudio-server stop
  • 开启后就可以使用了

本地浏览器:localhost:8787
其它浏览器:服务器ip:8787
账户密码为Ubuntu的登录账户密码

6.下载和安装Anaconda

  • 直接去下面的链接找最新的适配的版本
https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/
本人用的是:https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-5.2.0-Linux-x86_64.sh
  • 然后进入到下载的sh所在的目录
$ bash ./Ana.........sh
  • 一路Enter+yes
  • 搞定

7.配置Jupyter Notebook Server

  • 添加jupyter登录密码
$ jupyter notebook password
  • 这里有可能失败,如果提示json不存在,我们手动创建.jupyter目录
$ mkdir ~/.jupyter
  • 然后重试
$ jupyter notebook password
  • 创建并打开配置文件
$ jupyter notebook --generate-config
$ gedit ~/.jupyter/jupyter_notebook_config.py
  • 修改配置文件(注意去掉注释)
c.NotebookApp.ip='*'
c.NotebookApp.notebook_dir = '/home/username/jupyter_nb'(此处自定义即可)
c.NotebookApp.open_browser = False
c.NotebookApp.port = 8888
  • 保存
  • 进入命令行,启动Jupyter Notebook
$ jupyter notebook
  • 现在Jupyter Notebook Server已经可以正常使用了

本地浏览器:localhost:8888
其它浏览器:服务器ip:8888
密码为前面设置的密码

8.pip切换国内源(永久)

  • 修改~/.pip/pip.conf
  • 如果没有目录或文件,提前建好
  • 文件夹建立:

$ sudo mkdir ~/.pip
  • 文本文件建立:

$ sudo touch ~/.pip/pip.conf
  • 修改内容如下:
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple

9.配置ssh远程登录

$ sudo apt-get install openssh-server
$ sudo service ssh restart
  • 此时其他服务器或个人电脑可以通过ssh user@ip的形式访问该服务器了

10.NVIDIA驱动安装 (我的显卡是NVIDIA Geforce GTX960)

  • 官方驱动下载
http://www.nvidia.cn/Download/index.aspx?lang=cn
  • 关闭默认驱动
$ sudo gedit /etc/modprobe.d/blacklist.conf
#在最后一行添加:blacklist nouveau
$ sudo update-initramfs -u
$ sudo reboot
  • 重启后进行安装
#按Ctrl+Alt+F1进入命令行界面(这里要等一会儿)
$ lsmod | grep nouveau
$ sudo /etc/init.d/lightdm stop
$ cd 安装脚本放置的目录
$ sudo chmod a+x NVIDIA-...run(给安装脚本赋予可执行权限)
$ sudo ./NVIDIA-...run(安装)
$ sudo /etc/init.d/lightdm start
  • 安装完成,进入系统后测试是否安装成功
$ sudo nvidia-smi
$ sudo reboot

11.安装cuda 9.0

  • 下载地址
https://developer.nvidia.com/cuda-90-download-archive?target_os=Linux&target_arch=x86_64&target_distro=Ubuntu&target_version=1604&target_type=deblocal
  • 安装过程
$ cd 安装包放置的目录
$ sudo dpkg -i cuda...deb
$ sudo apt-key add /var/cuda-repo-9-0-local/7fa2af80.pub
$ sudo apt-get update
$ sudo apt-get install cuda
  • 配置环境
$ sudo gedit /etc/profile
#尾部输入
#export PATH=/usr/local/cuda-9.0/bin${PATH:+:${PATH}}
#如果是64位系统,输入: 
#export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
#如果是32位系统,输入: 
#export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
  • cuda 9.0安装结束
$ sudo reboot

12.安装cuDNN 7.0.5

  • 下载地址
https://developer.nvidia.com/cudnn
  • 安装过程
$ cd 安装包放置的目录
$ sudo dpkg -i libcudnn7_7.0.5-1...deb
  • cuDNN 7.0.5安装结束
$ sudo reboot

13.安装TensorFlow-GPU版本

$ pip install tensorflow-gpu

你可能感兴趣的:(Ubuntu 16.04 搭建 RStudio Server + Jupyter Notebook Server + TensorFlow-GPU 服务器)