Page 1 of 1
cuda.lib return 32bit integer
Posted: Sat Jul 20, 2019 3:01 pm
by Etayson
Hi, sorry for my bad english
I have a problem with cuda.lib, this library return 32bit integer when should return 64bit.
Nvidia forum say that all is correct and and I'm doing something wrong
Let`s see code:
Code: Select all
Import "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\lib\x64\cuda.lib"
cuInit(Flags.i)
cuDeviceGetCount(count.i)
cuDeviceGet(device.i, ordinal.i)
cuDeviceGetName(name.s,len.i,dev.i)
cuDeviceTotalMem(bytes.i,dev.i)
cuDeviceTotalMem_v2(bytes.i,dev.i) ;UNDOCUMENTED!!!
EndImport
;main
OpenConsole()
CudaDevice.i
namedev.s=Space(128)
sizebytes.i
sizebytes64.i
piattrib.i
major.i
minor.i
count.i
mp.i
cores.i
cuInit(0)
cuDeviceGetCount(@count)
If count>0
PrintN("Found "+count+" Cuda device.")
Else
PrintN("No Cuda device found.")
Input()
End
EndIf
For i=0 To count-1
cores=0
cuDeviceGet(@CudaDevice, i)
cuDeviceGetName(namedev,128,CudaDevice)
cuDeviceTotalMem(@sizebytes,CudaDevice)
cuDeviceTotalMem_v2(@sizebytes64,CudaDevice)
PrintN("Cuda device["+Str(CudaDevice)+"]:"+namedev)
PrintN("cuDeviceTotalMem:"+Str(sizebytes/1048576)+"Mb")
PrintN("cuDeviceTotalMem_v2:"+Str(sizebytes64/1048576)+"Mb")
Next i
Input()
CloseConsole()
End
To run code you should have installed nvidia cudatoolkit.
So question, why nvidia say that all is ok, but documented function cuDeviceTotalMem return only 32bit integer while undocumented cuDeviceTotalMem_v2 return correct 64bit value ???
Re: cuda.lib return 32bit integer
Posted: Sat Jul 20, 2019 7:06 pm
by mk-soft
32 bit Integer Signed or Unsigned?
Not testet
Code: Select all
Import "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\lib\x64\cuda.lib"
cuInit(Flags.i)
cuDeviceGetCount(count.i)
cuDeviceGet(device.i, ordinal.i)
cuDeviceGetName(name.s,len.i,dev.i)
cuDeviceTotalMem(*bytes,dev.i)
cuDeviceTotalMem_v2(*bytes,dev.i) ;UNDOCUMENTED!!!
EndImport
Structure llValue
StructureUnion
l.l
q.q
EndStructureUnion
EndStructure
;main
OpenConsole()
Define CudaDevice.i
Define namedev.s=Space(128)
Define sizebytes.llValue
Define sizebytes64.llValue
Define piattrib.i
Define major.i
Define minor.i
Define count.i
Define mp.i
Define cores.i
cuInit(0)
cuDeviceGetCount(@count)
If count>0
PrintN("Found "+count+" Cuda device.")
Else
PrintN("No Cuda device found.")
Input()
End
EndIf
For i=0 To count-1
cores=0
cuDeviceGet(@CudaDevice, i)
cuDeviceGetName(namedev,128,CudaDevice)
cuDeviceTotalMem(@sizebytes,CudaDevice)
cuDeviceTotalMem_v2(@sizebytes64,CudaDevice)
PrintN("Cuda device["+Str(CudaDevice)+"]:"+namedev)
PrintN("cuDeviceTotalMem Signed:"+Str(sizebytes\l / 1048576)+"Mb")
PrintN("cuDeviceTotalMem Unsigned:"+Str(sizebytes\q / 1048576)+"Mb")
PrintN("cuDeviceTotalMem_v2:"+Str(sizebytes64\q / 1048576)+"Mb")
Next i
Input()
CloseConsole()
End
Re: cuda.lib return 32bit integer
Posted: Sat Jul 20, 2019 7:31 pm
by Etayson
mk-soft wrote:32 bit Integer Signed or Unsigned?
Not testet
Hi, thanks for answer
It is result of your code:
Code: Select all
Found 1 Cuda device.
Cuda device[0]:GeForce RTX 2080 Ti
cuDeviceTotalMem Signed:0Mb
cuDeviceTotalMem Unsigned:4095Mb
cuDeviceTotalMem_v2:11264Mb
The same like my code cuDeviceTotalMem return 32bit integer
I think that cuda.lib have bug with returned value, because undocumented functions with prefix _v2 always return correct 64bit value.
I can`t use _v2 prefix because there is same limitations..
Re: cuda.lib return 32bit integer
Posted: Sat Jul 20, 2019 7:45 pm
by mk-soft
The result of 32bit Unsigned Integer is right
Limit of Unsigned Value
Code: Select all
Structure llValue
StructureUnion
l.l
q.q
EndStructureUnion
EndStructure
a.llValue
#MegaBytes = 1024 *1024
a\l = $FFFFFFFF
Debug a\q
Debug a\q / #MegaBytes
Re: cuda.lib return 32bit integer
Posted: Sat Jul 20, 2019 7:52 pm
by Etayson
mk-soft wrote:The result of 32bit Unsigned Integer is right
Limit of Unsigned Value
Code: Select all
Structure llValue
StructureUnion
l.l
q.q
EndStructureUnion
EndStructure
a.llValue
#MegaBytes = 1024 *1024
a\l = $FFFFFFFF
Debug a\q
Debug a\q / #MegaBytes
Returned value should be 64bit Unsigned Integer, not 32 bit. And i use x64 cuda.lib library.
It is my post on devtalk nvidia
https://devtalk.nvidia.com/default/topi ... 3/#5350253
Re: cuda.lib return 32bit integer
Posted: Sat Jul 20, 2019 8:09 pm
by mk-soft
It is often the case that out of compality a new function "_v2" is added to the old 32 bit version.
I think you can use the new function safely. Simply search for examples with google.
Re: cuda.lib return 32bit integer
Posted: Sat Jul 20, 2019 8:13 pm
by Etayson
mk-soft wrote:It is often the case that out of compality a new function "_v2" is added to the old 32 bit version.
I think you can use the new function safely. Simply search for examples with google.
I just wanted to make sure it was really a bug. And that Nvidia ignores him for some reason.
32bit restriction not only in this function, but also in many others.
That's why I wanted to make sure that it’s not just me or I’m doing something wrong.
And that answer i got on devtalk about cuMemAlloc function (the same bug of 32bit)
Re: cuda.lib return 32bit integer
Posted: Sat Apr 30, 2022 3:41 pm
by pdwyer
I'm replying to this thread for a slightly different reason.
I'm using 11.6
Import "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.6\lib\x64\cuda.lib"
and I don't have the problem you are having but I have a problem with the string returned for the name. I've tried converting between ascii,utf8,unicode in different ways but I get a garbled string.
Code: Select all
Found 1 Cuda device.
Cuda device[0]:噎䑉䅉䜠䙥牯散䜠塔ㄠ㔶0
cuDeviceTotalMem Signed:0Mb
cuDeviceTotalMem Unsigned:4095Mb
cuDeviceTotalMem_v2:4095Mb
I would really like to use cuda or opencl in my code as I have a processing job I'd like to run with GPU so I'd be happy to collaborate on anything others are doing.
Anyway, I'll look around the forums and the docs that came with the toolkit to see what I can work out.
Re: cuda.lib return 32bit integer
Posted: Sat Apr 30, 2022 4:19 pm
by pdwyer
Okay, found a way through with
Code: Select all
PrintN("Cuda device["+Str(CudaDevice)+"]:"+ PeekS(@namedev,128,#PB_Ascii) )
Looks simple in hindsight but went off course with ascii() and other things. passing the address directly to peeks did the trick.
1 problem down, 1,000,000 to go