OS: win10PyCuda "NVCC фатальным: Не удается найти компилятор 'cl.exe' в PATH"
VS: визуальный stadio2015 64bit
CUDA: CUDA8.0
питон: python2.7.12 64биную (PyCuda)
Я последовал за этот сайт, https://documen.tician.de/pycuda/tutorial.html#getting-started
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)#transfer the data to the GPU
#executing a kernel
#function: write code to double each entry in a_gpu.
#we write the corresponding CUDA C code, and feed it into the constructor of pycuda.compiler.SourceModule
mod = SourceModule("""
__global__ void doublify(float *a)
{
int idx = threadIdx.x + threadIdx.y*4;
a[idx] *= 2;
}
""")
#If there aren’t any errors, the code is now compiled and loaded onto the device. We find a reference to our pycuda.driver.Function and call it, specifying a_gpu as the argument, and a block size of 4x4:
func = mod.get_function("doublify")
func(a_gpu, block=(4,4,1))
#Finally, we fetch the data back from the GPU and display it, together with the original a:
a_doubled = numpy.empty_like(a)
cuda.memcpy_dtoh(a_doubled, a_gpu)
print a_doubled
print a
, но потерпела неудачу с ошибкой:
Traceback (most recent call last):
File "G:/myworkspace/python2.7/cuda/test.py", line 24, in <module>
""")
File "D:\python2.7\lib\site-packages\pycuda\compiler.py", line 265, in __init__
arch, code, cache_dir, include_dirs)
File "D:\python2.7\lib\site-packages\pycuda\compiler.py", line 255, in compile
return compile_plain(source, options, keep, nvcc, cache_dir, target)
File "D:\python2.7\lib\site-packages\pycuda\compiler.py", line 137, in compile_plain
stderr=stderr.decode("utf-8", "replace"))
CompileError: nvcc compilation of c:\users\gl\appdata\local\temp\tmp8poxqp\kernel.cu failed
[command: nvcc --cubin -arch sm_50 -m64 -Id:\python2.7\lib\site-packages\pycuda\cuda kernel.cu]
[stdout:
nvcc fatal : Cannot find compiler 'cl.exe' in PATH
]
Кто-то сказал, чтобы добавить дир cl.exe к окружающей среде. Я сделал, и ошибка такая же. Я новичок в CUDA. Как я могу решить эту проблему? Некоторые советы?
Я сделал, как @citizenSNIPS посоветовал:
добавить путь к cl.exe, D: \ vs2015 \ VC \ Bin.
INCLUDE = C: \ Program Files (x86) \ Windows Kits \ 10 \ Include \ 10.0.10240.0 \ ucrt.
LIB = C: \ Program Files (x86) \ Windows Kits \ 10 \ Lib \ 10.0.10240.0 \ ucrt \ x64 (я не могу найти C: \ Program Files (x86) \ Windows Kits \ 10 \ Lib \ 10.0.10240.0 \ um \ x64 на моем компьютере).
Там была новая ошибка следующим образом:
raceback (most recent call last):
File "G:\myworkspace\python2.7\cuda\test.py", line 24, in <module>
""")
File "D:\python2.7\lib\site-packages\pycuda\compiler.py", line 265, in __init__
arch, code, cache_dir, include_dirs)
File "D:\python2.7\lib\site-packages\pycuda\compiler.py", line 255, in compile
return compile_plain(source, options, keep, nvcc, cache_dir, target)
File "D:\python2.7\lib\site-packages\pycuda\compiler.py", line 147, in compile_plain
+ (stdout+stderr).decode("utf-8", "replace"), stacklevel=4)
File "D:\python2.7\lib\idlelib\run.py", line 36, in idle_showwarning_subproc
message, category, filename, lineno, line))
File "D:\python2.7\lib\idlelib\PyShell.py", line 65, in idle_formatwarning
s += "%s: %s\n" % (category.__name__, message)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 147-168: ordinal not in range(128)
сейчас я работаю для этой проблемы, может быть, это потому, что я не добавлял C: \ Program Files (x86) \ Windows Kits \ 10 \ Lib \ 10.0.10240.0 \ ит \ x64?
Вы используете IDE для запуска своего кода или вызова из терминала? –
Я использую IDLE (графический интерфейс python). – glen