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

Cannot runnetonce on GPU tensored network #80

Open
ColeKOP opened this issue Sep 12, 2018 · 2 comments
Open

Cannot runnetonce on GPU tensored network #80

ColeKOP opened this issue Sep 12, 2018 · 2 comments

Comments

@ColeKOP
Copy link

ColeKOP commented Sep 12, 2018

Hi, I used python script to save the model into .pb file where the tensors and model were in CUDA. But when I try to run the model using pretrained.cc after instruction workspace.runNetOnce, the program aborted. But the .pb model where the model and tensor in CPU can work as expected. May I have any insight on this issue? Thank you.

@ColeKOP
Copy link
Author

ColeKOP commented Sep 13, 2018

Here is my code

           DeviceOption option;
	option.set_device_type(CUDA);
	new CUDAContext(option);

	// Load Squeezenet model
	NetDef init_net, predict_net;

	init_net.mutable_device_option()->set_device_type(CUDA);
	predict_net.mutable_device_option()->set_device_type(CUDA);
	// >>> with open(path_to_INIT_NET) as f:
	CAFFE_ENFORCE(ReadProtoFromFile(FLAGS_init_net, &init_net));

	// >>> with open(path_to_PREDICT_NET) as f:
	CAFFE_ENFORCE(ReadProtoFromFile(FLAGS_predict_net, &predict_net));

	// >>> p = workspace.Predictor(init_net, predict_net)
	Workspace workspace("tmp");
	CAFFE_ENFORCE(workspace.RunNetOnce(init_net));
	auto input = workspace.CreateBlob("data")->GetMutable<TensorCUDA>();

	input->ResizeLike(tensor);
	input->CopyFrom(tensor);
	CAFFE_ENFORCE(workspace.RunNetOnce(predict_net));


	

	// >>> results = p.run([img])
	auto &output_name = predict_net.external_output(0);
	auto output = workspace.GetBlob(output_name)->Get<TensorCUDA>();

The program will fail after CAFFE_ENFORCE(workspace.RunNetOnce(predict_net)); with
Unhandled exception at 0x00007FFB894AA388 in caffe2CPP.exe: Microsoft C++ exception: caffe2::EnforceNotMet at memory location 0x000000F73F30DF50.

Can you help me with the problem. Thank you.

@qingyang-jiandao
Copy link

i met same you

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

No branches or pull requests

2 participants