TensorFlow的安装和配置一直都是一件很繁琐的事情,我已经安装啦很多次,但是每次都还是在查询安装,为了自己和大家参考,在此写一下安装过程。
查看
1.安装anaconda
首先在官网(www.continuum.io/downloads)下载anaconda3到本地,在下载文件所在文件夹路径下执行以下操作:
bash Anaconda3-4.4.0-Linux-x86_64.sh
中间会出现两次选择:
(1)许可证
Do you approve the license terms? [yes|no]
Please answer 'yes' or 'no':
输入:yes
(2)路径
Do you wish the installer to prepend the Anaconda3 install location to PATH in your /home/zcm/.bashrc ? [yes|no]
输入:yes
2.安装cuda
首先下载官网(https://developer.nvidia.com/accelerated-computing-toolkit)下载cuda,然后执行操作:
sudo sh cuda_8.0.61_375.26_linux-run
or
chmod u+x cuda_8.0.44_linux.run
sudo ./cuda_8.0.44_linux.run
接下来就是各种选择:
The NVIDIA CUDA Toolkit provides command-line and graphical
tools for building, debugging and optimizing the performance
of applications accelerated by NVIDIA GPUs, runtime and math
libraries, and documentation including programming guides,
Do you accept the previously read EULA?
accept/decline/quit: accept
Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 375.26?
(y)es/(n)o/(q)uit: n
Install the CUDA 8.0 Toolkit?
(y)es/(n)o/(q)uit: y
Enter Toolkit Location
[ default is /usr/local/cuda-8.0 ]:
Do you want to install a symbolic link at /usr/local/cuda?
(y)es/(n)o/(q)uit: y
Install the CUDA 8.0 Samples?
(y)es/(n)o/(q)uit: n
安装好cuda之后安装invidia驱动,在‘设置’——》‘详细信息’,里面更新,然后在‘软件和更新’——》‘附加驱动’,选择invidia,点击应用.
更新完成后,输入命令查看:
nvidia-smi
3.安装cudnn
首先在cudnn的下载文件夹路径中执行如下操作:
sudo cp *.tgz /usr/local/cuda/include/
cd /usr/local/cuda/include/
sudo tar -xzvf cudnn-8.0-linux-x64-v5.0-ga.tgz
sudo chmod a+r /usr/local/cuda/include/cuda/include/cudnn.h /usr/local/cuda/include/cuda/lib64/libcudnn*
4.安装TensorFlow
首先安装pip,用于python3的一些安装,操作:
sudo apt install python3-pip
更新pip:
sudo apt-get update
sudo apt-get upgrade
wget https://bootstrap.pypa.io/get-pip.py
sudo python3 get-pip.py
接下来安装tensorflow:
sudo pip install tensorflow_gpu-1.4.0rc1-cp36-cp36m-linux_x86_64.whl
查看python和tensorflow版本以及安装路径:
python
import tensorflow as tf
tf.__version__
tf.__path__
查看cuda 版本
cat /usr/local/cuda/version.txt
cudnn 版本
cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2
5.安装bazel
http://blog.csdn.net/sunflower_Yolanda/article/details/51635674