吴恩达deeplearning课程作业环境

Deep learning课程安装

Course 4 prerequisites:
- 2017/2/14 keras /pydot / graphviz
- 2017/2/20 pandas for week 3
- 2017/2/23 opencv for week 4


conda安装

unbuntu 16
pyhton 3.6版本 miniconda

https://conda.io/docs/user-guide/tasks/manage-environments.html

sudo apt-get update

bash Miniconda3-latest-Linux-x86_64.sh
# 安装位置 /home/ubuser/miniconda3

重启Terminal

基础库

创建virtualenv环境deeplearn,并且安装相应的包。(好像漏掉了conda create -n tensorflow python=2.7 # or python=3.3, etc.)

conda config --prepend channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ #使用国内源,清华或者豆瓣

mkdir DeepLearning
cd DeepLearning/

conda install -n deeplearn numpy
conda install -n deeplearn jupyter
conda install -n deeplearn matplotlib
conda install -n deeplearn h5py

# 为了支持PIL,PIL官方只支持python 2.xconda install -n deeplearn pillow 

#sklearn
conda install -n deeplearn scikit-learn 

conda install -n deeplearn pandas

#cv2
conda install -n deeplearn opencv 

pip 国内源使用方法

例如豆瓣:http://pypi.douban.com/simple/

清华:https://pypi.tuna.tsinghua.edu.cn/simple

可以在使用pip的时候加参数-i https://pypi.tuna.tsinghua.edu.cn/simple

例如:pip install -i https://pypi.tuna.tsinghua.edu.cn/simple gevent,这样就会从清华这边的镜像去安装gevent库。

永久修改
linux下,修改 ~/.pip/pip.conf
windows下,直接在user目录中创建一个pip目录,如:C:\Users\xx\pip,新建文件pip.ini,

安装TensorFlow

安装说明 https://www.tensorflow.org/install/install_linux (墙外)
清华tuna源使用说明 https://mirrors.tuna.tsinghua.edu.cn/help/tensorflow/


Take the following steps to install TensorFlow in an Anaconda environment:

  1. Follow the instructions on the Anaconda download site to download and install Anaconda.

  2. Create a conda environment named tensorflow to run a version of Python by invoking the following command:

    $ conda create -n tensorflow python=2.7 # or python=3.3, etc.

  3. Activate the conda environment by issuing the following command:

    $ **source activate tensorflow
    (tensorflow)$  # Your prompt should change
  4. Issue a command of the following format to install TensorFlow inside your conda environment:

    (tensorflow)$ pip install --ignore-installed --upgrade tfBinaryURL

    where tfBinaryURL is the URL of the TensorFlow Python package. For example, the following command installs the CPU-only version of TensorFlow for Python 3.4:

    (tensorflow)$ pip install --ignore-installed --upgrade\
     https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.4.0-cp34-cp34m-linux_x86_64.whl

从清华页面获得安装参数(在虚机内,简单期间使用CPU版。GPU的依赖见官方安装说明)

pip install \
  -i https://pypi.tuna.tsinghua.edu.cn/simple/ \
  https://mirrors.tuna.tsinghua.edu.cn/tensorflow/linux/cpu/tensorflow-1.4.1-cp36-cp36m-linux_x86_64.whl

正式使用安装命令(在相应的venv下执行)

 pip install --ignore-installed --upgrade\
     -i https://pypi.tuna.tsinghua.edu.cn/simple/ \
     https://mirrors.tuna.tsinghua.edu.cn/tensorflow/linux/cpu/tensorflow-1.4.1-cp36-cp36m-linux_x86_64.whl

TensorFlow其他资料

1) 如果出现警告 “RuntimeWarning: compiletime version 3.5 of module ‘tensorflow.python.framework.fast_tensor_util’ does not match runtime version 3.6”, 可以尝试从https://github.com/lakshayg/tensorflow-build安装。这个警告截至到2017/12/18没有官方解决方案。可以不管这个警告继续运行。回避的方式是把python改成3.5或者自己重编译。

2) 未经测试的安装方式

 $ pip install tensorflow      # Python 2.7; 仅支持CPU
 $ pip3 install tensorflow     # Python 3.n; 仅支持CPU
 $ pip install tensorflow-gpu  # Python 2.7; 支持CPU
 $ pip3 install tensorflow-gpu # Python 3.n; 支持CPU

3) Intel提供了针对Intel CPU优化的tensorflow, https://software.intel.com/en-us/articles/intel-optimized-tensorflow-wheel-now-available

# Python 3.6
pip install https://anaconda.org/intel/tensorflow/1.4.0/download/tensorflow-1.4.0-cp36-cp36m-linux_x86_64.whl
# Python 2.7
pip install https://anaconda.org/intel/tensorflow/1.4.0/download/tensorflow-1.4.0-cp27-cp27mu-linux_x86_64.whl

文章里还提供了修改venv配置和使用intel版numpy的方法。

使用使用Intel为主python环境的使用方法
https://software.intel.com/en-us/articles/using-intel-distribution-for-python-with-anaconda

单纯安装intel tensorflow在vmware虚机内,性能不会改善。

其他开源包
  • keras / pydot
    course 4 week 02 作业
pip install keras
pip install pydot

pydot需要graphviz支持,没有的话,会出现这个错误 “FileNotFoundError: [Errno 2] No such file or directory: ‘dot’”

sudo apt-get install graphviz 

安装测试

TensorFlow测试

# Python
import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))

使用测试

source activate deeplearn

jupyter notebook

进入notebook环境

import numpy as np
A = np.array([[1, 2], [3, 4]])
print(A)

从主机访问虚拟机

如果ssh映射到本地,参考文档

bivisw里面配置C2S端口映射(port forwording)
Listen interface/port是主机的
Destination host/port是虚拟机的

两个IP可以都是127.0.0.1或者localhost
虚拟机的端口是8888(notebook默认端口),主机端口任意。

另外一种方法,直接改变监听的IP

jupyter notebook --help 

jupyter notebook --ip=0.0.0.0 # listen all network interface

Viewing a list of the packages in an environment


To see a list of all packages installed in a specific environment:

  • If the environment is not activated:

    conda list -n myenv

  • If the environment is activated:

    conda list

导出Export your active environment to a new file:

conda env export > environment.yml

name: deeplearn
channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
- defaults
dependencies:
- bleach=1.5.0=py36_0
- certifi=2016.2.28=py36_0
- cycler=0.10.0=py36_0
- dbus=1.10.20=0
- decorator=4.1.2=py36_0
- entrypoints=0.2.3=py36_0
- expat=2.1.0=0
- fontconfig=2.12.1=3
- freetype=2.5.5=2
- glib=2.50.2=1
- gst-plugins-base=1.8.0=0
- gstreamer=1.8.0=0
- h5py=2.7.0=np112py36_0
- hdf5=1.8.17=2
- html5lib=0.9999999=py36_0
- icu=54.1=0
- ipykernel=4.6.1=py36_0
- ipython=6.1.0=py36_0
- ipython_genutils=0.2.0=py36_0
- ipywidgets=6.0.0=py36_0
- jbig=2.1=0
- jedi=0.10.2=py36_2
- jinja2=2.9.6=py36_0
- jpeg=8d=2
- jsonschema=2.6.0=py36_0
- jupyter=1.0.0=py36_3
- jupyter_client=5.1.0=py36_0
- jupyter_console=5.2.0=py36_0
- jupyter_core=4.3.0=py36_0
- libffi=3.2.1=1
- libgcc=5.2.0=0
- libgfortran=3.0.0=1
- libiconv=1.14=0
- libpng=1.6.30=1
- libsodium=1.0.10=0
- libtiff=4.0.6=2
- libxcb=1.12=1
- libxml2=2.9.4=0
- markupsafe=1.0=py36_0
- matplotlib=2.0.2=np112py36_0
- mistune=0.7.4=py36_0
- mkl=2017.0.3=0
- nbconvert=5.2.1=py36_0
- nbformat=4.4.0=py36_0
- notebook=5.0.0=py36_0
- numpy=1.12.1=py36_0
- olefile=0.44=py36_0
- opencv=3.1.0=np112py36_1
- openssl=1.0.2l=0
- pandas=0.20.3=py36_0
- pandocfilters=1.4.2=py36_0
- path.py=10.3.1=py36_0
- pcre=8.39=1
- pexpect=4.2.1=py36_0
- pickleshare=0.7.4=py36_0
- pillow=3.4.2=py36_0
- pip=9.0.1=py36_1
- prompt_toolkit=1.0.15=py36_0
- ptyprocess=0.5.2=py36_0
- pygments=2.2.0=py36_0
- pyparsing=2.2.0=py36_0
- pyqt=5.6.0=py36_2
- python=3.6.2=0
- python-dateutil=2.6.1=py36_0
- pytz=2017.2=py36_0
- pyzmq=16.0.2=py36_0
- qt=5.6.2=2
- qtconsole=4.3.1=py36_0
- readline=6.2=2
- scikit-learn=0.19.0=np112py36_0
- scipy=0.19.1=np112py36_0
- setuptools=36.4.0=py36_1
- simplegeneric=0.8.1=py36_1
- sip=4.18=py36_0
- six=1.10.0=py36_0
- sqlite=3.13.0=0
- terminado=0.6=py36_0
- testpath=0.3.1=py36_0
- tk=8.5.18=0
- tornado=4.5.2=py36_0
- traitlets=4.3.2=py36_0
- wcwidth=0.1.7=py36_0
- wheel=0.29.0=py36_0
- widgetsnbextension=3.0.2=py36_0
- xz=5.2.3=0
- zeromq=4.1.5=0
- zlib=1.2.11=0
- pip:
  - enum34==1.1.6
  - ipython-genutils==0.2.0
  - jupyter-client==5.1.0
  - jupyter-console==5.2.0
  - jupyter-core==4.3.0
  - keras==2.1.3
  - markdown==2.6.10
  - prompt-toolkit==1.0.15
  - protobuf==3.5.0.post1
  - pydot==1.2.4
  - pyyaml==3.12
  - tensorflow==1.4.1
  - tensorflow-tensorboard==0.4.0rc3
  - werkzeug==0.13
prefix: /home/ubuser/miniconda3/envs/deeplearn
  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值