Skip to content
This repository has been archived by the owner on Aug 5, 2022. It is now read-only.

Commit

Permalink
Support MKL2017 as default engine
Browse files Browse the repository at this point in the history
  • Loading branch information
hshen14 committed Jul 26, 2017
1 parent c2d5380 commit a5220f6
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ include(cmake/ConfigGen.cmake)
caffe_option(CPU_ONLY "Build Caffe without CUDA support" OFF) # TODO: rename to USE_CUDA
caffe_option(USE_OPENMP "Build Caffe with OpenMP support" ON )
caffe_option(USE_CUDNN "Build Caffe with cuDNN library support" ON IF NOT CPU_ONLY)
caffe_option(USE_MKL2017_AS_DEFAULT_ENGINE "Use MKL2017 primitives for supported layers" OFF)
caffe_option(USE_MKL2017_AS_DEFAULT_ENGINE "Use MKL2017 primitives for supported layers" ON)
caffe_option(USE_MKLDNN_AS_DEFAULT_ENGINE "Use MKL-DNN primitives for supported layers" OFF)
caffe_option(BUILD_SHARED_LIBS "Build shared libraries" ON)
caffe_option(BUILD_python "Build Python wrapper" ON)
Expand Down
4 changes: 2 additions & 2 deletions Makefile.config.example
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
# CPU-only switch (uncomment to build without GPU support).
CPU_ONLY := 1

# USE_MKL2017_AS_DEFAULT_ENGINE flag is OBSOLETE
# Put this at the top your train_val.protoxt or solver.prototxt file:
USE_MKL2017_AS_DEFAULT_ENGINE := 1
# or put this at the top your train_val.protoxt or solver.prototxt file:
# engine: "MKL2017"
# or use this option with caffe tool:
# -engine "MKL2017"
Expand Down
2 changes: 0 additions & 2 deletions docs/release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,6 @@ This Caffe version is seflcontained. This means that newest version of Intel MKL
* Set layer engine to `MKL2017` in prototxt file (model). Only this specific layer will be accelerated with new primitives.
* Use -engine = MKL2017 in command line as an option during execution of caffe (training, scoring, benchmark)

Comment: there is obsolete method to compale with `USE_MKL2017_AS_DEFAULT_ENGINE := 1` in `Makefile.config`. This is obsolete solution - not recommended to use anymore.

### Building for GPU
Caffe requires the CUDA `nvcc` compiler to compile its GPU code and CUDA driver for GPU operation.
To install CUDA, go to the [NVIDIA CUDA website](https://developer.nvidia.com/cuda-downloads) and follow installation instructions there. Install the library and the latest standalone driver separately; the driver bundled with the library is usually out-of-date. **Warning!** The 331.* CUDA driver series has a critical performance issue: do not use it.
Expand Down
16 changes: 12 additions & 4 deletions src/caffe/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,18 @@ void Net<Dtype>::Init(const NetParameter& in_param) {
}
// Setup layer.
const LayerParameter& layer_param = param.layer(layer_id);
if (param.engine() != "" && param.layer(layer_id).engine() == "")
param.mutable_layer(layer_id)->set_engine(param.engine());
if (param.engine() != "") {
if (param.layer(layer_id).engine() == "") {
param.mutable_layer(layer_id)->set_engine(param.engine());
}
else {
if ((!param.layer(layer_id).engine().compare("MKL2017") && !param.engine().compare("MKLDNN"))
|| (!param.layer(layer_id).engine().compare("MKLDNN") && !param.engine().compare("MKL2017"))) {
param.mutable_layer(layer_id)->set_engine(param.engine());
}
}
}

if (layer_param.propagate_down_size() > 0) {
CHECK_EQ(layer_param.propagate_down_size(),
layer_param.bottom_size())
Expand Down Expand Up @@ -490,8 +500,6 @@ template <typename Dtype>
void Net<Dtype>::CompileNet(const NetParameter& param,
NetParameter* param_compiled) {



NetParameter param_temp0;
param_temp0.CopyFrom(param);
param_temp0.clear_layer();
Expand Down

0 comments on commit a5220f6

Please sign in to comment.