深度学习Linux+tensorflow+cudnn+cuda+anaconda开发环境搭建

搭建Linux+tensorflow+cudnn+cuda+anaconda开发环境

一.Ubuntu下载和安装(双系统)

1.登录https://cn.ubuntu.com/下载对应Ubuntu版本。

2.制作U盘启动器。

3.分区。

4.启动引导。

二.配置安装环境

sudo apt-get update

sudo apt-get install python-dev python-pip python-nose gcc g++ git gfortran

sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler

sudo apt-get install --no-install-recommends libboost-all-dev

sudo apt-get install libopenblas-dev liblapack-dev libatlas-base-dev

sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev

sudo apt-get install git cmake build-essential

三.禁用自带显卡驱动

sudo gedit /etc/modprobe.d/blacklist-nouveau.conf

blacklist nouveau option nouveau modeset=0

sudo update-initramfs -u

加入环境变量

sudo gedit ~/.bashrc

export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH

export LD_LIBRARY_PATH=/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH

source ~/.bashrc

 

 

四.安装NVIDIA显卡驱动

登录官网http://www.geforce.cn/drivers,根据自己的CPU型号下载对应的驱动。查看自己型号:sudo lshw -numeric -C display。如果之前安装过驱动,则卸载:sudo apt-get remove --purge nvidia-*。Ctrl-Alt+F1 进入命令行界面。

cd Downloads

sudo /etc/init.d/lightdm stop #关闭当前图形环境令

sudo chmod a+x NVIDIA-Linux-x86_64-375.66.run #给驱动run文件赋予执行权限

sudo ./NVIDIA-Linux-x86_64-375.66.run --no-x-check

--no-nouveau-check --no-opengl-files # 这句一定要加参数,不然就会循环登录

sudo /etc/init.d/lightdm start #重新启动图形环境

reboot

如果出现黑屏或者循环登录:

  1. 启动系统后在Grub界面,选择ubuntu系统的那一行,然后按E键,就会进入Grub的编辑状态。
  2. 在quiet splash 后面加(先打空格)nomodeset,然后按F10保存启动即可!!! 
  3. sudo vi /etc/default/grub 或 sudo gedit /etc/default/grub #编辑打开的文件,找到GRUB_CMDLINE_LINUX_DEFAULT那一行,在后面加上(在quiet splash后打一个空格) nomodeset(保险起见,nomodeset后面加多一个空格),保存,然后在终端输入 sudo update-grub 重启后就OK了!!!

装过程中可能出现以下情况:

  1. WARNING: Unable to find a suitable destination to install32-bit compatibility libraries. Your system may not be set up for 32-bitcompatibility. 32-bit compatibility files will not be installed; if you wishWARNING: Unable to find a suitable destination to install32-bit compatibility libraries. Your system may not be set up for 32-bitcompatibility. 32-bit compatibility files will not be installed; if you wish…….

忽略 

  1. would you like to run the nvidia-xconfig utility to automatically update your configurtion file so that the nvidia driver will be used when you restart X?…. 

    选择YES

  1.  Unable to load the kernel module ‘nvidia.ko’.  This happens most frequently when this kernel module was built against the wrong or improperly configured kernel sources, with a version of gcc that differs from the one used to build the target kernel, or if a driver such as rivafb/nvidiafb is present and prevents the NVIDIA kernel module from obtaining ownership of the NVIDIA graphics device(s), or NVIDIA GPU installed in this system is not supported by this NVIDIA Linux graphics driver release.

以管理员身份打开blacklist模块:vim    /etc/modprobe.d/blacklist.conf。添加以下部分并保存,重启电脑。

blacklist vga16fb
blacklist nouveau
blacklist rivafb
blacklist nvidiafb
blacklist rivatv

安装完成后,打开终端(快捷键Ctrl-alt+T),输入命令nvidia-settings ,会弹出一个窗口,即可查看显卡情况。

五.安装CUDA(可直接在anaconda中配置)

1.注意CUDA版本与显卡驱动版本的型号匹配:https://www.cnblogs.com/wolflzc/p/9117291.html

2.如果出现以下错误:

Error: unsupported compiler: 4.8.2. Use --override to override this check.

执行:sudo ./cuda_6.0.37_linux_64.run -toolkit -samples -silent -override

用anaconda配置TensorFlow-gpu+cudnn+cuda环境

  1. 进入所要配置环境的envs:source  activate  环境名
  2. 跟换清华源:

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/

conda conig --set show_channel_urls yes

  1. 安装tensorflow-gpu

conda install tensorflow-gpu==1.7.0

安装完成后测试编译环境即可。

 

 

 

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值