| 19 | } |
| 20 | |
| 21 | void InternalThread::StartInternalThread() { |
| 22 | CHECK(!is_started()) << "Threads should persist and not be restarted."; |
| 23 | |
| 24 | int device = 0; |
| 25 | #ifndef CPU_ONLY |
| 26 | CUDA_CHECK(cudaGetDevice(&device)); |
| 27 | #endif |
| 28 | Caffe::Brew mode = Caffe::mode(); |
| 29 | int rand_seed = caffe_rng_rand(); |
| 30 | int solver_count = Caffe::solver_count(); |
| 31 | bool root_solver = Caffe::root_solver(); |
| 32 | |
| 33 | try { |
| 34 | thread_.reset(new boost::thread(&InternalThread::entry, this, device, mode, |
| 35 | rand_seed, solver_count, root_solver)); |
| 36 | } catch (std::exception& e) { |
| 37 | LOG(FATAL) << "Thread exception: " << e.what(); |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | void InternalThread::entry(int device, Caffe::Brew mode, int rand_seed, |
| 42 | int solver_count, bool root_solver) { |