caffe 01 win10 运行环境配置(不需要开发环境)
2017-03-09 15:31
1586 查看
01 caffe介绍
Caffe,全称Convolution Architecture For Feature Extraction。caffe是一个清晰,可读性高,快速的深度学习框架。作者是贾扬清,加州大学伯克利的ph.D,现就职于Facebook。caffe的官网:http://caffe.berkeleyvision.org/。
caffe官方github:https://github.com/BVLC/caffe
官网安装环境介绍页面:http://caffe.berkeleyvision.org/installation.html
官网基础知识介绍页面:http://caffe.berkeleyvision.org/tutorial/
官网实验指导页面:http://caffe.berkeleyvision.org/ 页面中 Examples 中的内容。
windows release 版本下载地址:https://github.com/BVLC/caffe/tree/windows
目前(20170309)共有5个vs2015版本供下载。
Visual Studio 2015, CPU only, Python 3.5: Caffe Release, Caffe Debug
Visual Studio 2015, CUDA 8.0, Python 3.5: Caffe Release Visual
Studio 2015, CPU only, Python 2.7: Caffe Release, Caffe Debug Visual
Studio 2015, CUDA 8.0, Python 2.7: Caffe Release Visual Studio 2013,
CPU only, Python 2.7: Caffe Release, Caffe Debug
本次实验环境:windows10,CUDA8.0,Python3.5.3,
Visual Studio 2015, CUDA 8.0, Python 3.5: Caffe Release
caffe.zip解压到 D:\git\DeepLearning\caffebin
里面有目录:bin、include、lib、python、share。其中python是python接口目录。
下载的【Visual Studio 2015, CUDA 8.0, Python 3.5: Caffe Release】 windows
caffe运行版本已经带了vs2015的运行时dll。可以直接在没有安装vs2015的win10机器上运行。如果要在win7或win8.1的运行,需要在win7或win8.1机器上安装vs2015运行文件。
02 安装GPU支持必要组件
下载并安装CUDA8.0。默认安装到C:\Program Files。网址 https://developer.nvidia.com/cuda-downloads
安装后,会自动生成环境变量
CUDA_PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0 CUDA_PATH_V8_0=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0 NVCUDASAMPLES8_0_ROOT=C:\ProgramData\NVIDIA Corporation\CUDA Samples\v8.0 NVCUDASAMPLES_ROOT=C:\ProgramData\NVIDIA Corporation\CUDA Samples\v8.0 NVTOOLSEXT_PATH=C:\Program Files\NVIDIA Corporation\NvToolsExt\
03 安装pthon3.5.3及必要组件
pytho3.5.3下载地址:https://www.python.org/ftp/python/3.5.3/python-3.5.3-amd64.exe安装到c:\python35。安装时选择设置环境变量、勾选pip。
安装后,环境变量path中会加入如下两项(如果你安装了其他版本的python,请确保这个环境变量在path的较前位置)。
# %path%环境变量中有如下两行 c:\Python35\Scripts\ c:\Python35\
安装后,C:\Python35\Lib\site-packages只有README.exe文件。后面使用pip货pip3安装的python组件会被默认安装到
C:\Python35\Lib\site-packages 目录。
根据 https://github.com/BVLC/caffe/tree/windows 官网描述:
Using the Python interface
The recommended Python distribution is Anaconda or Miniconda. To
successfully build the python interface you need to install the
following packages: conda install –yes numpy scipy matplotlib
scikit-image pip six
also you will need a protobuf python package that is compatible with
pre-built dependencies. This package can be installed this way: conda
install –yes –channel willyd protobuf==3.1.0
If Python is installed the default is to build the python interface
and python layers. If you wish to disable the python layers or the
python build use the CMake options -DBUILD_python_layer=0 and
-DBUILD_python=0 respectively. In order to use the python interface you need to either add the C:\Projects\caffe\python folder to your
python path of copy the C:\Projects\caffe\python\caffe folder to
your site_packages folder.
安装必要的python工具组件:
在网址 http://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy
下载scipy-0.18.1-cp35-cp35m-win_amd64.whl
保存到E:\Work\201703\caffe\
安装scipy:
pip3 install E:\Work\201703\caffe\scipy-0.18.1-cp35-cp35m-win_amd64.whl
从 http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy
下载 Numpy+MKL,
选择 numpy-1.11.3+mkl-cp35-cp35m-win_amd64.whl,
下载到E:\Work\201703\caffe\
安装 Numpy+MKL:
pip3 install E:\Work\201703\caffe\numpy-1.11.3+mkl-cp35-cp35m-win_amd64.whl
安装其他组件
pip3 install wheel matplotlib six protobuf scikit-image pydot
这些python组件会被安装在 C:\Python35\Lib\site-packages 目录。
可以使用下列命令查看安装的python组件
pip3 --help # 查看帮助信息 pip3 list # 查看已安装的组件 pip3 show matplotlib #查看matplotlib 包信息
C:\Python35>pip3 show matplotlib
Name: matplotlib Version: 2.0.0 Summary: Python plotting package
Home-page: http://matplotlib.org Author: John D. Hunter, Michael
Droettboom Author-email: matplotlib-users@python.org License: BSD
Location: c:\python35\lib\site-packages Requires: pytz, pyparsing,
numpy, cycler, six, python-dateutil
04 caffe python接口调用
运行如下test01.py文件。D:\git\DeepLearning\caffebin\bin\test01.py
import numpy as np; import sys,os; # 注意下面的目录结构,根据自己的实际情况修改即可 caffe_root='D:/git/DeepLearning/caffebin/'; sys.path.insert(0, caffe_root + 'python'); import caffe as ca; # 引入自己的caffe的python接口 print("######"); # python打印6个# import matplotlib.pyplot as plt; plt.plot([1,2,3,4], [1,2,3,4]); plt.show(); # 画一条45°直线 ca.set_mode_gpu(); #设置使用GPU,ca.set_mode_cpu(); # 下面5行验证python目录下的接口可以正常引用 import caffe.io as cai; import caffe.net_spec as can; import caffe.classifier as cac; import caffe.draw as cad; # 这个文件需要安装pydot组件 import caffe.coord_map as caco;
运行结果:
###### WARNING: Logging before InitGoogleLogging() is written to STDERR I0309 14:47:07.974293 27364 common.cpp:36] System entropy source not available, using fallback algorithm to generate seed instead. [Finished in 9.2s]
相关文章推荐
- 【体感】Intel Realsense开发: C++环境配置+语音合成Demo (不需要硬件也能运行)
- 【Android开发系列】Android开发第一步-----开发环境配置 + 运行sample
- 什么是IIS,一个完整的.NET运行环境(针对web;不是开发环境)需要哪些软件或配置
- 【iOS-cocos2d-X 游戏开发之三】Mac下配置Android NDK环境并搭建Cocos2d-x环境并Eclipse正常编译运行!
- 【iOS-cocos2d-X 游戏开发之三】Mac下配置Android NDK环境并搭建Cocos2d-x环境并Eclipse正常编译运行Cocos2dX自带TestsDemo项目!
- J2EE运行和开发环境的安装与配置(JDK+TOMCAT 6.5+MyEclipse)(1)
- windows7平台下配置Apache+Python-CGI开发运行环境
- Android开发环境搭建:SDK在线离线安装+在Eclipse中配置ADT+第一个Android程序运行
- 安装和配置OAF开发环境运行官方toolbox demo
- RoR运行、开发环境的安装和配置
- WCSF教程01☞配置开发环境
- java 开发+运行环境配置+连接 sql 2008
- linux配置java开发环境运行hello world
- [J2EE学习笔记01]配置标准的J2EE开发环境
- Android开发环境搭建:SDK在线离线安装+在Eclipse中配置ADT+第一个Android程序运行
- android 开发环境的搭建 环境变量的配置 helloworld的运行
- VS2008环境下开发的某些程序在其他机器运行提示“由于应用程序配置不正确,应用程序未能启动”的问题(IIS)
- JAVA 运行与开发环境配置(二)- hello java
- 图解 PHP运行环境配置和开发环境的配置
- Sublime Text 2配置强大的IDE开发环境,运行java