Skip to content

Cannot runnetonce on GPU tensored network #80

Open

Description

@ColeKOP

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.

Activity

  1. ColeKOP commented on Sep 13, 2018

    @ColeKOP
    Author

    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.

  2. qingyang-jiandao commented on Jan 3, 2019

    @qingyang-jiandao

    i met same you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions