参考文章:(超完整)Linux(debian9)服务器配置tensorflow环境:nvidia驱动、CUDA、cudnn、anaconda
安装debian9
1、下载官方镜像,DVD版。
2、使用rufus-3.5制作安装U盘。注意是否需要UEFI选项。
3、语音现在英文,地区在other中选择中国。
4、选择软件xfce、ssh sever。
debian系统的配置
1、替换源为阿里云
mousepad /etc/apt/sources.list
deb http://mirrors.aliyun.com/debian stretch main contrib non-free
deb-src http://mirrors.aliyun.com/debian stretch main contrib non-free
deb http://mirrors.aliyun.com/debian stretch-updates main contrib non-free
deb-src http://mirrors.aliyun.com/debian stretch-updates main contrib non-free
deb http://mirrors.aliyun.com/debian-security stretch/updates main contrib non-free
deb-src http://mirrors.aliyun.com/debian-security stretch/updates main contrib non-free
2、安装sudo
#apt-get install sudo
mousepad /etc/sudoers
添加一行
"实际用户名" ALL=(ALL)ALL
3、安装搜狗输入法
a、搜狗官网下载.deb安装包
b、安装fcitx
sudo apt-get install fcitx
c、安装搜狗
sudo dpkg -i sougou*.deb
d、修复依赖关系
sudo apt --fix-broken install
e、重启桌面服务
sudo lightdm restart
f、配置fcitx config
4、安装NVIDIA显卡驱动
a、官网下载显卡驱动,例如,NVIDIA-Linux-x86_64-410.78.run
b、安装三大件
sudo apt-get install linux-headers-$(uname -r)
sudo apt-get install gcc
sudo apt-get install make
c、切换到命令行终端继续安装
ps:如果遇到命令行终端黑屏的情况,需要修改 GRUB为nomodeset
service lightdm stop
chmod +x NVIDIA-Linux-x86_64-410.78.run
./NVIDIA-Linux-x86_64-410.78.run
5、安装CUDA
a、官网下载CUDA,例如,cuda_9.0.176_384.81_linux-run,注意cuda版本和tensorflow版本的对应关系
sudo ./cuda_9.0.176_384.81_linux-run
b、在 /etc/profile添加两行路径
vim /etc/profile
在最后添加:
export PATH=/usr/local/cuda-9.0/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64:$LD_LIBRARY_PATH
使路径生效:
source /etc/profile
6、安装CUDNN
a、下载CUDNN,例如,cudnn-9.0-linux-x64-v7.4.2.24.tgz
b、解压缩
tar -xvzf cudnn-9.0-linux-x64-v7.4.2.24.tgz
c、解压获得一个文件夹
cd cuda
sudo cp include/cudnn.h /usr/local/cuda/include
sudo cp lib64/libcudnn.* /usr/local/cuda/lib64
7、安装tensorflow
a、安装pip3
sudo apt-get install python3-pip
b、pip3安装tensorflow
pip3 install --user tensorflow-gpu==1.12 -i https://mirrors.aliyun.com/pypi/simple/