6.2 CUDA streams
stream是什么
nivdia给出的解释是:
A sequence of operations that execute in issue-order on the GPU. 可以理解成在GPU上执行的操作序列.比如下面的这些动作.
cudaMemcpy()
kernel launch
device sync
cudaMemcpy()
不同的流操作可能是交叉执行的,可能是同事执行的.

流的API:
cudaEvent_t start;
cudaEventCreate(&start);
cudaEventRecord( start, 0 );
我们可以把一个应用程序的整体对的stream的情况称之为pipeline.优化程序以stream的角度就是优化pipeline
cuda overlap重叠
支持设备重叠的cuda GPU设备能够在执行kernel函数时同时执行设备与主机之间的内存拷贝动作.可以用下面的代码查看设备是否支持overlap:
int dev_count;
cudaDeviceProp prop;
cudaGetDeviceCount( &dev_count);
for (int i = ; i < dev_count; i++) {
cudaGetDeviceProperties(&prop, i);
if (prop.deviceOverlap) ...
cudaMemcpyAsync()
memcpy是以同步方式执行的,当函数返回时,复制操作已经完成.而cudaMemcpyAsync()是异步函数,它只是放置一个请求,表示在流中执行一次内存复制操作,这个复制操作是通过参数stream来指定的.当函数返回时我们无法保证函数已经执行完成,能够保证的是复制操作肯定会在下一个放入流的操作之前执行完成.任何传递给cudaMemcpyAsync()的主机内存指针都必须已经通过cudaHostAlloc()分配好内存,也就是,你只能以异步方式对页锁定内存进行复制操作.
Vector stream add 向量流加法

优化这个pipeline,最理想的pipeline如下:

可以看到在同一时间,lanuch kernel, copy host to device, copy device back to host 三个任务同时执行. 有2个stream流,一个是copy, 一个用于执行kernel.

实际优化pipeline的时候并不是这么简单和容易的,先看下面一段host代码:
for (int i=; i<n; i+=SegSize*) {
cudaMemcpyAsync(d_A0, h_A+i, SegSize*sizeof(float),..., stream0);
cudaMemcpyAsync(d_B0, h_B+i, SegSize*sizeof(float),..., stream0);
vecAdd<<<SegSize/, , , stream0>>>(d_A0, d_B0,...);
cudaMemcpyAsync(h_C+i, d_C0, SegSize*sizeof(float),..., stream0);
cudaMemcpyAsync(d_A1, h_A+i+SegSize, SegSize*sizeof(float),...,
stream1);
cudaMemcpyAsync(d_B1, h_B+i+SegSize, SegSize*sizeof(float) ,...,
stream1);
vecAdd<<<SegSize/, , , stream1>>>(d_A1, d_B1, ...);
cudaMemcpyAsync(d_C1, h_C+i+SegSize, SegSize*sizeof(float),...,
stream1);
}
这段代码的pipeline的情况是: 执行kernel计算和 下一块拷贝主机内存到设备是同事进行的.
再看下面这段代码:
for (int i=; i<n; i+=SegSize*) {
cudaMemcpyAsync(d_A0, h_A+i, SegSize*sizeof(float),..., stream0);
cudaMemcpyAsync(d_B0, h_B+i, SegSize*sizeof(float),..., stream0);
cudaMemcpyAsync(d_A1, h_A+i+SegSize, SegSize*sizeof(float),...,
stream1);
cudaMemcpyAsync(d_B1, h_B+i+SegSize, SegSize*sizeof(float),...,
stream1);
vecAdd<<<SegSize/, , , stream0>>>(d_A0, d_B0, ...);
vecAdd<<<SegSize/, , , stream1>>>(d_A1, d_B1, ...);
cudaMemcpyAsync(h_C+i, d_C0, SegSize*sizeof(float),..., stream0);
cudaMemcpyAsync(h_C+i+SegSize, d_C1, SegSize*sizeof(float),...,
stream1);
}
这段代码的pipeline情况是:和上一种的区别是把拷贝A和B元素与kernel并行,可以形象的理解成,下一行向左移动一下,那么整个pipeline整体是缩短了的.
strean 同步API
cudaStreamSynchronize(stream_id): 等待一个stream中的所有任务执行完成.
cudaDeviceSynchronize(): 不带参数等待设备中所有流任务执行完成
Vector-stream-add Code
首先使用2个stream来做:
#include <wb.h>
#define wbCheck(stmt) do { \
cudaError_t err = stmt; \
if (err != cudaSuccess) { \
wbLog(ERROR, "Failed to run stmt ", #stmt); \
wbLog(ERROR, "Got CUDA error ... ", cudaGetErrorString(err)); \
return -; \
} \
} while() #define SegSize 256
#define StreamNum 2 __global__ void vecAdd(float * in1, float * in2, float * out, int len) {
//@@ Insert code to implement vector addition here
int gidx = blockIdx.x*blockDim.x + threadIdx.x; if(gidx< len)
{
out[gidx]= in1[gidx]+in2[gidx];
}
} int main(int argc, char ** argv) {
wbArg_t args;
int inputLength;
float * hostInput1;
float * hostInput2;
float * hostOutput;
// float * deviceInput1;
// float * deviceInput2;
// float * deviceOutput;
float *h_A, *h_B, *h_C; //cudaStream_t stream0, stream1;
//cudaStreamCreate(&stream0);
//cudaStreamCreate(&stream1);
float *d_A0, *d_B0, *d_C0;// device memory for stream 0
float *d_A1, *d_B1, *d_C1;// device memory for stream 1 args = wbArg_read(argc, argv);
int Csize = SegSize*sizeof(float); wbTime_start(Generic, "Importing data and creating memory on host");
hostInput1 = (float *) wbImport(wbArg_getInputFile(args, ), &inputLength);
hostInput2 = (float *) wbImport(wbArg_getInputFile(args, ), &inputLength);
hostOutput = (float *) malloc(inputLength * sizeof(float));
printf("inputLength ==%d, SegSize =%d\n", inputLength, SegSize);
wbTime_stop(Generic, "Importing data and creating memory on host"); cudaHostAlloc((void**)&h_A, inputLength*sizeof(float), cudaHostAllocDefault);
cudaHostAlloc((void**)&h_B, inputLength*sizeof(float), cudaHostAllocDefault);
cudaHostAlloc((void**)&h_C, inputLength*sizeof(float), cudaHostAllocDefault); memcpy(h_A, hostInput1,inputLength*sizeof(float));
memcpy(h_B, hostInput2,inputLength*sizeof(float)); wbCheck(cudaMalloc((void **)&d_A0, Csize));
wbCheck(cudaMalloc((void **)&d_A1, Csize));
wbCheck(cudaMalloc((void **)&d_B0, Csize));
wbCheck(cudaMalloc((void **)&d_B1, Csize));
wbCheck(cudaMalloc((void **)&d_C0, Csize));
wbCheck(cudaMalloc((void **)&d_C1, Csize)); cudaStream_t *streams = (cudaStream_t*) malloc(StreamNum * sizeof(cudaStream_t));
for(int i = ; i < StreamNum; i++)
cudaStreamCreate(&(streams[i])); int main = inputLength/(SegSize*StreamNum);
int left = inputLength%(SegSize*StreamNum); printf("main =%d, left=%d\n", main, left);
int i = ; // keep the increaing length
for(i; i < inputLength; i+=SegSize*StreamNum)
{
cudaMemcpyAsync(d_A0, hostInput1+i, Csize, cudaMemcpyHostToDevice, streams[]);
cudaMemcpyAsync(d_B0, hostInput2+i, Csize, cudaMemcpyHostToDevice, streams[]);
cudaMemcpyAsync(d_A1, hostInput1+i+SegSize, Csize, cudaMemcpyHostToDevice, streams[]);
cudaMemcpyAsync(d_B1, hostInput2+i+SegSize, Csize, cudaMemcpyHostToDevice, streams[]); // block size is 256
vecAdd<<<SegSize/, SegSize, , streams[]>>>(d_A0, d_B0, d_C0, SegSize);
vecAdd<<<SegSize/, SegSize, , streams[]>>>(d_A1, d_B1, d_C1, SegSize); // cudaStreamSynchronize(yiming_stream0);
cudaMemcpyAsync(hostOutput+i, d_C0, Csize, cudaMemcpyDeviceToHost, streams[]);
//cudaStreamSynchronize(yiming_stream1);
cudaMemcpyAsync(hostOutput+i+SegSize, d_C1, Csize, cudaMemcpyDeviceToHost, streams[]);
} // Process the remaining elements if(SegSize < left)
{
printf("AAAAAAA, left- size ==%d\n", left-SegSize);
cudaMemcpyAsync(d_A0, hostInput1+i, Csize, cudaMemcpyHostToDevice, streams[]);
cudaMemcpyAsync(d_B0, hostInput2+i, Csize, cudaMemcpyHostToDevice, streams[]);
cudaMemcpyAsync(d_A1, hostInput1+i+SegSize, (left-SegSize)*sizeof(float), cudaMemcpyHostToDevice, streams[]);
cudaMemcpyAsync(d_B1, hostInput2+i+SegSize, (left-SegSize)*sizeof(float), cudaMemcpyHostToDevice, streams[]); // block size is 256
vecAdd<<<, SegSize, , streams[]>>>(d_A0, d_B0, d_C0, SegSize);
vecAdd<<<, left-SegSize, , streams[]>>>(d_A0, d_B0, d_C0, left-SegSize); // cudaStreamSynchronize(streams[0]);
cudaMemcpyAsync(hostOutput+i, d_C0, Csize,cudaMemcpyDeviceToHost, streams[]);
cudaMemcpyAsync(hostOutput+i+SegSize, d_C0, (left-SegSize)*sizeof(float),cudaMemcpyDeviceToHost, streams[]); // i+=SegSize;
// left = left - SegSize;
}
else if(left > )
{
printf("BBBBBBB\n");
cudaMemcpyAsync(d_A0, hostInput1+i, left*sizeof(float), cudaMemcpyHostToDevice);
cudaMemcpyAsync(d_B0, hostInput2+i, left*sizeof(float), cudaMemcpyHostToDevice); vecAdd<<<, left, , streams[]>>>(d_A0, d_B0, d_C0, left); //cudaDeviceSynchronize();
cudaMemcpyAsync(hostOutput+i, d_C0, left*sizeof(float), cudaMemcpyDeviceToHost);
} cudaDeviceSynchronize();
wbSolution(args, hostOutput, inputLength); free(hostInput1);
free(hostInput2);
free(hostOutput); for(int i = ; i < StreamNum; i++)
cudaStreamDestroy(streams[i]); cudaFree(d_A0);
cudaFree(d_A1);
cudaFree(d_B0);
cudaFree(d_B1);
cudaFree(d_C0);
cudaFree(d_C1);
return ;
}
然后是使用4个流来做,code如下:
#include <wb.h>
#define wbCheck(stmt) do { \
cudaError_t err = stmt; \
if (err != cudaSuccess) { \
wbLog(ERROR, "Failed to run stmt ", #stmt); \
wbLog(ERROR, "Got CUDA error ... ", cudaGetErrorString(err)); \
return -; \
} \
} while() #define SegSize 256
#define StreamNum 4 __global__ void vecAdd(float * in1, float * in2, float * out, int len) {
//@@ Insert code to implement vector addition here
int gidx = blockIdx.x*blockDim.x + threadIdx.x; if(gidx< len)
{
out[gidx]= in1[gidx]+in2[gidx];
}
} int main(int argc, char ** argv) {
wbArg_t args;
int inputLength, i;
float * hostInput1;
float * hostInput2;
float * hostOutput;
// float * deviceInput1;
// float * deviceInput2;
// float * deviceOutput;
float *h_A, *h_B, *h_C; //cudaStream_t stream0, stream1;
//cudaStreamCreate(&stream0);
//cudaStreamCreate(&stream1);
float *d_A0, *d_B0, *d_C0;// device memory for stream 0
float *d_A1, *d_B1, *d_C1;// device memory for stream 1
float *d_A2, *d_B2, *d_C2;// device memory for stream 2
float *d_A3, *d_B3, *d_C3;// device memory for stream 3 args = wbArg_read(argc, argv);
int Csize = SegSize*sizeof(float); wbTime_start(Generic, "Importing data and creating memory on host");
hostInput1 = (float *) wbImport(wbArg_getInputFile(args, ), &inputLength);
hostInput2 = (float *) wbImport(wbArg_getInputFile(args, ), &inputLength);
hostOutput = (float *) malloc(inputLength * sizeof(float));
printf("inputLength ==%d, SegSize =%d\n", inputLength, SegSize);
wbTime_stop(Generic, "Importing data and creating memory on host"); cudaHostAlloc((void**)&h_A, inputLength*sizeof(float), cudaHostAllocDefault);
cudaHostAlloc((void**)&h_B, inputLength*sizeof(float), cudaHostAllocDefault);
cudaHostAlloc((void**)&h_C, inputLength*sizeof(float), cudaHostAllocDefault); memcpy(h_A, hostInput1,inputLength*sizeof(float));
memcpy(h_B, hostInput2,inputLength*sizeof(float)); wbCheck(cudaMalloc((void **)&d_A0, Csize));
wbCheck(cudaMalloc((void **)&d_A1, Csize));
wbCheck(cudaMalloc((void **)&d_B0, Csize));
wbCheck(cudaMalloc((void **)&d_B1, Csize));
wbCheck(cudaMalloc((void **)&d_C0, Csize));
wbCheck(cudaMalloc((void **)&d_C1, Csize));
wbCheck(cudaMalloc((void **)&d_A2, Csize));
wbCheck(cudaMalloc((void **)&d_A3, Csize));
wbCheck(cudaMalloc((void **)&d_B2, Csize));
wbCheck(cudaMalloc((void **)&d_B3, Csize));
wbCheck(cudaMalloc((void **)&d_C2, Csize));
wbCheck(cudaMalloc((void **)&d_C3, Csize)); cudaStream_t *streams = (cudaStream_t*) malloc(StreamNum * sizeof(cudaStream_t));
for(int i = ; i < StreamNum; i++)
cudaStreamCreate(&(streams[i])); int main = inputLength/(SegSize*StreamNum);
int left = inputLength%(SegSize*StreamNum); printf("main =%d, left=%d\n", main, left);
for(i=; i < inputLength; i+=SegSize*StreamNum)
{
cudaMemcpyAsync(d_A0, hostInput1+i, Csize, cudaMemcpyHostToDevice, streams[]);
cudaMemcpyAsync(d_B0, hostInput2+i, Csize, cudaMemcpyHostToDevice, streams[]);
cudaMemcpyAsync(d_A1, hostInput1+i+SegSize, Csize, cudaMemcpyHostToDevice, streams[]);
cudaMemcpyAsync(d_B1, hostInput2+i+SegSize, Csize, cudaMemcpyHostToDevice, streams[]);
cudaMemcpyAsync(d_A2, hostInput1+i+SegSize*, Csize, cudaMemcpyHostToDevice, streams[]);
cudaMemcpyAsync(d_B2, hostInput2+i+SegSize*, Csize, cudaMemcpyHostToDevice, streams[]);
cudaMemcpyAsync(d_A3, hostInput1+i+SegSize*, Csize, cudaMemcpyHostToDevice, streams[]);
cudaMemcpyAsync(d_B3, hostInput2+i+SegSize*, Csize, cudaMemcpyHostToDevice, streams[]); // block size is 256
vecAdd<<<SegSize/, SegSize, , streams[]>>>(d_A0, d_B0, d_C0, SegSize);
vecAdd<<<SegSize/, SegSize, , streams[]>>>(d_A1, d_B1, d_C1, SegSize);
vecAdd<<<SegSize/, SegSize, , streams[]>>>(d_A2, d_B2, d_C2, SegSize);
vecAdd<<<SegSize/, SegSize, , streams[]>>>(d_A3, d_B3, d_C3, SegSize); cudaMemcpyAsync(hostOutput+i, d_C0, Csize, cudaMemcpyDeviceToHost, streams[]);
//cudaStreamSynchronize(yiming_stream1);
cudaMemcpyAsync(hostOutput+i+SegSize, d_C1, Csize, cudaMemcpyDeviceToHost, streams[]);
cudaMemcpyAsync(hostOutput+i+SegSize*, d_C2, Csize, cudaMemcpyDeviceToHost, streams[]);
cudaMemcpyAsync(hostOutput+i+SegSize*, d_C3, Csize, cudaMemcpyDeviceToHost, streams[]);
} // Process the remaining elements
if(SegSize* < left){
printf("DDDDDDDD\n");
cudaMemcpyAsync(d_A0, hostInput1+i, Csize, cudaMemcpyHostToDevice, streams[]);
cudaMemcpyAsync(d_B0, hostInput2+i, Csize, cudaMemcpyHostToDevice, streams[]);
cudaMemcpyAsync(d_A1, hostInput1+i+SegSize, Csize, cudaMemcpyHostToDevice, streams[]);
cudaMemcpyAsync(d_B1, hostInput2+i+SegSize, Csize, cudaMemcpyHostToDevice, streams[]);
cudaMemcpyAsync(d_A2, hostInput1+i+SegSize*, Csize, cudaMemcpyHostToDevice, streams[]);
cudaMemcpyAsync(d_B2, hostInput2+i+SegSize*, Csize, cudaMemcpyHostToDevice, streams[]);
cudaMemcpyAsync(d_A3, hostInput1+i+SegSize*, (left-SegSize*)*sizeof(float), cudaMemcpyHostToDevice, streams[]);
cudaMemcpyAsync(d_B3, hostInput2+i+SegSize*, (left-SegSize*)*sizeof(float), cudaMemcpyHostToDevice, streams[]); // block size is 256
vecAdd<<<, SegSize, , streams[]>>>(d_A0, d_B0, d_C0, SegSize);
vecAdd<<<, SegSize, , streams[]>>>(d_A1, d_B1, d_C1, SegSize);
vecAdd<<<, SegSize, , streams[]>>>(d_A2, d_B2, d_C2, SegSize);
vecAdd<<<, (left-SegSize*), , streams[]>>>(d_A3, d_B3, d_C3, (left-SegSize*)); cudaMemcpyAsync(hostOutput+i, d_C0, Csize, cudaMemcpyDeviceToHost, streams[]);
//cudaStreamSynchronize(yiming_stream1);
cudaMemcpyAsync(hostOutput+i+SegSize, d_C1, Csize, cudaMemcpyDeviceToHost, streams[]);
cudaMemcpyAsync(hostOutput+i+SegSize*, d_C2, Csize, cudaMemcpyDeviceToHost, streams[]);
cudaMemcpyAsync(hostOutput+i+SegSize*, d_C3, (left-SegSize*)*sizeof(float), cudaMemcpyDeviceToHost, streams[]);
}
else if(SegSize* < left){
printf("CCCCCCCC\n");
cudaMemcpyAsync(d_A0, hostInput1+i, Csize, cudaMemcpyHostToDevice, streams[]);
cudaMemcpyAsync(d_B0, hostInput2+i, Csize, cudaMemcpyHostToDevice, streams[]);
cudaMemcpyAsync(d_A1, hostInput1+i+SegSize, Csize, cudaMemcpyHostToDevice, streams[]);
cudaMemcpyAsync(d_B1, hostInput2+i+SegSize, Csize, cudaMemcpyHostToDevice, streams[]);
cudaMemcpyAsync(d_A2, hostInput1+i+SegSize*, (left-SegSize*)*sizeof(float), cudaMemcpyHostToDevice, streams[]);
cudaMemcpyAsync(d_B2, hostInput2+i+SegSize*, (left-SegSize*)*sizeof(float), cudaMemcpyHostToDevice, streams[]); // block size is 256
vecAdd<<<, SegSize, , streams[]>>>(d_A0, d_B0, d_C0, SegSize);
vecAdd<<<, SegSize, , streams[]>>>(d_A1, d_B1, d_C1, SegSize);
vecAdd<<<, left-SegSize*, , streams[]>>>(d_A2, d_B2, d_C2, (left-SegSize*)); cudaMemcpyAsync(hostOutput+i, d_C0, Csize, cudaMemcpyDeviceToHost, streams[]);
//cudaStreamSynchronize(yiming_stream1);
cudaMemcpyAsync(hostOutput+i+SegSize, d_C1, Csize, cudaMemcpyDeviceToHost, streams[]);
cudaMemcpyAsync(hostOutput+i+SegSize*, d_C2, (left-SegSize*)*sizeof(float), cudaMemcpyDeviceToHost, streams[]); }
else if(SegSize < left)
{
printf("AAAAAAA, left- size ==%d\n", left-SegSize);
cudaMemcpyAsync(d_A0, hostInput1+i, Csize, cudaMemcpyHostToDevice, streams[]);
cudaMemcpyAsync(d_B0, hostInput2+i, Csize, cudaMemcpyHostToDevice, streams[]);
cudaMemcpyAsync(d_A1, hostInput1+i+SegSize, (left-SegSize)*sizeof(float), cudaMemcpyHostToDevice, streams[]);
cudaMemcpyAsync(d_B1, hostInput2+i+SegSize, (left-SegSize)*sizeof(float), cudaMemcpyHostToDevice, streams[]); // block size is 256
vecAdd<<<, SegSize, , streams[]>>>(d_A0, d_B0, d_C0, SegSize);
vecAdd<<<, left-SegSize, , streams[]>>>(d_A0, d_B0, d_C0, left-
SegSize); // cudaStreamSynchronize(streams[0]);
cudaMemcpyAsync(hostOutput+i, d_C0, Csize,cudaMemcpyDeviceToHost, streams[]);
cudaMemcpyAsync(hostOutput+i+SegSize, d_C1, (left-SegSize)*sizeof(float),cudaMemcpyDeviceToHost, streams[]); // i+=SegSize;
// left = left - SegSize;
}
else if(left > )
{
printf("BBBBBBB\n");
cudaMemcpyAsync(d_A0, hostInput1+i, left*sizeof(float), cudaMemcpyHostToDevice);
cudaMemcpyAsync(d_B0, hostInput2+i, left*sizeof(float), cudaMemcpyHostToDevice); vecAdd<<<, left, , streams[]>>>(d_A0, d_B0, d_C0, left); //cudaDeviceSynchronize();
cudaMemcpyAsync(hostOutput+i, d_C0, left*sizeof(float), cudaMemcpyDeviceToHost);
} cudaDeviceSynchronize();
wbSolution(args, hostOutput, inputLength); free(hostInput1);
free(hostInput2);
free(hostOutput); for(int i = ; i < StreamNum; i++)
cudaStreamDestroy(streams[i]); cudaFree(d_A0);
cudaFree(d_A1);
cudaFree(d_B0);
cudaFree(d_B1);
cudaFree(d_C0);
cudaFree(d_C1);
cudaFree(d_A2);
cudaFree(d_A3);
cudaFree(d_B2);
cudaFree(d_B3);
cudaFree(d_C2);
cudaFree(d_C3);
return ;
}
运行成功,但是遗留一个问题,当我把拷贝内存的代码改成:
cudaMemcpyAsync(d_A0, h_A+i, Csize, cudaMemcpyHostToDevice, streams[0]); 即使用页固定内存,结果就会错误,不明白为什么
6.2 CUDA streams的更多相关文章
- CUDA 进阶学习
CUDA基本概念 CUDA网格限制 1.2CPU和GPU的设计区别 2.1CUDA-Thread 2.2CUDA-Memory(存储)和bank-conflict 2.3CUDA矩阵乘法 3.1 全局 ...
- CUDA ---- Stream and Event
Stream 一般来说,cuda c并行性表现在下面两个层面上: Kernel level Grid level 到目前为止,我们讨论的一直是kernel level的,也就是一个kernel或者一个 ...
- Cuda Stream流分析
Cuda Stream流分析 Stream 一般来说,cuda c并行性表现在下面两个层面上: Kernel level Grid level Stream和event简介 Cuda stream是指 ...
- PyTorch中的CUDA操作
CUDA(Compute Unified Device Architecture)是NVIDIA推出的异构计算平台,PyTorch中有专门的模块torch.cuda来设置和运行CUDA相关操作.本 ...
- cudaMemcpy与cudaMemcpyAsync的区别
转载请注明来源:http://www.cnblogs.com/shrimp-can/p/5231857.html 简单可以理解为:cudaMemcpy是同步的,而cudaMemcpyAsync是异步的 ...
- Suricata的规则解读(默认和自定义)
不多说,直接上干货! 见suricata官网 https://suricata.readthedocs.io/en/latest/rules/index.html 一.Suricata的规则所放位置 ...
- suricata.yaml (一款高性能的网络IDS、IPS和网络安全监控引擎)默认配置文件(图文详解)
不多说,直接上干货! 前期博客 基于CentOS6.5下Suricata(一款高性能的网络IDS.IPS和网络安全监控引擎)的搭建(图文详解)(博主推荐) 或者 基于Ubuntu14.04下Suric ...
- TensorRT 介绍
引用:https://arleyzhang.github.io/articles/7f4b25ce/ 1 简介 TensorRT是一个高性能的深度学习推理(Inference)优化器,可以为深度学习应 ...
- 【转载】 NVIDIA Tesla/Quadro和GeForce GPU比较
原文地址: https://blog.csdn.net/m0_37462765/article/details/74394932 版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议 ...
随机推荐
- replace()替换文字
var test = text.innerHTML; b = test.replace(/任晓强/g,"你好"); console.log(b); html: <div id ...
- Windows下的Memcache安装与测试教程
Windows下的Memcache安装 1.下载memcache for windows. 下载地址:http://splinedancer.com/memcached-win32/,推荐下载bina ...
- hdu 1018
数学题 用的这个方法比较烂 g++超时 c++ 406ms /******************************************************************* ...
- Untiy 接入 移动MM 详解
原地址:http://www.cnblogs.com/alongu3d/p/3627936.html Untiy 接入 移动MM 详解 第一次接到师傅的任务(小龙),准备着手写untiy接入第三方SD ...
- 快速排序(quicksort)算法实现
快速排序(quicksort)是分治法的典型例子,它的主要思想是将一个待排序的数组以数组的某一个元素X为轴,使这个轴的左侧元素都比X大,而右侧元素都比X小(从大到小排序).然后以这个X在变换后数组的位 ...
- HDU 1494 跑跑卡丁车 (DP)
题目链接 题意 : 中文题不详述. 思路 : sum = L*N 段,每走过一段如果不用加速卡的话,能量会增20%,将20%看作1,也就是说每涨到15就要变为10,所以最多是14才不浪费. dp[i] ...
- 李洪强iOS开发之静态库
iOS开发拓展篇—静态库 一.简单介绍 1.什么是库? 库是程序代码的集合,是共享程序代码的一种方式 2.库的分类 根据源代码的公开情况,库可以分为2种类型 (1)开源库 公开源代码,能看到具体实现 ...
- Java IO3:字符流
字符流 字节流提供了处理任何类型输入/输出操作的功能(对于计算机而言,一切都是0 和1,只需把数据以字节形式表示就够了),但它们不可以直接操作Unicode字符,一个Unicode字符占用2个字节,而 ...
- 编译GNU Global
GNU Global是一套界面更友好的tag系统,但是因为其支持的语言太少,现在一般使用其为前端,后端一般使用最新的Universal Ctags. 编译办法如下: 1.去GNU Project ht ...
- 254 shades of grey
254 shades of grey Description: Why would we want to stop to only 50 shades of grey? Let's see to ho ...