2017-02-16 7 views
5

Ich habe pyCuda gerade installiert haben, wenn ich zu kompilieren versuchen: Import pycuda.autoinit Import pycuda.driver als drv Import numpypycuda: nvcc compitalation von kernel.cu gescheitert

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]; 
} 
""") 

ist dies die Ergebnis:

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] 

ich habe installiert pyCuda Pip in einer Anakonda-Shell, und ich bin mit Microsoft Visual Studio 14.0. Folgen Sie these ich habe hinzugefügt ach Linie in nvcc.profile:

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

aber es gibt immer den gleichen Fehler.

Danke.

Antwort

1

Nicht ändern nvcc.profile. Sie hatten wahrscheinlich das gleiche Problem, das ich hatte. Ich bearbeitete compiler.py, um das stdout des Befehlsanrufs auszugeben. Ich habe "nvcc fatal : Cannot find compiler 'cl.exe' in PATH".

Also, wenn dies der gleiche Fall für Sie ist, müssen Sie den Pfad zu cl.exe in Ihrer Python-Datei hinzufügen. In meinem Fall musste ich am Anfang meines Codes die folgenden Zeilen hinzufügen.

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: Sie benötigen eine MSVS Version kompatibel mit CUDA auszuführen. I.e. CUDA v9.0 unterstützt MSVS2017 nicht und CUDA v9.1 unterstützt nur Version 15.4, nicht spätere Versionen. Probieren Sie es aus, indem Sie nvcc.exe über die Native Tools-Eingabeaufforderung für Visual Studio ausführen.