VS2013配置Caffe卷积神经网络工具(64位Windows 7)

2014年4月的时候自己在公司就将Caffe移植到Windows系统了,今年自己换了台电脑,想在家里也随便跑跑,本来也装了Ubuntu可以很方便的配置好,无奈在家的风格是“娱乐的时候抽空学习”,所以移植到Windows还是很有必要的。但是,公司禁止将公司内部资料带出,很多地方又都忘记了,周末磨了一天终于移植完,本篇为记录将Caffe移植至Windows7x64系统下的一些关键步骤。下面介绍如何从源码建立VS2013工程。

File–>New–>Project

选择Win32ConsoleApplication

选择工程路径,比如D:\CODE\CXX

给项目命名caffe-dev

Build–>ConfigurationManager–>Activesolutionplatform–>new–>x64–>OK

Project–>BuildCustomizations…–>CUDA7.0–>OK

D:\LIBS\boost_1_57_0;D:\LIBS\OpenBLAS\include

D:\LIBS\opencv\build\include

D:\LIBS\opencv\build\include\opencv

D:\LIBS\opencv\build\include\opencv2

C:\ProgramFiles\NVIDIAGPUComputingToolkit\CUDA\v7.0\include

D:\LIBS\OpenBLAS\lib

D:\LIBS\opencv\build\x64\vc12\lib

D:\LIBS\boost_1_57_0\lib

C:\ProgramFiles\NVIDIAGPUComputingToolkit\CUDA\v7.0\lib\x64

在Project–>Properties–>ConfigurationProperties–>C/C++–>General–>AdditionalIncludeDirectories中添加

../include;../src

../3rdparty/include

../3rdparty/include/hdf5

../3rdparty/include/lmdb

在Project–>Properties–>ConfigurationProperties–>Linker–>General–>AdditionalLibraryDirectories中添加

../3rdparty/lib

在Project–>Properties–>ConfigurationProperties–>Linker–>Input–>AdditionalDependencies中添加

opencv_core2410.lib

opencv_highgui2410.lib

opencv_imgproc2410.lib

cudart.lib

cublas.lib

curand.lib

gflags.lib

libglog.lib

libopenblas.dll.a

libprotobuf.lib

libprotoc.lib

leveldb.lib

lmdb.lib

libhdf5.lib

libhdf5_hl.lib

Shlwapi.lib

opencv_core2410d.lib

opencv_highgui2410d.lib

opencv_imgproc2410d.lib

cudart.lib

cublas.lib

curand.lib

gflagsd.lib

libglogd.lib

libopenblas.dll.a

libprotobufd.lib

libprotoc.lib

leveldbd.lib

lmdbd.lib

libhdf5.lib

libhdf5_hl.lib

Shlwapi.lib

protoc.exe caffe.proto –cpp_output=./

#include <windows.h>#include <io.h>int mkstemp(char *templates);

/* mkstemp extracted from libc/sysdeps/posix/tempname.c. Copyright (C) 1991-1999, 2000, 2001, 2006 Free Software Foundation, Inc.The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. */#include "caffe/util/mkstemp.hpp"#include <errno.h>#include <fcntl.h>#include <sys/stat.h>static const char letters[] ="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";/* Generate a temporary file name based on TMPL. TMPL must match the rules for mk[s]temp (i.e. end in "XXXXXX"). The name constructed does not exist at the time of the call to mkstemp. TMPL is overwritten with the result. */int mkstemp (char *tmpl){ int len; char *XXXXXX; static unsigned long long value; unsigned long long random_time_bits; unsigned int count; int fd = -1; int save_errno = errno; /* A lower bound on the number of temporary files to attempt togenerate. The maximum total number of temporary file names thatcan exist for a given template is 62**6. It should never benecessary to try all these combinations. Instead if a reasonablenumber of names is tried (we define reasonable as 62**3) fail togive the system administrator the chance to remove the problems. */#define ATTEMPTS_MIN (62 * 62 * 62) /* The number of times to attempt to generate a temporary file. Toconform to POSIX, this must be no smaller than TMP_MAX. */#if ATTEMPTS_MIN < TMP_MAX unsigned int attempts = TMP_MAX;#else unsigned int attempts = ATTEMPTS_MIN;#endif len = strlen (tmpl); if (len < 6 || strcmp (&tmpl[len – 6], "XXXXXX")){errno = EINVAL;return -1;}/* This is where the Xs start. */ XXXXXX = &tmpl[len – 6]; /* Get some more or less random data. */ {SYSTEMTIMEstNow;FILETIME ftNow;// get system timeGetSystemTime(&stNow);stNow.wMilliseconds = 500;if (!SystemTimeToFileTime(&stNow, &ftNow)){errno = -1;return -1;}random_time_bits = (((unsigned long long)ftNow.dwHighDateTime << 32)| (unsigned long long)ftNow.dwLowDateTime); } value += random_time_bits ^ (unsigned long long)GetCurrentThreadId (); for (count = 0; count < attempts; value += 7777, ++count){unsigned long long v = value;/* Fill in the random bits. */XXXXXX[0] = letters[v % 62];v /= 62;XXXXXX[1] = letters[v % 62];v /= 62;XXXXXX[2] = letters[v % 62];v /= 62;XXXXXX[3] = letters[v % 62];v /= 62;XXXXXX[4] = letters[v % 62];v /= 62;XXXXXX[5] = letters[v % 62];fd = open (tmpl, O_RDWR | O_CREAT | O_EXCL, _S_IREAD | _S_IWRITE);if (fd >= 0){errno = save_errno;return fd;}else if (errno != EEXIST)return -1;} /* We got out of the loop because we ran out of combinations to try. */ errno = EEXIST; return -1;}

11.修改一些代码

在include/caffe/common.hpp中添加#include<direct.h>

可就是这样,还是有人,期望过多的温暖。

VS2013配置Caffe卷积神经网络工具(64位Windows 7)

相关文章:

你感兴趣的文章:

标签云: