centos7安装cuda

#########

CUDA (NVIDIA GPU) on a Centos7 安装步骤

#########

1.安装anaconda

https://www.anaconda.com/download/#linux
wget 下载地址
bash XXX

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

conda install caffe
conda install keras
pip install tensorflow-gpu jieba gensim

yum -y install lrzsz

pip install numpy
pip install Cython
pip install scipy

配置juypter

jupyter notebook --generate-config --allow-root
cd ~/.jupyter/
vim jupyter_notebook_config.py
c.NotebookApp.ip='*'
c.NotebookApp.open_browser = False
c.NotebookApp.port =8888#随便指定一个端口
c.NotebookApp.notebook_dir='/data/path'#设置根路径

cd /data
jupyter notebook --allow-root
拷贝地址浏览器里打开,新建py2文件,输入

from notebook.auth import passwd
passwd()

生成密码后继续修改配置文件
c.NotebookApp.password = u'sha:ce...刚才复制的那个密文'

修改后重启
nohup jupyter notebook --allow-root &

#########

2.CUDA

#########

2.1 disable selinux

sed -i 's/enforcing/disabled/g' /etc/selinux/config /etc/selinux/config

2.2 then reboot

shutdown -r now

2.3 disable postfix

systemctl stop postfix
systemctl disable postfix

2.4 enable swap

/bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
/sbin/mkswap /var/swap.1
/sbin/swapon /var/swap.1

2.5 library dependencies

yum -y install lapack-devel gcc-c++ kernel-devel libjpeg-turbo-devel zlib-devel pciutils git python-virtualenv lrzsz
yum -y update

2.6 get epel

cd /var/tmp
curl -O https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
yum -y install ./epel-release-latest-7.noarch.rpm

2.9 更新驱动程序

访问 http://www.geforce.cn/drivers/results/123918 点击下载
获取最新的下载地址 wget 下载
bash XXXX.run

2.10 下载cuda for centos 7 下面一步不要了

cuda 版本要和驱动版本保持一致 尽量下8.0左右的版本
http://developer.download.nvidia.com/compute/cuda/repos/rhel7/x86_64/
https://developer.nvidia.com/cuda-downloads
选择 linux x86_64 centos7 rmp(network) 获取下载地址 wget
rpm -i xxx.x86_64.rpm
yum clean all
yum install cuda

目前先过掉这一步,7.5有点太老了 get cuda RPM of rpms for centos 7

(must be done on GPU enabled host)

cd /var/tmp
curl -O http://developer.download.nvidia.com/compute/cuda/7.5/Prod/local_installers/cuda-repo-rhel7-7-5-local-7.5-18.x86_64.rpm
yum -y install ./cuda-repo-rhel7-7-5-local-7.5-18.x86_64.rpm
yum -y install cuda
cd /usr/local/cuda-7.5/samples/1_Utilities/deviceQuery
make
cp -p deviceQuery /root

2.12 install python-virtualenv

yum -y install python-virtualenv

2.13 create venv

cd /root
virtualenv deepenv

activate deepenv (within script?)

install pip pkgs

install cudarray (cuda enabled numpy)

cd /root
git clone https://github.com/andersbll/cudarray
cd cudarray
make
make install
python setup.py install

yum -y install libjpeg-turbo-devel

cd /root
git clone https://github.com/andersbll/deeppy
cd deeppy
python setup.py install

下载keras example

git clone https://github.com/keras-team/keras.git
python ./keras/example/mnist_cnn.py

报错 kernel version 384.66.0 does not match DSO version 387.26.0

其他方法

检查是否安装了GPU:
lspci | grep -i nvidia
检查GPU版本
lspci | grep -v vga
检查系统版本
uname -m && cat /etc/*release
检查gcc版本
gcc --version
检查是否正确安装kernel headers
yum install kernel-devel-(uname -r) kernel-headers-(uname -r)
查看驱动版本
cat /proc/driver/nvidia/version

你可能感兴趣的:(centos7安装cuda)