Skip to content

Commit b2982f6

Browse files
authored
Cuda (luoyetx#8)
* remove blob diff * fix warning * only build Release * add cuda code * fix * update appveyor * Revert "update appveyor" This reverts commit a29ce8f. * add cudnn * update
1 parent 7059278 commit b2982f6

File tree

158 files changed

+5383
-618
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

158 files changed

+5383
-618
lines changed

LICENSE

Lines changed: 23 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,27 @@
1-
COPYRIGHT
1+
Copyright (c) 2015, zhangjie
22

3-
All contributions by the University of California:
4-
Copyright (c) 2014, 2015, The Regents of the University of California (Regents)
53
All rights reserved.
64

7-
All other contributions:
8-
Copyright (c) 2014, 2015, the respective contributors
9-
All rights reserved.
10-
11-
Caffe uses a shared copyright model: each contributor holds copyright over
12-
their contributions to Caffe. The project versioning records all such
13-
contribution and copyright details. If a contributor wants to further mark
14-
their specific copyright on a particular contribution, they should indicate
15-
their copyright solely in the commit message of the change when it is
16-
committed.
17-
18-
LICENSE
19-
20-
Redistribution and use in source and binary forms, with or without
21-
modification, are permitted provided that the following conditions are met:
22-
23-
1. Redistributions of source code must retain the above copyright notice, this
24-
list of conditions and the following disclaimer.
25-
2. Redistributions in binary form must reproduce the above copyright notice,
26-
this list of conditions and the following disclaimer in the documentation
27-
and/or other materials provided with the distribution.
28-
29-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
30-
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
31-
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
32-
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
33-
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
34-
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
35-
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
36-
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
5+
Redistribution and use in source and binary forms, with or without modification,
6+
are permitted provided that the following conditions are met:
7+
8+
* Redistributions of source code must retain the above copyright notice,
9+
this list of conditions and the following disclaimer.
10+
* Redistributions in binary form must reproduce the above copyright notice,
11+
this list of conditions and the following disclaimer in the documentation
12+
and/or other materials provided with the distribution.
13+
* Neither the name of mini-caffe nor the names of its contributors
14+
may be used to endorse or promote products derived from this software
15+
without specific prior written permission.
16+
17+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
21+
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
3827
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39-
40-
CONTRIBUTION AGREEMENT
41-
42-
By contributing to the BVLC/caffe repository through pull-request, comment,
43-
or otherwise, the contributor releases their content to the
44-
license and copyright terms herein.

README.md

Lines changed: 40 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -4,71 +4,68 @@ Mini-Caffe
44
[![Build Status](https://travis-ci.org/luoyetx/mini-caffe.svg?branch=master)](https://travis-ci.org/luoyetx/mini-caffe)
55
[![Build status](https://ci.appveyor.com/api/projects/status/x9s2iajv7rtxeo3t/branch/master?svg=true)](https://ci.appveyor.com/project/luoyetx/mini-caffe/branch/master)
66

7-
Minimal runtime core of Caffe. This repo is aimed to provide a minimal runtime of Caffe for those want to run Caffe model.
7+
Minimal runtime core of Caffe. This repo is aimed to provide a minimal C++ runtime core for those want to **Forward** a Caffe model.
88

9-
### Update
9+
### What can Mini-Caffe do?
1010

11-
- 2017/01/16. Build with x64 and remove many code.
12-
- 2016/12/11. Mini-Caffe now only depends on OpenBLAS and protobuf.
11+
Mini-Caffe only depends on OpenBLAS and protobuf which means you can't train model with Mini-Caffe. It also only supports **Forward** function which means you can't apply models like nerual art style transform that uses **Backward** function.
1312

14-
### What can mini-caffe do?
13+
### Build on Windows
1514

16-
This repo has no CUDA, no Caffe tools which means you can only use mini-caffe to run the nerual network model in CPU mode. You should train the nerual model use caffe tools on *nix platform, mini-caffe is just an optional choice for testing the nerual model on Windows platform. If you want a fully ported Caffe, you may refer to [happynear/caffe-windows](https://github.com/happynear/caffe-windows) or [Microsoft/caffe](https://github.com/Microsoft/caffe).
15+
You need a VC compiler to build Mini-Caffe. Visual Studio 2013 Community should be fine. You can download from [here](https://www.visualstudio.com/downloads/).
1716

18-
### Which compiler?
17+
##### OpenBLAS
1918

20-
VC12 in Visual Studio 2013. We only build for x64, if you know the difference, it can be easily doned with x86. What's more, We also need CMake.
19+
OpenBLAS library is already shipped with the source code, we don't need to compile it. If you want, you could download other version from [here](https://sourceforge.net/projects/openblas/files/). [v0.2.14](https://sourceforge.net/projects/openblas/files/v0.2.14/) is used for Mini-Caffe.
2120

22-
### 3rdparty libraries
21+
##### protobuf
2322

24-
Since Caffe depends on many 3rdparty libraries, I have modified some code to remove the libraries Caffe use.
23+
protobuf is a git submodule in Mini-Caffe, we need to fetch the source code and compile it.
2524

26-
- no CUDA
27-
- no DataLayer for train
28-
- no HDF5
25+
```
26+
$ git submodule update --init
27+
$ cmake .. -DUSE_CUDA=ON -DUSE_CUDNN=ON
28+
$ cd 3rdparty/src/protobuf/cmake
29+
$ mkdir build
30+
$ cd build
31+
$ cmake .. -DBUILD_TESTING=OFF -G "Visual Studio 12 2013 Win64"
32+
```
2933

30-
but we still need libraries below.
34+
Use `protobuf.sln` to compile `Debug` and `Release` version.
3135

32-
- ~~OpenCV~~
33-
- ~~Boost~~
34-
- ~~gflags~~
35-
- ~~glog~~
36-
- protobuf
37-
- openblas
36+
With these two libraries, we can compile Mini-Caffe now. Copy protobuf's include headers and libraries. Generate `caffe.pb.h` and `caffe.pb.cc`.
3837

39-
~~We can download pre-compiled OpenCV and Boost, and set two environment variables `OpenCV_DIR` and `Boost_DIR`. For example, `OpenCV_DIR` = `D:\3rdparty\opencv2.4.8\build` and `Boost_DIR` = `D:\3rdparty\boost_1_57_0`. Pay attention to the Compiler version and build Architecture, which will be **VC12** and **x86**.~~
38+
```
39+
$ copydeps.bat
40+
$ generatepb.bat
41+
$ mkdir build
42+
$ cd build
43+
$ cmake .. -G "Visual Studio 12 2013 Win64"
44+
```
4045

41-
For openblas, I already put the library in the source code.
46+
Use `mini-caffe.sln` to compile it.
4247

43-
~~gflags, glog,~~ protobuf can be compiled by ourself, I add these libraries as submodules of mini-caffe.
48+
### Build on Linux
4449

45-
To compile these libraries yourself, you should download the source code first.
50+
Install OpenBLAS and protobuf library through system package manager. Then build Mini-Caffe.
4651

4752
```
48-
git submodule update --init
53+
$ sudo apt install libopenblas-dev libprotobuf-dev protobuf-compiler
54+
$ protoc -I="./src/proto" --cpp_out="./src/proto" "./src/proto/caffe.proto"
55+
$ mkdir build
56+
$ cd build
57+
$ cmake ..
58+
$ make -j4
4959
```
5060

51-
all source code are under `3rdparty/src`.
61+
### With CUDA and CUDNN
5262

53-
##### protobuf
63+
Install CUDA and CUDNN in your system, then we can compile Mini-Caffe with GPU support. Run cmake command below.
5464

5565
```
56-
cd 3rdparty/src/protobuf/cmake
57-
mkdir build
58-
cd build
59-
cmake .. -DBUILD_TESTING=OFF -G "Visual Studio 12 2013 Win64"
66+
$ cmake .. -DUSE_CUDA=ON -DUSE_CUDNN=ON
6067
```
6168

62-
use VS2013 to compile protobuf. `Debug` and `Release`.
63-
64-
Once you have compiled these libraries, you need collect header files and lib files to `3rdparty/include` and `3rdparty/lib`. I provide a script for collecting, just run `copydeps.bat`, it will also copy dll files to `3rdparty/bin`.
65-
66-
### cmake for mini-caffe
67-
68-
Before we use cmake to generate vs solution file, we need to use protoc.exe to generate `caffe.pb.h` and `caffe.pb.cc`. Run `generatepb.bat` will use proto.exe and copy files to include folder and source folder.
69-
70-
`mini-caffe.sln` is the solution file for VS2013.
71-
72-
### Embed mini-caffe
69+
### Embed Mini-Caffe
7370

74-
To use mini-caffe as a sub-project, you may refer to [mini-caffe-example](https://github.com/luoyetx/mini-caffe-example).
71+
To use Mini-Caffe as a library, you may refer to [mini-caffe-example](https://github.com/luoyetx/mini-caffe-example).

appveyor.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ build_script:
3030
mkdir build
3131
cd build
3232
cmake .. -G "Visual Studio 12 2013 Win64"
33-
msbuild mini-caffe.sln /t:Rebuild /p:Configuration=Debug;Platform=x64 /m
3433
msbuild mini-caffe.sln /t:Rebuild /p:Configuration=Release;Platform=x64 /m
3534
cd ..
3635

caffe.LICENSE

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
COPYRIGHT
2+
3+
All contributions by the University of California:
4+
Copyright (c) 2014, 2015, The Regents of the University of California (Regents)
5+
All rights reserved.
6+
7+
All other contributions:
8+
Copyright (c) 2014, 2015, the respective contributors
9+
All rights reserved.
10+
11+
Caffe uses a shared copyright model: each contributor holds copyright over
12+
their contributions to Caffe. The project versioning records all such
13+
contribution and copyright details. If a contributor wants to further mark
14+
their specific copyright on a particular contribution, they should indicate
15+
their copyright solely in the commit message of the change when it is
16+
committed.
17+
18+
LICENSE
19+
20+
Redistribution and use in source and binary forms, with or without
21+
modification, are permitted provided that the following conditions are met:
22+
23+
1. Redistributions of source code must retain the above copyright notice, this
24+
list of conditions and the following disclaimer.
25+
2. Redistributions in binary form must reproduce the above copyright notice,
26+
this list of conditions and the following disclaimer in the documentation
27+
and/or other materials provided with the distribution.
28+
29+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
30+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
31+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
32+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
33+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
34+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
35+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
36+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
38+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39+
40+
CONTRIBUTION AGREEMENT
41+
42+
By contributing to the BVLC/caffe repository through pull-request, comment,
43+
or otherwise, the contributor releases their content to the
44+
license and copyright terms herein.

0 commit comments

Comments
 (0)