我如何知道安装了numba或tensorflow的python代码中每个块的最大线程数? [英] How do I know the maximum number of threads per block in python code with either numba or tensorflow installed?

查看:75
本文介绍了我如何知道安装了numba或tensorflow的python代码中每个块的最大线程数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在python中是否安装了numba或tensorflow的任何代码?例如,如果我想了解GPU内存信息,则可以简单地使用:

Is there any code in python with either numba or tensorflow installed? For example, if I would like to know the GPU memory info, I can simply use:

from numba import cuda
gpus = cuda.gpus.lst
for gpu in gpus:
    with gpu:
        meminfo = cuda.current_context().get_memory_info()
        print("%s, free: %s bytes, total, %s bytes" % (gpu, meminfo[0], meminfo[1]))

在numba中.但是我找不到任何能给我每个块信息最大线程数的代码.我希望代码能够检测每个块的最大线程数,并进一步计算每个方向上指定的块数.

in numba. But I can not find any code that gives me the maximum threads per block info. I would like the code to detect the maximum number of threads per block and further calculate the specified number of blocks in each direction.

推荐答案

在python中是否安装了numba 或tensorflow 的代码?

不是我能找到的.numba设备类似乎具有检索设备属性的功能:

Not that I can find. The numba device class appears to have facilities to retrieve device attributes:

In [9]: ddd=numba.cuda.get_current_device()

In [10]: print(ddd)
<CUDA device 0 'b'GeForce GTX 970''>

In [11]: print(ddd.attributes)
{}

,但至少在我使用的numba版本(0.31.0)中,似乎未填充该词典.否则,在这个阶段,numba不会公开任何用于检索设备或已编译函数属性的常规驱动程序API功能.

but at least in the numba version I am using (0.31.0), the dictionary does not appear to be populated. Otherwise, it does not appear that any of the conventional driver API functionality for retrieving either device or compiled function properties are exposed by numba at this stage.

这篇关于我如何知道安装了numba或tensorflow的python代码中每个块的最大线程数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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