Used numba to consume GPU instead of CPU in loop

折月煮酒 提交于 2021-02-04 21:35:41

问题


I have a list with multiply identities and each identity consists of multiple images. When i am retrieving positive images from json list it works fine. After that I am mixing this positive list with by doing cross product with every images in pair form and then save in negative array. When i am doing cross product, my system got completely hang even i have 16 GB RAM with GPU.

Code

for i in range(0, len(idendities) - 1):
    for j in range(i + 1, len(idendities)):
        # print(samples_list[i], " vs ",samples_list[j])
        cross_product = itertools.product(samples_list[i], samples_list[j])
        cross_product = list(cross_product)
        # print(cross_product)

        for cross_sample in cross_product:
            # print(cross_sample[0], " vs ", cross_sample[1])
            negative = []
            negative.append(cross_sample[0])
            negative.append(cross_sample[1])
            negatives.append(negative)

negatives = pd.DataFrame(negatives, columns=["file_x", "file_y"])
negatives["decision"] = "No"

negatives = negatives.sample(positives.shape[0])

来源:https://stackoverflow.com/questions/65629130/used-numba-to-consume-gpu-instead-of-cpu-in-loop

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!