It is currently Mon Sep 23, 2019 5:02 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: cuda.lib return 32bit integer
PostPosted: Sat Jul 20, 2019 3:01 pm 
Offline
User
User

Joined: Sun Jun 05, 2016 5:01 pm
Posts: 48
Hi, sorry for my bad english :oops:
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:
   
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 ???


Top
 Profile  
Reply with quote  
 Post subject: Re: cuda.lib return 32bit integer
PostPosted: Sat Jul 20, 2019 7:06 pm 
Offline
Addict
Addict
User avatar

Joined: Fri May 12, 2006 6:51 pm
Posts: 1915
Location: Germany
32 bit Integer Signed or Unsigned?

Not testet
Code:
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

_________________
My Projects ThreadToGUI / OOP-BaseClass / OOP-BaseClassDispatch / EventDesigner V3
PB v3.30 / v5.70 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace


Top
 Profile  
Reply with quote  
 Post subject: Re: cuda.lib return 32bit integer
PostPosted: Sat Jul 20, 2019 7:31 pm 
Offline
User
User

Joined: Sun Jun 05, 2016 5:01 pm
Posts: 48
mk-soft wrote:
32 bit Integer Signed or Unsigned?

Not testet

Hi, thanks for answer
It is result of your code:
Code:
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..


Top
 Profile  
Reply with quote  
 Post subject: Re: cuda.lib return 32bit integer
PostPosted: Sat Jul 20, 2019 7:45 pm 
Offline
Addict
Addict
User avatar

Joined: Fri May 12, 2006 6:51 pm
Posts: 1915
Location: Germany
The result of 32bit Unsigned Integer is right

Limit of Unsigned Value
Code:
Structure llValue
  StructureUnion
    l.l
    q.q
  EndStructureUnion
EndStructure

a.llValue

#MegaBytes = 1024 *1024
a\l = $FFFFFFFF

Debug a\q
Debug a\q / #MegaBytes

_________________
My Projects ThreadToGUI / OOP-BaseClass / OOP-BaseClassDispatch / EventDesigner V3
PB v3.30 / v5.70 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace


Top
 Profile  
Reply with quote  
 Post subject: Re: cuda.lib return 32bit integer
PostPosted: Sat Jul 20, 2019 7:52 pm 
Offline
User
User

Joined: Sun Jun 05, 2016 5:01 pm
Posts: 48
mk-soft wrote:
The result of 32bit Unsigned Integer is right

Limit of Unsigned Value
Code:
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


Last edited by Etayson on Sat Jul 20, 2019 8:10 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: cuda.lib return 32bit integer
PostPosted: Sat Jul 20, 2019 8:09 pm 
Offline
Addict
Addict
User avatar

Joined: Fri May 12, 2006 6:51 pm
Posts: 1915
Location: Germany
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.

_________________
My Projects ThreadToGUI / OOP-BaseClass / OOP-BaseClassDispatch / EventDesigner V3
PB v3.30 / v5.70 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace


Top
 Profile  
Reply with quote  
 Post subject: Re: cuda.lib return 32bit integer
PostPosted: Sat Jul 20, 2019 8:13 pm 
Offline
User
User

Joined: Sun Jun 05, 2016 5:01 pm
Posts: 48
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)
Quote:
cuMemAlloc_v2 doesn't appear to be a documented part of the CUDA driver API:

https://docs.nvidia.com/cuda/cuda-drive ... _CUDA__MEM

I'm not aware of any 32-bit limitation on cuMemAlloc:

https://docs.nvidia.com/cuda/cuda-drive ... c31e8aa467

size_t is 64-bits on a 64-bit platform.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye