本文主要记录了在新安装完 Centos 系统后的 NVIDIA 显卡驱动、cuda、cudnn、以及 TensorFlow 等 python 库的安装及配置。
更改启动设置
(1) 查看系统默认启动环境。
systemctl get-default
->graphical.target
(2) 将默认启动环境设置为命令行。systemctl set-default multi-user.target
(3)reboot
禁用系统自带的 nouveau 显卡驱动。
(4) run the NVIDIA driver file, it will create two
.conf
file to disable the nouveau driver for you under/etc/modeprobe.d
and/usr/...
重做内核镜像
(5)
mv /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r)-nouveau.img
# Backup image
(6)dracut /boot/initramfs-$(uname -r).img $(uname -r)
# Create a new image
(7)reboot
安装 NVIDIA 显卡驱动
(8) run the NVIDIA driver file again, finish the installation of NVIDIA driver.
安装 Cuda
(9) Install cuda 8.0, do not install the driver provided by cuda since we already installed the NVIDIA driver before.
(10) addexport PATH=/usr/local/cuda-8.0/bin:$PATH
andexport LD_LIBRARY_PATH=/usr/local/cuda-8/lib64:$LD_LIBRARY_PATH
to~/.bashrc
(11)source ~/.bashrc
解压 cudnn
(12)
tar zxvf cudnn.tgz
# extract cudnn files
copy extracted files to the corresponding folders under cuda installation directory
安装 Anaconda/python
(13) Install Ananconda. Do not add the Ananconda path to
/root/.bashrc
, add it to~/.bashrc
.
(14)source ~/.bashrc
安装 tensorflow 或其他 python 库
(15)
pip install tensorflow-gpu==1.0.0
. # Install GPU version tensorflow 1.0.0
注意,安装 1.0.0
的 tensorflow 时,numpy==1.16.2
貌似会报错。因此,需要 check 一下 Anaconda 中 numpy 的版本。如果需要安装,则安装 pip install numpy==1.14.2
。