import pycuda.driver as drv
import pycuda.tools
import pycuda.autoinit
import numpy
import numpy.linalg as la
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))
print dest-a*b
C:\Python27>hello_gpu.pyкусок кода из compiler.py, в котором как я понял ошибка вылезает:
Traceback (most recent call last):
File “C:\Python27\hello_gpu.py”, line 14, in <module>
“”“)
File ”C:\Python27\lib\site-packages\pycuda\compiler.py“, line 235, in __init__
arch, code, cache_dir, include_dirs)
File ”C:\Python27\lib\site-packages\pycuda\compiler.py“, line 201, in compile
”pycuda-compiler-cache-v1-%s“ % _get_per_user_string())
File ”C:\Python27\lib\site-packages\pycuda\compiler.py", line 139, in _get_per_user_string
checksum.update(environ)
File “C:\Python27\lib\os.py”, line 423, in __getitem__
return self.data
KeyError: ‘HOME’
def _get_per_user_string():
try:
from os import getuid
except ImportError:
checksum = _new_md5()
from os import environ
checksum.update(environ["HOME"])
return checksum.hexdigest()
else:
return "uid%d" % getuid()
Python 2.7.1
NVIDIA GPU Computing Toolkit 3.2
numpy-1.5.1.win32-py2.7
pytools-11
decorator-3.2.1
pycuda-0.94.2.win32-py2.7
операционка Windows 7 64x. Если важно: стоит Visual Studio 2010 и Delphi 7.
Посоветуйте, как заставить проект работать? я “в питоне” совсем недавно, буквально недели 2 только.