首页 » Linux » Ubuntu 16.04+CUDA8+CUDNN+Anaconda3+Tensorflow+Keras+Theano的安装

Ubuntu 16.04+CUDA8+CUDNN+Anaconda3+Tensorflow+Keras+Theano的安装

作者: vForce 分类: Linux 发布时间: 2017-04-05 19:04 ė浏览 24,487 次 6没有评论

1、下载Ubuntu 16.04的ISO,用UltraISO等工具写入到U盘里

2、插入U盘并从U盘启动

3、在选择界面,选中Install Ubuntu,按e进入编辑界面,将其中的“—”修改为“nomodeset”后按F10启动进入安装界面(不改会卡死黑屏)。安装完后执行以下命令开启SSH服务及其他常用组件

apt -y install vim openssh-server
echo "
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted universe multiverse

# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-proposed main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-proposed main restricted universe multiverse
" > /etc/apt/sources.list
apt-get update
apt-get upgrade

4、安装nVidia显卡驱动


service lightdm stop

chmod +x NVIDIA-Linux-x86_64-375.39.run

./NVIDIA-Linux-x86_64-375.39.run --no-opengl-files

apt install build-essential libgl1-mesa-dev libglu1-mesa-dev freeglut3-dev mesa-common-dev

安装完毕后自行nvidia-smi,如果看到显卡名字则完成

5、安装Anaconda


chmod +x Anaconda3-4.3.1-Linux-x86_64.sh

./Anaconda3-4.3.1-Linux-x86_64.sh

source ~/.bashrc

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

conda config --set show_channel_urls yes

6、安装CUDA


wget https://developer.nvidia.com/compute/cuda/8.0/Prod2/local_installers/cuda_8.0.61_375.26_linux-run

chmod +x cuda_8.0.61_375.26_linux.run

./cuda_8.0.61_375.26_linux.run --tmpdir=/tmp/

echo "

export PATH="/usr/local/anaconda3/bin:$PATH"
export PATH="/usr/local/cuda-8.0/bin:$PATH"
export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
export CUDA_ROOT=/usr/local/cuda-8.0/bin" >> /etc/bash.bashrc

安装完毕后自行进入sample里执行检查

cd 1_Utilities/deviceQuery

make

./deviceQuery

cd ../../5_Simulations/nbody/

make

./nbody -benchmark -numbodies=256000 -device=0

7、安装CUDNN


wget http://developer2.download.nvidia.com/compute/machine-learning/cudnn/secure/v5.1/prod_20161129/8.0/cudnn-8.0-linux-x64-v5.1.tgz?5zc3NqDhfywBGKHsI_EYDf2NliYHm01iF9G9Tz4pqSQoOKIMS-gS3eBRbyYAa1yRN86d3RNhfFByQWxkeIOG_NB2TfP2IRksxnvzNoH_LYbJa4jUoBHB7mzRZwCm1g1y8EOLnmLNgKZcPUqbefYWY3OI85qBOiV3MUtkbLt_edkSt-dyVIIvTCkHV2imWSjStLU5GNHpBew

tar zxvf cudnn-8.0-linux-x64-v5.1.tgz

cp cuda/include/cudnn.h /usr/local/cuda/include/

cp cuda/lib64/libcudnn* /usr/local/cuda/lib64/

chmod a+r /usr/local/cuda/include/cudnn.h

chmod a+r /usr/local/cuda/lib64/libcudnn*

8、安装Tensorflow


apt install libcupti-dev

pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.0.1-cp36-cp36m-linux_x86_64.whl

9、安装Keras


git clone https://github.com/fchollet/keras.git

cd keras

python setup.py install

conda install numpy scipy mkl nose sphinx nomkl

10、安装Theano


conda install theano pygpu

git clone https://github.com/Theano/libgpuarray.git

cd libgpuarray

git checkout tags/v0.6.2 -b v0.6.2

mkdir build

cd build

cmake .. -DCMAKE_BUILD_TYPE=Release

make && make install

cd ..

python setup.py build

python setup.py install

ldconfig

echo "

[global]
floatX = float32
device = gpu0

[lib]
cnmem = 1

[cuda]
root = /usr/local/cuda-8.0/lib64" > ~/.theanorc

本文出自 Tech Trace,转载时请注明出处及相应链接。

本文永久链接: https://www.qiujiahui.com/2017/04/05/ubuntu-16-04cuda8cudnnanaconda3tensorflowkerastheano%e7%9a%84%e5%ae%89%e8%a3%85/

0

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

Ɣ回顶部