Table of Contents
系统安装
切换国内镜像站
安装Anaconda
安装显卡驱动
安装cuda 10
安装tensorflow-gpu
激活环境并运行python
参见:CentOS 镜像
su
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum makecache
cd #Anaconda3安装包所在路径
chmod +x Anaconda3-2019.10-Linux-x86_64.sh
./Anaconda3-2019.10-Linux-x86_64.sh # 安装过程中全部选yes
cd
conda config --set show_channel_urls yes
gedit .condarc
channels:
- defaults
show_channel_urls: true
channel_alias: https://mirrors.tuna.tsinghua.edu.cn/anaconda
default_channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
conda clean -i
参考:CentOS 7中以runfile形式安装CUDA 9.0
su
lspci | grep -i nvidia
yum install -y gcc gcc-c++
yum install -y kernel-devel-$(uname -r) kernel-headers-$(uname -r)
lsmod | grep nouveau
gedit /usr/lib/modprobe.d/blacklist-nouveau.conf
blacklist nouveau
options nouveau modeset=0
sudo dracut --force
systemctl set-default multi-user.target
init 3
计算机重启后进入命令行界面,输入用户名和密码进行登陆,登陆后安装驱动即可。
systemctl set-default graphical.target
init 5
chmod +x cuda_10.0.130_410.48_linux.run
sudo ./cuda_10.0.130_410.48_linux.run
export PATH=/usr/local/cuda/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
rpm -ivh libcudnn7-*.x86_64.rpm
rpm -ivh libcudnn7-devel-*.x86_64.rpm
rpm -ivh libcudnn7-doc-*.x86_64.rpm
cp -r /usr/src/cudnn_samples_v7/ $HOME
cd $HOME/cudnn_samples_v7/mnistCUDNN
make clean && make
./mnistCUDNN
rpm -ivh nccl-repo-rhel7-2.5.6-ga-cuda10.0-1-1.x86_64.rpm
conda create -n tf tensorflow-gpu=2.0
conda activate tf
python
在python命令提示符后输入:
import tensorflow as tf
tf.test.is_gpu_available()
返回‘True’,表示tensorflow-gpu可用。