如何在协作室中使用numba [英] How to use numba in Colaboratory

查看:84
本文介绍了如何在协作室中使用numba的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人尝试在Google合作实验室中使用numba吗?我只是不知道如何在此环境中进行设置.此刻,我陷入了未找到库nvvm 的错误.

Anybody tried to use numba in google collaboratory? I just can not figure out how to set it up in this environment. At the moment, I'm stuck with the error library nvvm not found.

推荐答案

将此代码复制到单元格中.它对我有用.

Copy this code into cell. It works for me.

!apt-get install nvidia-cuda-toolkit
!pip3 install numba

import os
os.environ['NUMBAPRO_LIBDEVICE'] = "/usr/lib/nvidia-cuda-toolkit/libdevice"
os.environ['NUMBAPRO_NVVM'] = "/usr/lib/x86_64-linux-gnu/libnvvm.so"

from numba import cuda
import numpy as np
import time

@cuda.jit
def hello(data):
    data[cuda.blockIdx.x, cuda.threadIdx.x] = cuda.blockIdx.x

numBlocks = 5
threadsPerBlock = 10

data = np.ones((numBlocks, threadsPerBlock), dtype=np.uint8)

hello[numBlocks, threadsPerBlock](data)

print(data)

这篇关于如何在协作室中使用numba的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆