Install pycuda-2013.1.1 on windows 7 64 bit

FYI, I have a 64-bit version of Python 2.7 and I followed the instructions for installing pycuda to install pycuda. A.

And I have no problems following the script.

import pycuda.driver as cuda import pycuda.autoinit from pycuda.compiler import SourceModule import numpy a = numpy.random.randn(4,4) a = a.astype(numpy.float32) a_gpu = cuda.mem_alloc(a.nbytes) cuda.memcpy_htod(a_gpu,a) 

But after that, when fulfilling this statement

 mod = SourceModule(""" __global__ void doublify(float *a) { int idx = threadIdx.x + threadIdx.y * 4; a[idx] *= 2; } """) 

I got error messages

CompileError: nvcc compilation c: \ users \ xxxx \ appdata \ local \ temp \ tmpaoxt97 \ kernel.cu failed [command: nvcc --cubin -arch sm_21 -m64 -Ic: \ python27 \ lib \ site-packages \ pycuda \ cuda kernel.cu] [stderr: nvcc: fatal error: nvcc could not find a supported version of Microsoft Visual Studio. Only versions 2008, 2010 and 2012 are supported.

But I have VS 2008 and VS 2010 installed on the machine, and set the path and nvcc profile according to the instructions. Will someone tell me what is going on?

UPDATE1 . As cgohike noted, performing the following statements before a problematic statement will solve the problem.

 import os os.system("vcvarsamd64.bat") 
+4
source share
2 answers

Call "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" amd64 or "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" amd64 before python.exe . This will set all the necessary environment variables to use the 64-bit Visual Studio compiler from Python or the command line.

+2
source

Well, it's too early to call it final. Even with permission from cgohike, I got the same error when I ran another script, like this

 import pycuda.gpuarray as gpuarray import pycuda.driver as cuda import pycuda.autoinit import numpy a_gpu = gpuarray.to_gpu(numpy.random.randn(4, 4)) print "a_gpu =" print a_gpu a_doubled = (2*a_gpu).get() print print "a_doubled =" print a_doubled 

And then I found this answer. So in my case, I added the following line to nvcc.profile

 COMPILER-BINDIR = C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64 

After that, a compiler error no longer occurs. Hope this helps others.

+3
source

Source: https://habr.com/ru/post/1264330/


All Articles