Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how work on cpu mode #18

Open
heavenong opened this issue Jan 16, 2019 · 3 comments
Open

how work on cpu mode #18

heavenong opened this issue Jan 16, 2019 · 3 comments

Comments

@heavenong
Copy link

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

@heavenong
Copy link
Author

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

@Ewenwan
Copy link
Owner

Ewenwan commented Jan 16, 2019

// 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);
}
}

@heavenong
Copy link
Author

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

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants