Reputation: 853
I've 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've installed pyCuda using pip in an anaconda shell and i'm using microsoft visual studio 14.0. Follow these i've added ollowing line in nvcc.profile:
COMPILER-BINDIR = C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64
but it returns always the same error.
Thanks.
Upvotes: 4
Views: 5204
Reputation: 145
I just solved this error by adding cl.exe to my windows path and restarting my ide.
The path to cl.exe varies depending on the version and installation directory of Visual Studio. Typically, cl.exe is located in a directory similar to C:\Program Files\Microsoft Visual Studio\[Version]\[Edition]\VC\Tools\MSVC\[Version]\bin\Host[X64 or X86]\[x64 or x86].
Upvotes: 0
Reputation: 132
If you are using Windows make the following settings in Environment Variables:
PATH:
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2\bin
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2\libnvvp
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2\lib\x64
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2\extras\CUPTI\libx64
C:\ProgramFiles(x86)\MicrosoftVisualStudio\2019\Community\VC\Tools\MSVC\14.23.28105\bin\Hostx64\x64"
CUDA_PATH: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2
CUDA_PATH_V8_0: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2
NVCUDASAMPLES_ROOT: C:\ProgramData\NVIDIA Corporation\CUDA Samples\v10.2
NVCUDASAMPLES8_0_ROOT: C:\ProgramData\NVIDIA Corporation\CUDA Samples\v10.2
After you finish, click OKs and restart the computer.
Upvotes: -1
Reputation: 11271
Don't change nvcc.profile
. You probably had the same issue I had. I edited compiler.py
to output the stdout of the 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 in your python file. In my case, I needed to add the following lines at the start 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 MSVS version compatible with CUDA. I.e. CUDA v9.0 doesn't support MSVS2017 and CUDA v9.1 only supports version 15.4, not later versions. Try if it works by running nvcc.exe
from the Native Tools Command Prompt for Visual Studio.
Upvotes: 3