前言:

对于深度学习来说,各种框架torch,caffe,keras,mxnet,tensorflow,pandapanda环境要求各一,如果我们在一台服务器上部署了较多的这样的框架,那么各种莫名的冲突

会一直伴随着你,吃过很多次亏之后,慢慢的接触了Anaconda,真的是很爽的一个功能,来管理环境配置。我们进行tensorflow安装的时候,还是使用Anaconda,鉴于国内墙太高

,我们使用了Tsinghua的镜像文件,清华大学的Anaconda介绍地址见:https://mirror.tuna.tsinghua.edu.cn/help/anaconda/

这里记录下linux的安装方式:

 所使用的系统: ubuntu16.

  安装步骤
: 先登录到这个页面:https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/
   . 下载: wget -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda2-2.4.1-Linux-x86_64.sh
. 运行: bash Anaconda2-.i.-Linux-x86_64.sh [中间会有几个询问,全部设置yes或者y]
  . 设置镜像仓库:
     TUNA 还提供了 Anaconda 仓库的镜像,运行以下命令:
       conda config
--add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
       conda config --set show_channel_urls yes
     即可添加 Anaconda Python 免费仓库。
     运行 conda install numpy 测试一下吧。
. 安装tensorflow:
5.1 查询conda下的tensorflow可以利用的镜像:
      anaconda search -t conda tensorflow

  大概会出现这些信息:

gxjun@gxjun:~$ anaconda search -t conda tensorflow
Using Anaconda API: https://api.anaconda.org
Run 'anaconda show <USER/PACKAGE>' to get more details:
Packages:
Name | Version | Package Types | Platforms
------------------------- | ------ | --------------- | ---------------
HCC/tensorflow | 1.0. | conda | linux-
HCC/tensorflow-cpucompat | 1.0. | conda | linux-
HCC/tensorflow-fma | 1.0. | conda | linux-
SentientPrime/tensorflow | 0.6. | conda | osx-
: TensorFlow helps the tensors flow
acellera/tensorflow-cuda | 0.12. | conda | linux-
anaconda/tensorflow | 1.1. | conda | linux-ppc64le, linux-, osx-, win-
anaconda/tensorflow-gpu | 1.1. | conda | linux-ppc64le, linux-, win-
conda-forge/r-tensorflow | 0.7 | conda | linux-, osx-, win-
conda-forge/tensorflow | 1.2. | conda | linux-, win-, osx-
: TensorFlow helps the tensors flow
creditx/tensorflow | 0.9. | conda | linux-
: TensorFlow helps the tensors flow
derickl/tensorflow | 1.1. | conda | osx-
dhirschfeld/tensorflow | 1.2. | conda | win-
: Computation using data flow graphs for scalable machine learning
dseuss/tensorflow | | conda | osx-
guyanhua/tensorflow | 1.0. | conda | linux-
ijstokes/tensorflow | 2017.03.03.1349 | conda, ipynb | linux-
jjh_cio_testing/tensorflow | 1.2. | conda | linux-
: TensorFlow is a machine learning library
jjh_cio_testing/tensorflow-gpu | 1.2. | conda | linux-
: TensorFlow is a machine learning library
jjh_ppc64le/tensorflow | 1.2. | conda | linux-ppc64le
: TensorFlow is a machine learning library
jjh_ppc64le/tensorflow-gpu | 1.2. | conda | linux-ppc64le
: TensorFlow is a machine learning library
jjhelmus/tensorflow | 0.12.0rc0 | conda, pypi | linux-, osx-
: TensorFlow helps the tensors flow
jjhelmus/tensorflow-gpu | 1.0. | conda | linux-
kevin-keraudren/tensorflow | 0.9. | conda | linux-
lcls-rhel7/tensorflow | 1.1. | conda | linux-
marta-sd/tensorflow | 1.2. | conda | linux-
marta-sd/tensorflow-gpu | 1.2. | conda | linux-
memex/tensorflow | 0.5. | conda | linux-, osx-
: TensorFlow helps the tensors flow
mhworth/tensorflow | 0.7. | conda | osx-
: TensorFlow helps the tensors flow
miovision/tensorflow | 0.10..gpu | conda | linux-, osx-
msarahan/tensorflow | 1.0.0rc2 | conda | linux-
mutirri/tensorflow | 0.10.0rc0 | conda | linux-
mwojcikowski/tensorflow | 1.0. | conda | linux-
nehaljwani/tensorflow | 1.1. | conda | win-, osx-
: TensorFlow is a machine learning library
nehaljwani/tensorflow-gpu | 1.1. | conda | win-
: TensorFlow is a machine learning library
rdonnelly/tensorflow | 0.9. | conda | linux-
rdonnellyr/r-tensorflow | 0.4. | conda | osx-
test_org_002/tensorflow | 0.10.0rc0 | conda |
Found packages

我们选择其中的一个进行安装之前,先查询这个分支的URL路径:

gxjun@gxjun:~$ anaconda show  nehaljwani/tensorflow-gpu
Using Anaconda API: https://api.anaconda.org
Name: tensorflow-gpu
Summary: TensorFlow is a machine learning library
Access: public
Package Types: conda
Versions:
+ 1.1. To install this package with conda run:
conda install --channel https://conda.anaconda.org/nehaljwani tensorflow-gpu

5.2 安装

     conda install --channel https://conda.anaconda.org/nehaljwani tensorflow-gpu

5.3 检测是否安装成功:

   在控制端输入:  
       python -> 进入python编辑环境
       import tensorflow as tf

  如果没有报错,则说明幸运的安装成功了~

  对于失败的情况,我这里给出最容易出现的:

>>> import tensorflow as tf
Traceback (most recent call last):
File "<stdin>", line , in <module>
File "/home/gxjun/anaconda2/lib/python2.7/site-packages/tensorflow/__init__.py", line , in <module>
from tensorflow.python import *
File "/home/gxjun/anaconda2/lib/python2.7/site-packages/tensorflow/python/__init__.py", line , in <module>
from tensorflow.python import pywrap_tensorflow
File "/home/gxjun/anaconda2/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line , in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/home/gxjun/anaconda2/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line , in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/home/gxjun/anaconda2/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line , in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/home/gxjun/anaconda2/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line , in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
ImportError: libcusolver.so.7.5: cannot open shared object file: No such file or directory

这种问题,是说我们没有找到这个动态库,或者干脆就没有这个动态库.

   解决方法:

      先问是不是: 输入这条命令查查看有没有: locate libcusolver.so      

gxjun@gxjun:~$ locate   libcusolver.so
/usr/lib/x86_64-linux-gnu/libcusolver.so
/usr/lib/x86_64-linux-gnu/libcusolver.so.8.0
/usr/lib/x86_64-linux-gnu/libcusolver.so.8.0.
/usr/lib/x86_64-linux-gnu/stubs/libcusolver.so
/usr/local/cuda-8.0/doc/man/man7/libcusolver.so.
/usr/local/cuda-8.0/targets/x86_64-linux/lib/libcusolver.so
/usr/local/cuda-8.0/targets/x86_64-linux/lib/libcusolver.so.8.0
/usr/local/cuda-8.0/targets/x86_64-linux/lib/libcusolver.so.8.0.
/usr/local/cuda-8.0/targets/x86_64-linux/lib/stubs/libcusolver.so
/usr/share/man/man7/libcusolver.so..gz

我们发现我们只有libcusolver.so.8.0,并没有我们要找的libcusolver.so.7.5,看了一下官方的文档:

  给出的建议是: 可以使用.8.0来替代.7.5,我们命名一个.8.0的软连接为.7.5

我们先到/usr/lib/cuda/lib64 下:

ln -s libcusolver.so.8.0  libcusolver.so.7.5

然后在.bashrc系统环境下配置一下这个路径:

export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/lib/cuda/lib64"
export CUDA_HOME=/usr/local/cuda

然后在测试:

    

gxjun@gxjun:~$ python
Python 2.7. |Anaconda 4.2. (-bit)| (default, Jul , ::)
[GCC 4.4. (Red Hat 4.4.-)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> import tensorflow as tf
>>>

正常了,说明已经完全安装好了~

参考:

    https://mirror.tuna.tsinghua.edu.cn/help/anaconda/

    http://www.jianshu.com/p/7be2498785b1

https://stackoverflow.com/questions/42013316/after-building-tensorflow-from-source-seeing-libcudart-so-and-libcudnn-errors

https://github.com/tensorflow/tensorflow/issues/1501

使用Anaconda搭建TensorFlow-GPU环境的更多相关文章

  1. windows 10 环境下 使用Anaconda搭建 TensorFlow 环境

    ##大致步骤 1 安装Anaconda 2 在Anaconda中建立虚拟TensorFlow的虚拟环境 建立虚拟环境的命令是 conda  create -n tensorflow python=3. ...

  2. 利用Anaconda搭建TensorFlow环境并在Jupyter Notebook使用

    打开Anaconda Prompt 创建一个tensorflow 虚拟环境:conda create -n tensorflow python=3.6 激活tensorflow虚拟环境activate ...

  3. 手把手教你在win10下搭建pytorch GPU环境(Anaconda+Pycharm)

    Anaconda指的是一个开源的Python发行版本,其主要优点如下: Anaconda默认安装了常见的科学计算包,用它搭建起Python环境后不用再费时费力安装这些包: Anaconda可以创建互相 ...

  4. Anaconda 安装tensorflow(GPU)

    1.安装 如果是安装CPU模式的tensorflow,只要输入一下代码就可以了 pip3 install tensorflow #python3pip install tensorflow #pyth ...

  5. Win7系统中用anaconda配置tensorflow运行环境

    前言:anaconda是一个python Data Science Platform.安装它的契机是因为要用tensorflow. 安装完后感觉用它来管理python运行环境还是挺方便的,常用的con ...

  6. windows下搭建tensorflow的环境

    这年头,不会点人工智能和神经网络,都不好意思跟人打招呼了.之前搞了一下sklearn,今天觉得应该要了解一下google这个传说中的人工智能开源神器. 最近终于有时间了,凡事从hello world开 ...

  7. 重拾Python(1):使用Anaconda搭建Python开发环境(Windows7)

    1.为什么选择Anaconda? Anaconda解决了Python使用痛点. Python好用但是令人头疼的就是库管理与Python不同版本的问题,特别是Windows环境下. 2.什么是Anaco ...

  8. 又见Python<1>:使用Anaconda搭建Python开发环境(Windows7)

    1.为什么选择Anaconda? Anaconda解决了Python使用痛点. Python好用但是令人头疼的就是库管理与Python不同版本的问题,特别是Windows环境下. 2.什么是Anaco ...

  9. 【Python】狂蟒来袭 | 使用Anaconda搭建Python开发环境

    这段时间转了一个小圈圈,发现又回来了,瞎忙.想要学习数据挖掘的小伙伴一定得对机器学习有所了解吧,我之前看过几页周志华老师的西瓜书,但终没能坚持下来. 人生处处是起点,什么时候都不晚.记此笔记以分享与督 ...

  10. 使用Docker快速搭建Tensorflow开发环境

    当我刚开始学习使用scikit-learn时,总是会出现各种各样的包依赖问题,兜兜转转了一遍才全部安装好,现在的机器学习算法开发者大都使用tensorflow.pytorch来实现自己的想法,但依然会 ...

随机推荐

  1. svn搭建服务器--- 绝对好使---杜恩德

    如何创建 SVN 服务器,并搭建自己的 SVN 仓库 听语音 | 浏览:1289 | 更新:2016-09-10 17:45 1 2 3 4 5 6 7 分步阅读 百度经验:jingyan.baidu ...

  2. CentOS6.9下安装rabbitmq消息队列

    安装如下步骤: 首先安装erlang yum install erlang 安装rabbitmq rpm包 wget http://www.rabbitmq.com/releases/rabbitmq ...

  3. Struts的使用

    一.Struts2的获取 Struts的官方网站为:http://struts.apache.org/ 下载完Struts2的jar包,解压,Struts2资源包的目录结构如下图: apps目录下包含 ...

  4. OpenCASCADE构造一般曲面

    OpenCASCADE构造一般曲面 eryar@163.com Abstract. 本文主要介绍常见的曲面如一般柱面(拉伸曲面).旋转面在OpenCASCADE中的构造方法,由此思考一般放样算法的实现 ...

  5. django2.0+linux服务器 ,如何让自己电脑访问

    这几天一直在搞这个服务器端口开放问题,来让自己电脑可以访问服务器下的django网页,今天终于弄好了~~~~~离成功又进了一步~~~~~ 1.首先,我们来开放一个linux服务器的端口(我开放了828 ...

  6. C#基础在using中创建对象

    在using中创建的对象的类必须是实现了IDispose接口的类,示例代码如下: static void Main(string[] args) { Method(); Console.WriteLi ...

  7. 关于Qt Designer程序/UI文件打开未响应的解决方法

    最近完成一个项目,到最后关头用QtCreator无法打开UI文件,每次都未响应,用QtDesigner也无法启动 这个问题把我折磨了半天,最后才知道原来是要删除C:\Users\Administrat ...

  8. Pashmak and Flowers

    Pashmak decided to give Parmida a pair of flowers from the garden. There are nflowers in the garden ...

  9. bzoj 2119: 股市的预测

    Description 墨墨的妈妈热爱炒股,她要求墨墨为她编写一个软件,预测某只股票未来的走势.股票折线图是研究股票的必备工具,它通过一张时间与股票的价位的函数图像清晰地展示了股票的走势情况.经过长时 ...

  10. lesson - 2 yum /单用户/救援模式/Linux 启动

    课程大纲:1.  yum使用yum 是一个在线安装软件包的工具,它可以帮我们解决软件包的依赖,这个日后会详细介绍.我们介绍了以下几个用法:yum list    这个命令可以列出所有安装过和未安装的软 ...