您的位置:首页 > Web前端

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]


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐