multithreading - 咖啡文档 :"Use multiple classification threads to ensure the GPU is always fully utilized"。如何?

标签 multithreading caffe

在“Classifying ImageNet: using the C++ API”教程(http://caffe.berkeleyvision.org/gathered/examples/cpp_classification.html)的结尾,我发现了这样的短语:

Use multiple classification threads to ensure the GPU is always fully utilized and not waiting for an I/O blocked CPU thread.

这是什么意思? 我理解正确,有一种方法可以在一个 GPU 上运行时为 CPU 层使用多个线程吗?

谢谢

最佳答案

您可以使用 CUDA 在一个 GPU 上使用多个线程和 CUDNN .

例如,CUDA programming guide :

以下代码将两个大小为 NxN 的矩阵 A 和 B 相加,并将结果存储到矩阵 C 中:

// Kernel definition
__global__ void MatAdd(float A[N][N], float B[N][N],
                       float C[N][N])
{
    int i = threadIdx.x;
    int j = threadIdx.y;
    C[i][j] = A[i][j] + B[i][j];
}

int main()
{
    ...
    // Kernel invocation with one block of N * N * 1 threads
    int numBlocks = 1;
    dim3 threadsPerBlock(N, N);
    MatAdd<<<numBlocks, threadsPerBlock>>>(A, B, C);
    ...
}

关于multithreading - 咖啡文档 :"Use multiple classification threads to ensure the GPU is always fully utilized"。如何?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36991270/

相关文章:

objective-c - 多线程崩溃中的 sizeWithFont!

c++ - 编译 caffe 的自定义层时 LevelDB 出现奇怪的错误

c++ - 如何理解 Cifar10 预测输出?

gcc - 由于不受支持的 gcc 编译器版本,Caffe 编译失败

neural-network - 在 pycaffe 中创建简单的身份层后网络不收敛

macos - 如何在 Mac 上为 google protobuf 设置 LD_LIBRARY_PATH (也可能是 DYLD_)?

multithreading - 什么是FIFO存储缓冲区中的本地旁路?

java - 访问正在运行循环的另一个线程的结果

python:如何检测我的线程何时成为孤儿?

Python - 如何不在构建线程步骤中启动线程