BVLC / caffe

Caffe: a fast open framework for deep learning.
http://caffe.berkeleyvision.org/
Other
34.08k stars 18.7k forks source link

New thread which get the forward instance constructed by main thread cannot use GPU #5744

Open fengshikun opened 7 years ago

fengshikun commented 7 years ago

Issue summary

I construct a new classification forward instance in main thread like this:

// construct a new forward class
Caffe::set_mode(Caffe::GPU);
 net_.reset(new Net(model_file, TEST));
 net_->CopyTrainedLayersFrom(trained_file);

and pass this instance to a new thread to do forward. but this new thread failed to use GPU.

from https://github.com/BVLC/caffe/issues/4178, I add Caffe::set_mode(Caffe::GPU); before each forward operation, but it will complains:

gpu_memory.hpp:90 Check failed: 'prt_' Must be non NULL.

How to reset the GPU configuration to make it normal, thanks!

Your system configuration

Operating system: Ubuntu16.06 with CUDA8.0

shaibagon commented 6 years ago

have you tried constructing the net in the thread instead of passing it?