[英]While running program in Ubuntu 18.04 (Running inside VMWare) am getting this error: AssertionError: Torch not compiled with CUDA enabled
[英]Error while running the python cuda program
我是python内核编程的新手,要学习,我点击了此链接 。 尝试运行示例Cuda python程序时,出现如下错误。 我不知道,这是什么? 请帮助我解决此问题,以便我可以继续学习。
Traceback (most recent call last):
File "numpycuda.py", line 17, in <module>
my_kernel[blockspergrid, threadsperblock](data)
File "/home/face/.local/lib/python2.7/site-
packages/numba/cuda/simulator/kernel.py", line 103, in
__getitem__
normalize_kernel_dimensions(*configuration[:2])
File "/home/face/.local/lib/python2.7/site-
packages/numba/cuda/errors.py", line 38, in
normalize_kernel_dimensions
griddim = check_dim(griddim, 'griddim')
File "/home/face/.local/lib/python2.7/site-
packages/numba/cuda/errors.py", line 33, in check_dim
% (name, dim)).
TypeError: griddim must be a sequence of integers, got [1.0]
Python程序
from __future__ import division
from numba import cuda
import numpy
import math
# CUDA kernel
@cuda.jit
def my_kernel(io_array):
pos = cuda.grid(1)
if pos < io_array.size:
io_array[pos] *= 2 # do the computation
# Host code
data = numpy.ones(256)
threadsperblock = 256
blockspergrid = math.ceil(data.shape[0] / threadsperblock)
my_kernel[blockspergrid, threadsperblock](data)
print(data)
我安装了numba,CUDA和numpy库,可能是什么问题? 我正在使用2.7.12的python版本
Numba内核启动要求执行参数为整数或整数元组。 您对math.ceil(data.shape[0] / threadsperblock)
将产生一个浮点数,该浮点数不能用作执行参数。
您可以执行以下操作:
data = numpy.ones(250)
threadsperblock = 64
blockspergrid = (data.shape[0] + threadsperblock - 1) // threadsperblock
my_kernel[blockspergrid, threadsperblock](data)
哪个应该正常工作
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.