安装nvidia驱动:
CentOS 7.0 Nvidia显卡安装步骤:
1 在英伟达官网下载相应驱动:
http://www.nvidia.com/download/driverResults.aspx/122825/en-us
2 屏蔽默认带有的nouveau:
使用su命令切换到root用户下: su root
打开/lib/modprobe.d/dist-blacklist.conf
将nvidiafb注释掉。
#blacklist nvidiafb
然后添加以下语句:
blacklist nouveau
options nouveau modeset=0
3 重建initramfs image步骤:
# mv /boot/initramfs-(uname−r).img /boot/initramfs−(uname -r).img.bak
# dracut /boot/initramfs-(uname−r).img(uname−r)
4 修改运行级别为文本模式:
# systemctl set-default multi-user.target
5 重新启动, 使用root用户登陆:
# reboot
6 进入下载的驱动所在目录:
# chmod +x NVIDIA-Linux-x86_64-346.47.run
# ./NVIDIA-Linux-x86_64-346.47.run
安装过程中,选择accep,其余默认选择yes或者install
7 修改运行级别回图形模式:
# systemctl set-default graphical.target
8 重新启动:
# reboot
9 验证,结果如下图则成功:
$ nvidia-smi
安装cuda:
1下载安装包:
https://developer.nvidia.com/cuda-80-ga2-download-archive
选择rpm(local),如下:
2安装指令如下:
$ sudo rpm -i cuda-repo-rhel7-8-0-local-ga2-8.0.61-1.x86_64.rpm
$ sudo yum clean all
$ sudo yum install cuda
3配置环境变量:
$ vim ~/.bashrc
添加以下内容:
export CUDA_HOME=/usr/local/cuda-8.0
export PATH=/usr/local/cuda-8.0/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH="/usr/local/cuda-8.0/lib:${LD_LIBRARY_PATH}"
4执行以下指令后重启:
source ~/.bashrc
5.验证,结果显示PASS则安装成功:
$ cd /usr/local/cuda-8.0/samples/1_Utilities/bandwidthTest/
$ sudo make
$ cd /usr/local/cuda-8.0/samples/
$ ./bin/x86_64/linux/release/bandwidthTest
备注:
1. 若提示以下错误:
“error:unable to find the kernel source tree for the currently running kernel. please make sure you have installed the kernel source files for your kernel and that they are properly configured; on red hat linux system, for example, be sure you have the 'kernel-source' or 'kernel-devel' RPM installed. if you know the correct kernel source files are installed ,you may specify the kernel source path with the '--kernel-source-path' command line option.“
执行以下指令安装kernel-devel包:
$ sudo yum install kernel-devel-$(uname -r)
2. 报错“Error: Package:1:nvidia-kmod-375.51-2.el7.x86_64 (cuda) Requires: dkms“
安装dkms依赖:
$ sudo yum install epel-release
$ sudo yum install dkms
安装cuDNN:
1. nvidia网站下载安装包,需要注册,(这里选用cudnn-8.0-linux-x64-v6.0版,下载的后缀名可能不一样,直接改成.tgz就可以了):
https://developer.nvidia.com/cudnn
2. 解压生成cuda文件夹:
$ tar -zxvf cudnn-8.0-linux-x64-v6.0.tgz
3. 拷贝文件到CUDA安装目录:
$ sudo cp cuda/include/cudnn.h /usr/local/cuda/include
$ sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64
$ sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*
安装jdk:
1 在oracle官网下载安装包:
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
2 用rpm安装:
$ sudo rpm -i jdk-8u91-linux-x64.rpm
3 配置环境变量(具体jdk版本号需要进入/usr/java文件夹查看):
$ export JAVA_HOME=/usr/java/jdk1.8.0_91
安装bazel:
1 下载指定版本的安装脚本:
https://github.com/bazelbuild/bazel/releases
2 修改文件属性:
$ chmod +x bazel--installer-linux-x86_64.sh
3 安装:
$./bazel--installer-linux-x86_64.sh --user
4 配置PATH变量:
$ vim ~/.bashrc
添加:export PATH="$PATH:$HOME/bin"
安装tensorflow:
1 安装依赖:
$ sudo yum -y install numpy swig python-devel python-wheel python-pip zlib zlib-devel
2 在github上下载安装文件.zip,并解压:
https://github.com/tensorflow/tensorflow
$ unzip tensorflow*.zip
3 进入解压后的文件夹进行配置:
$ cd tensorflow
$ ./configure
参考配置如下:
4 编译(gpu版),这个过程有点长:
$ bazel build --config=opt --config=cuda //tensorflow/tools/pip_package:build_pip_package
5 生成.whl包:
$ bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg
6 安装生成的包:
$ sudo pip install /tmp/tensorflow_pkg/tensorflow-*.whl
7 重启。
8 命令行输入“python“,在python环境下执行“import tensorflow”,如无报错,则安装成功。