Open saliltambe opened 6 years ago
Hi, you probably would have resolved this by now, but just in case you haven't I think the problem may be due to the ordering of your code. The set_device_type(CUDA) statements should execute before the ReadProtoFromFile calls. It works for me without any issue if I structure the code as below.
// Load Squeezenet model
NetDef init_net, predict_net;
#ifdef WITH_CUDA
init_net.mutable_device_option()->set_device_type(CUDA);
predict_net.mutable_device_option()->set_device_type(CUDA);
#else
init_net.mutable_device_option()->set_device_type(CPU);
predict_net.mutable_device_option()->set_device_type(CPU);
#endif
// >>> 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)
Have you solved this problem? If so, could you tell me the way to run GPU inference?
System information
**** Summary **** Hi,
I am trying to do a simple inference using GPU(squeeeznet) for testing. I managed to run it on CPU but the network initialization step continues to fail. Here is the part of the code(based on an online tutorial):
define WITH_CUDA
. . .
_#ifdef WITH_CUDA DeviceOption option; option.set_device_type(CUDA); option.clear_cuda_gpu_id(); option.set_cuda_gpu_id(0); new CUDAContext(option);
endif
ifdef WITH_CUDA
else
endif