4

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.

Community
  • 1
  • 1
Giuseppe Angora
  • 833
  • 1
  • 10
  • 25

2 Answers2

3

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.

user4020527
  • 1
  • 8
  • 20
JHBonarius
  • 10,824
  • 3
  • 22
  • 41
  • 1
    Effectively, for example with CUDA 10.1 you must install the VS2019 C compiler, to avoid this error. I suggest using the command 'nvcc --version' instead of nvcc.exe, in the Native Tools Command Prompt for Visual Studio. – Roger Gomez Nieto Nov 08 '20 at 12:50
-1

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.

Alana Melo
  • 132
  • 5