pycuda:kernel.cu的nvcc compitalation失败了

时间:2017-02-16 22:59:53

标签: python nvcc pycuda

当我尝试编译时,我刚刚安装了pyCuda:     import pycuda.autoinit     将pycuda.driver导入为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];
}
""")

这是结果:

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]

我在anaconda shell中使用pip安装了pyCuda,我正在使用microsoft visual studio 14.0。关注these我在nvcc.profile中添加了ollowing line:

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

但它总是返回相同的错误。

感谢。

2 个答案:

答案 0 :(得分:1)

不要改变add_shortcode( 'map', 'gmaps_map' ); function gmaps_map( $args ) { $id = substr( sha1( "Google Map" . time() ), rand( 2, 10 ), rand( 5, 8 ) ); ob_start(); $args = shortcode_atts( array( 'lat' => '49', 'lng' => '9', 'zoom' => '12', 'height' => '300px', 'id' => '0' ), $args, 'map' ); ?> <div class='map' style='height:<?php echo $args['height'] ?>;' id='map-<?php echo $id ?>'></div> <script type='text/javascript'> var <?php echo $args['id'] ?>; function initMap() { map = new google.maps.Map(document.getElementById('map-<?php echo $id ?>'), { center: {lat: <?php echo $args['lat'] ?>, lng: <?php echo $args['lng'] ?>}, zoom: <?php echo $args['zoom'] ?> }); var image = new google.maps.MarkerImage("<?php echo get_template_directory_uri(); ?>/images/marker.png", null, null, null, new google.maps.Size(64,64)); var marker = new google.maps.Marker({ position: {lat: <?php echo $args['lat'] ?>, lng: <?php echo $args['lng'] ?>}, map: map, icon: image, // null = default icon animation: google.maps.Animation.DROP, title: 'Hello World!' }); } </script> <?php $output = ob_get_clean(); return $output; } add_action( 'wp_enqueue_scripts', 'gmaps_enqueue_assets' ); function gmaps_enqueue_assets() { wp_enqueue_script( 'google-maps', '//maps.googleapis.com/maps/api/js?callback=initMap', array(), '1.0', true ); } 。你可能遇到了同样的问题。我编辑了nvcc.profile来输出命令调用的标准输出。我得到compiler.py

因此,如果您的情况相同,则需要在python文件中添加cl.exe的路径。就我而言,我需要在代码的开头添加以下行。

"nvcc fatal : Cannot find compiler 'cl.exe' in PATH"

编辑:您需要运行与CUDA兼容的MSVS版本。即CUDA v9.0不支持MSVS2017,CUDA v9.1仅支持15.4版本,而不支持更高版本。通过从Visual Studio的Native Tools命令提示符运行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") 来尝试它是否有效。

答案 1 :(得分:-1)

如果使用Windows,请在“环境变量”中进行以下设置:

路径:

C:\ Program Files \ NVIDIA GPU计算工具包\ CUDA \ v10.2 \ bin

C:\ Program Files \ NVIDIA GPU计算工具包\ CUDA \ v10.2 \ libnvvp

C:\ Program Files \ NVIDIA GPU Computing Toolkit \ CUDA \ v10.2 \ lib \ x64

C:\ Program Files \ NVIDIA GPU计算工具包\ 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

完成后,单击“确定”,然后重新启动计算机。