前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >配置CentOS7 GPU环境

配置CentOS7 GPU环境

作者头像
故事尾音
发布2019-12-18 16:29:02
1.6K0
发布2019-12-18 16:29:02
举报

基本配置

  1. 先装wget yum -y install wget
  2. 新建自己的文件夹 mkdir sunyan

安装Anoconda

  1. 下载Anoconda。注意最新Anoconda的是3.7版本的,但是tensorflow还没有更新到3.7,这里我们安装2018年5月发布的python 3.6版本。 wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-5.2.0-Linux-x86_64.sh
  2. 安装bzip2 yum install -y bzip2
  3. 安装Anoconda,一路yes即可。 bash Anaconda3-5.2.0-Linux-x86_64.sh
  4. 使能配置 source .bashrc
  5. 输入Python,查看是否配置正确

Conda安装TesnorFlow GPU版本

  1. 配置国内conda源。由于cudnn和cuda很大,conda又在国外,容易导致下载中断,这里我们配置国内中科大的镜像。 conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
  2. 安装 conda install tensorflow-gpu

我的cuda版本是9.0,cudnn版本是7.1.2,tensorflow-gpu版本是1.9.0。

安装NVIDIA驱动

  1. 安装gcc yum -y install gcc-c++
  2. 安装Open JDK yum install java-1.8.0-openjdk java-1.8.0-openjdk-devel
  3. 检测显卡驱动及型号 sudo rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org sudo rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm sudo yum install nvidia-detect

这里显示的是Tesla P4,410.66 NVIDIA driver

  1. 官网下载对应的驱动 wget http://cn.download.nvidia.com/tesla/384.145/NVIDIA-Linux-x86_64-384.145.run
  2. 屏蔽默认带有的nouveau,使用su命令切换到root用户下,然后修改/etc/modprobe.d/blacklist.conf 文件,如果系统没有该文件需要新建一个。 su root echo -e "blacklist nouveau\noptions nouveau modeset=0" > /etc/modprobe.d/blacklist.conf

然后查看一下文件内容:

代码语言:javascript
复制
cat /etc/modprobe.d/blacklist.conf
  1. 重建initramfs image mv /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r).img.bak dracut /boot/initramfs-$(uname -r).img $(uname -r)
  2. 修改运行级别为文本模式
代码语言:javascript
复制
systemctl set-default multi-user.target
  1. 重新启动, 使用root用户登陆,这里需要等待一下,约1分钟。 sudo iptables stop reboot
  2. 查看nouveau是否已经禁用,如果没有显示相关的内容,说明已禁用。 ls mod | grep nouveau
  3. 安装kenel-devel wget ftp://ftp.riken.jp/Linux/cern/centos/7/updates/x86_64/Packages/kernel-devel-3.10.0-693.17.1.el7.x86_64.rpm yum install kernel-devel-3.10.0-693.17.1.el7.x86_64.rpm
  4. 安装NVIDIA驱动,一路Enter即可 chmod +x NVIDIA-Linux-x86_64-384.145.run sh NVIDIA-Linux-x86_64-384.145.run

测试

  1. nvidia-smi测试和TensorFlow测试,显示GPU信息即可。报警告没有关系,是TF本身的警告,也可以通过pip install h5py==2.8.0rc1来解决。nvidia-smi python3 import tensorflow as tf sess = tf.Session()
  1. 更换PyPi为国内源 pip install pqi pqi use tuna pqi show
  2. 更换conda源为国内源 conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/main/ conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/ conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/ conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/msys2/ conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/bioconda/ conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/menpo/ conda config --set show_channel_urls yes
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2018-11-07,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 基本配置
  • 安装Anoconda
  • Conda安装TesnorFlow GPU版本
  • 安装NVIDIA驱动
  • 测试
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档