最近老板突然要说做项目,双手一挥就申请了张显卡,因此记录下这篇文档;
系统 / Ubunto16.04
显卡 / Nvidia GTX 1070ti
-
NVIDIA显卡驱动
-
安装准备
- 屏蔽nouveau开源驱动
touch /etc/modprobe.d/blacklist-nouveau.conf echo "blacklist nouveau" >>blacklist-nouveau.conf echo "options nouveau modeset = 0" >>blacklist-nouveau.conf
- 更新前可以去
blacklist-nouveau.conf
查看命令是否添加成功,之后执行更新:
sudo update-initramfs -u
- 去Nvidia官网下载和显卡对应的驱动,我的是GTX1070ti,对应的最新的驱动是
NVIDIA-Linux-x86_64-390.48.run
-
安装NVIDIA显卡驱动:
- 进入字符界面
Ctrl+alt+F1
之后,输入同户名和密码,登陆成功后执行:
sudo service lightdm stop
- 安装:其中
–no-opengl-files
很重要,不然安装后重启会出现循环登录的问题。
sudo chmod 777 NVIDIA-Linux-x86_64-390.48.run //执行权限 sudo sh NVIDIA-Linux-x86_64-390.48.run –no-opengl-files //执行 sudo service lightdm start sudo reboot
- 重启如果能够顺利登录,恭喜,之后测试是否安装成功:
打印出gpu相关信息表示安装成功。nvidia-smi
- 进入字符界面
-
安装CUDA-8.0
- 安装依赖:
- 设置源:
将aliyun的源添加到# 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
/etc/apt/source.list
中; - 安装相关依赖库:
sudo apt-get install freeglut3-dev build-essential libx11-dev sudo apt-get install libxmu-dev libxi-dev libgl1-mesa-glx libglu1-mesa sudo apt-get install libglu1-mesa-dev ```
- 安装依赖:
-
安装:ubunto16系统默认的
gcc-5.4.0
就支持cuda-8.0
,我的cuda-runfile文件是cuda_8.0.61_375.26_linux-run
sudo sh cuda_8.0.44_linux.run --no-opengl-libs
这里没有安装opengl,不会出现循环登录的bug;
- 添加环境变量
vim ~/.bashrc export PATH=/usr/local/cuda-8.0/bin:$PATH export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64:$LD_LIBRARY_PATH sudo vim /etc/profile export CUDA_HOME=/usr/local/cuda-8.0
- 设置动态链接库
sudo vim /etc/profile
写入
export PATH = /usr/local/cuda/bin:$PATH
创建
cuda.conf
文件sudo gedit /etc/ld.so.conf.d/cuda.conf
添加以下路径
/usr/local/cuda/lib64
执行链接生效
sudo ldconfig sudo reboot
- 测试cuda是否安装成功
得到以下结果表示安装成功。cd /usr/local/cuda-8.0/samples/1_Utilities/deviceQuery sudo make ./deviceQuery
-
安装cuDNN-5.1
- Cuda8.0对应的cnDNN版本是5.1,去官网注册下载;
- 下载之后解压,将cuDNN里的文件copy到CUDA目录;
sudo cp cudnn.h /usr/local/cuda/include/ sudo cp lib* /usr/local/cuda/lib64/ cd /usr/local/cuda/lib64/ sudo rm -rf libcudnn.so libcudnn.so.5 sudo ln -s libcudnn.so.5.1.5 libcudnn.so.5 sudo ln -s libcudnn.so.5 libcudnn.so
-
安装python
- 安装setuptools依赖的zlib库;
download:http://www.zlib.net/ ./configure --prefix=/usr/local/zlib/ make make install
添加链接;
//将--prefix目录添加到zlib.conf中 sudo vim /etc/ld.so.conf.d/zlib.conf ldconfig
- 安装setuptools;
download:https://pypi.org/project/setuptools/ sudo python setup.py install
- 安装pip;
sudo python setup.py install
-
安装tensorflow
pip安装:
//gpu-python2 sudo pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.2.0-cp27-none-linux_x86_64.whl //cpu-python2 sudo pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.2.0-cp27-none-linux_x86_64.whl //gpu-python3 sudo pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.2.0-cp34-cp34m-linux_x86_64.whl //cpu-python3 sudo pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.2.0-cp34-cp34m-linux_x86_64.whl
-
总结
这样环境就搭好了,可以愉快的烧GPU啦~
-
网友评论