半精度单精度双精度
三者分别是16位、32位、64位,一个字节8位因此分别是2位、4位、8位,它们都分成3部分,符号位,指数和尾数。不同精度只不过是指数位和尾数位的长度不一样:
; TiB和TB
TB,GB这些是1000进制,1TB=1000 GB
TiB GiB这些是1024进制,1TiB = 1024GiB
TiB和TB之间换算: 1TiB = 1.099511627776 TB (具体换算过程就不写了,自己拿个小本本算)
TB(Terabyte) 是国际单位制 International System of Units (SI).是十进制,包括:kilo, mega, giga, tera, peta, exa, zetta and yotta
TiB(Tebibyte)是International Electrotechnical Commission (IEC) 单位,是二进制,包括:kibi, mebi, gibi, pebi, exbi, zebi and yobi
矩阵运算过程
a=np.ones([9216,9216,9216],dtype=float)
b=np.ones([9216,9216,9216],dtype=float)
gpu.matmul(a,b)
报错:
numpy.core._exceptions.MemoryError: Unable to allocate 5.70 TiB for an array with shape (9216, 9216, 9216) and data type float64
5.70TiB怎么计算出来的,过程如下:
921 6 3 × 8 × ÷ 102 7 4 = 5.6953125 ( T i B ) ≈ 5.70 T i B 9216^{3}\times8\times\div1027^{4}=5.6953125(TiB)\approx5.70TiB 921 6 3 ×8 ×÷102 7 4 =5.6953125 (T i B )≈5.70 T i B
921 6 3 9216^{3}921 6 3是矩阵的形状大小,然后因为每个元素都是float64,占8位因此乘以8。
102 7 4 1027^{4}102 7 4是1TiB,1TiB=1024GiB,1GiB=1024MiB, 1MiB=1024KiB,1KiB=1024Byte字节,1Byte=8bit二进制位。
Original: https://blog.csdn.net/RayChiu757374816/article/details/126617765
Author: RayChiu_Labloy
Title: python矩阵运算内存占用计算
原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/762865/
转载文章受原作者版权保护。转载请注明原作者出处!