728x90
반응형
간단한 예제
import pycuda.autoinit
import pycuda.driver as drv
import numpy
from pycuda.compiler import SourceModule
mod = SourceModule("""
__global__ void multiply_them(float *dest, float *a, float *b)
{
const int i = threadIdx.x;
dest[i] = a[i] * b[i];
}
""")
multiply_them = mod.get_function("multiply_them")
a = numpy.random.randn(400).astype(numpy.float32)
b = numpy.random.randn(400).astype(numpy.float32)
dest = numpy.zeros_like(a)
multiply_them(
drv.Out(dest), drv.In(a), drv.In(b),
block=(400,1,1), grid=(1,1))
print dest-a*b
https://documen.tician.de/pycuda/
728x90
반응형
'AI Development > GPU | CUDA | PyCUDA' 카테고리의 다른 글
[CUDA] CUDA Driver Version (0) | 2020.07.06 |
---|---|
[PyCUDA] 정리중 (0) | 2020.05.14 |
[GPU] GPU Performance 및 Titan V, RTX 2080 Ti Benchmark (0) | 2020.03.04 |
[CUDA] CUDA Capability 확인 (2) | 2019.05.31 |
[CUDA] Visual Studio 2015, OpenCV , CUDA 연동하기 (3) | 2017.01.25 |