我尝试使用 CUDA 运行代码,出现此错误,系统似乎有问题
完整代码:我知道了CUDACast #10a - 你的第一个 CUDA Python 程序,没有名为 numbapro 的模块
import numpy as np
from timeit import default_timer as timer
from numba import vectorize
@vectorize(["float32(float32, float32)"], target='cuda')
def VectorAdd(a, b):
return a + b
def main():
N = 32000000
A = np.ones(N, dtype=np.float32)
B = np.ones(N, dtype=np.float32)
C = np.zeros(N, dtype=np.float32)
start = timer()
C = VectorAdd(A, B)
vectoradd_timer = timer() - start
print("C[:5] = " + str(C[:5]))
print("C[-5:] = " + str(C[-5:]))
print("VectorAdd took …Run Code Online (Sandbox Code Playgroud) 我想用cv2.imshow("Otsu img", binary)而不是plt.imshow( binary)
我收到错误
完整代码:
import matplotlib.pyplot as plt
from skimage import io
from skimage.filters.rank import entropy
from skimage.morphology import disk
import numpy as np
from skimage.filters import threshold_otsu
import cv2
img = io.imread("scratch.jpg")
entropy_img = entropy(img, disk(10))
thresh = threshold_otsu(entropy_img)
binary = entropy_img <= thresh
cv2.imshow("Otsu img", binary)
cv2.waitKey(0)
cv2.destroyAllWindows()
Run Code Online (Sandbox Code Playgroud)
如何修复这个错误?
cv2.imshow("Otsu img", binary)
TypeError: mat data type = 0 is not supported
Run Code Online (Sandbox Code Playgroud)