Pycuda: nvcc compilation kernel.cu failed

I just installed pyCuda when I try to compile: 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]; } """) 

this is the result:

 Traceback (most recent call last): File "<stdin>", line 7, in <module> File "C:\Program Files\Anaconda3\lib\site-packages\pycuda\compiler.py", line 265, in __init__ arch, code, cache_dir, include_dirs) File "C:\Program Files\Anaconda3\lib\site-packages\pycuda\compiler.py", line 255, in compile return compile_plain(source, options, keep, nvcc, cache_dir, target) File "C:\Program Files\Anaconda3\lib\site-packages\pycuda\compiler.py", line 137, in compile_plain stderr=stderr.decode("utf-8", "replace")) pycuda.driver.CompileError: nvcc compilation of C:\Users\whyno\AppData\Local\Temp\tmpkv6oyxif\kernel.cu failed [command: nvcc --cubin -arch sm_50 -m64 -Ic:\program files\anaconda3\lib\site-packages\pycuda\cuda kernel.cu] 

I installed pyCuda using pip in the anaconda shell and I am using Microsoft Visual Studio 14.0. Follow this , I added the ollowing line to nvcc.profile:

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

but always returns the same error.

Thanks.

+5
source share
1 answer

Do not change nvcc.profile . You probably had the same problem. I edited compiler.py to output the stdout command call. I got "nvcc fatal : Cannot find compiler 'cl.exe' in PATH" .

So, if this is the same case for you, you need to add the path to cl.exe to the python file. In my case, I needed to add the following lines at the beginning of my code.

 import os if os.system("cl.exe"): os.environ['PATH'] += ';'+r"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\bin\HostX64\x64" if os.system("cl.exe"): raise RuntimeError("cl.exe still not found, path probably incorrect") 

Edit: You need to run a version of MSVS compatible with CUDA. That is, CUDA v9.0 does not support MSVS2017, and CUDA v9.1 supports only versions 15.4, and not later versions. Try it if it works by running nvcc.exe from the command line of Native Tools for Visual Studio.

+1
source

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