TensorFlow安装与配置

来源:互联网 发布:51talk软件下载 编辑:程序博客网 时间:2024/06/05 09:59

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
注意此处要关闭nvidia,使用操作:

exit X

首先下载cuda,然后执行操作:

sudo sh cuda_8.0.61_375.26_linux-run

接下来就是各种选择:

The NVIDIA CUDA Toolkit provides command-line and graphicaltools for building, debugging and optimizing the performanceof applications accelerated by NVIDIA GPUs, runtime and mathlibraries, and documentation including programming guides,Do you accept the previously read EULA?accept/decline/quit: acceptInstall NVIDIA Accelerated Graphics Driver for Linux-x86_64 375.26?(y)es/(n)o/(q)uit: yDo you want to install the OpenGL libraries?(y)es/(n)o/(q)uit [ default is yes ]: yDo you want to run nvidia-xconfig?This will update the system X configuration file so that the NVIDIA X driveris used. The pre-existing X configuration file will be backed up.This option should not be used on systems that require a customX configuration, such as systems with multiple GPU vendors.(y)es/(n)o/(q)uit [ default is no ]: yInstall the CUDA 8.0 Toolkit?(y)es/(n)o/(q)uit: yEnter 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: yInstall the CUDA 8.0 Samples?(y)es/(n)o/(q)uit: n

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.tgzsudo 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 updatesudo apt-get upgradewget  https://bootstrap.pypa.io/get-pip.pysudo python3 get-pip.py

接下来安装tensorflow:

sudo pip install tensorflow_gpu-1.4.0rc1-cp36-cp36m-linux_x86_64.whl 

查看python和tensorflow版本以及安装路径:

pythonimport tensorflow as tftf.__version__tf.__path__

查看cuda 版本

cat /usr/local/cuda/version.txt

cudnn 版本

cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2
原创粉丝点击