MVision icon indicating copy to clipboard operation
MVision copied to clipboard

how work on cpu mode

Open heavenong opened this issue 6 years ago • 3 comments

The document says it can work in CPU mode,but how?

heavenong avatar Jan 16 '19 06:01 heavenong

ristretto work on cpu mode , set "cpu=0" ?

heavenong avatar Jan 16 '19 06:01 heavenong

// 1.不加 --gpu=x,x,x,x,x 选项 // 2.使用--gpu=all 选项 如果计算机无CUDA设备,则设置为无GPU模式,仅使用CPU

void Quantization::SetGpu() { // Parse GPU ids or use all available devices vector gpus; if (gpus_ == "all") { int count = 0; #ifndef CPU_ONLY CUDA_CHECK(cudaGetDeviceCount(&count));// 获取所有可以CUDA设备数量 #else NO_GPU; #endif for (int i = 0; i < count; ++i) { gpus.push_back(i); } } else if (gpus_.size()) { vector strings; // 字符串 --gpu=x,x,x,x,x boost::split(strings, gpus_, boost::is_any_of(","));// 按 , 号分割== for (int i = 0; i < strings.size(); ++i) { gpus.push_back(boost::lexical_cast(strings[i])); } } else { CHECK_EQ(gpus.size(), 0);// 大于等于0 如果命令行参数中没有 --gpu=x,x,x,x,x 选项 }

// Set device id and mode if (gpus.size() != 0) { LOG(INFO) << "Use GPU with device ID " << gpus[0]; Caffe::SetDevice(gpus[0]); Caffe::set_mode(Caffe::GPU); } else { LOG(INFO) << "Use CPU."; Caffe::set_mode(Caffe::CPU); } }

Ewenwan avatar Jan 16 '19 10:01 Ewenwan

l 选项 如果计算机无CUDA设备,则设置为无GPU模式,仅使

thanks

heavenong avatar Jan 16 '19 10:01 heavenong