Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows Branch: Input layer does not exist in caffe.lib #5448

Closed
dfotland opened this issue Mar 25, 2017 · 3 comments
Closed

Windows Branch: Input layer does not exist in caffe.lib #5448

dfotland opened this issue Mar 25, 2017 · 3 comments
Labels

Comments

@dfotland
Copy link

Please use the caffe-users list for usage, installation, or modeling questions, or other requests for help.
Do not post such requests to Issues. Doing so interferes with the development of Caffe.

Please read the guidelines for contributing before submitting this issue.

Issue summary

I am developing on Windows 10, using Visual Studio 2015 Community Edition. I downloaded the prebuilt caffe library for "Visual Studio 2015,CUDA 8.0, Python 2.7: Caffe Release" from https://github.com/BVLC/caffe/tree/windows. I have a net that I trained last May on a linux Ubuntu system. I've updated it for deployment using the instructions from https://github.com/BVLC/caffe/wiki/Using-a-Trained-Network:-Deploy

I use caffe from c++ initializing it with the code below. When I read the network definition, I get an error:
I0324 21:50:01.464443 17880 layer_factory.cpp:58] Creating layer data
F0324 21:50:01.465445 17880 layer_factory.cpp:62] Check failed: registry.count(type) == 1 (0 vs. 1) Unknown layer type: Input (known types: Convolution, Eltwise, LRN, Pooling, Power, Python, ReLU, Sigmoid, Softmax, Split, TanH)

The input layer is not known. I found several other people reporting this issue with no resolution.

****************** my prototxt *************************
name: "residue"

layer {
name: "data"
type: "Input"
top: "data"
input_param {
shape: { dim: 1 dim: 42 dim: 19 dim: 19 }
}
}

layer { name: "first""x5" type: "Convolution" bottom: "data" top: "first""x5" param { lr_mult: 1 } param { lr_mult: 2 } convolution_param { num_output: 32 kernel_size: 5 stride: 1 pad: 2 weight_filler { type: "xavier" } bias_filler { type: "constant" } } } layer { name: "first""x3" type: "Convolution" bottom: "data" top: "first""x3" param { lr_mult: 1 } param { lr_mult: 2 } convolution_param { num_output: 32 kernel_size: 3 stride: 1 pad: 1 weight_filler { type: "xavier" } bias_filler { type: "constant" } } } layer { name: "first""x1" type: "Convolution" bottom: "data" top: "first""x1" param { lr_mult: 1 } param { lr_mult: 2 } convolution_param { num_output: 32 kernel_size: 1 stride: 1 pad: 0 weight_filler { type: "xavier" } bias_filler { type: "constant" } } } layer { name: "first" type: "Concat" bottom: "first""x5" bottom: "first""x3" bottom: "first""x1" top: "first" concat_param { axis: 1 } } layer{ name: "first""relu" type: "ReLU" bottom: "first" top: "first" }

(followed by many more layers)

******************* my init code ************************
int caffe_init(const char *path, int use_gpu, int use_net) {
caffe_use_gpu = use_gpu;

#if HAVE_CAFFE
int argc = 2;
char *fake_args[] = { (char *)"gtpmfgo", (char *)"ManyFaces" };
char **argv = fake_args;
// defined in logging.h to control caffe logging
fLS::FLAGS_log_dir = "./log";
fLB::FLAGS_alsologtostderr = true;
fLI::FLAGS_minloglevel = 0;
GlobalInit(&argc, &argv);
caffe_set_mode();

if (caffe_test_net != NULL) delete caffe_test_net;
string file_path = path;
file_path += "/";
file_path += filename_net[use_net];
// check if file exists
FILE *f = fopen(file_path.c_str(), "r");
if (f == NULL) {
	printf("Can't open file: %s\n", file_path.c_str());
	return 0;
}
fclose(f);
caffe_test_net = new Net<float>(file_path, TEST);
caffe_test_net->CopyTrainedLayersFrom(file_path + filename_parameters[use_net]);
int t2 = Caffe::mode();
caffe_test_net_input_dim = caffe_test_net->input_blobs()[0]->shape()[1];
caffe_blob = new Blob<float>(1, caffe_test_net_input_dim, input_size, input_size);

// allocate data
int size = caffe_test_net_input_dim * input_size * input_size;
caffe_input = new caffe_request(size);
caffe_working = new caffe_request(size);

#endif
return 1;
}

Steps to reproduce

I have tried the release build above and the debug build without CPU support with the same result. I am linking with the prebuilt caffe.lib. For dependencies I'm using the ones that are downloaded by the caffe build script. I am NOT using the caffe.lib that is built from source by the build script.

Your system configuration

Operating system: Windows 10
Compiler: visual studio 2015 community edition, update 3
CUDA version (if applicable): 8.0
CUDNN version (if applicable): 5.1.10
BLAS: openbas
Python or MATLAB version (for pycaffe and matcaffe respectively): Python 2.7

@willyd
Copy link
Contributor

willyd commented Mar 25, 2017

Add this preprocessor define in your project: CMAKE_WINDOWS_BUILD

@willyd willyd added the windows label Mar 25, 2017
@dfotland
Copy link
Author

dfotland commented Mar 25, 2017

I'm using the prebuilt caffe.lib binaries. I'm not building them. I'll try adding this to my c++ project that is linking to the prebuilt caffe.lib, but I'm not sure that is what you mean,

With the define added to my c++ project, and a clean build, I still get the same error Unknown layer type: Input

I just tried linking with caffe.lib that I built yesterday, with the same result.

I'm unblocked. Thank you! Setting the define in my project file did not make it defined in the common.hpp that uses it to export symbols. Perhaps because that .hpp file is not included in the project. I set the define in my source code right before including "caffe/caffe.hpp" and the symbols are exported.

@dfotland
Copy link
Author

This define, when linked with the prebuilt caffe.lib, brings in some dependencies on the NVIDIA NCCL library. Consider adding this library to the prebuilt libraries download. The NCCL git does not include a windows build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants