I’m new to CUDA so this may be quite basic questions.
I would like to use the Runtime API for my programming. However, I cannot find a way to determine the current amount of memory available on the GPU. It seems that the Driver API has the function which I’m looking for called cuMemGetInfo(); - but since you are only able to use either the Driver or Runtime API in a program I am unable to use this function at all (or at least I think that is the case).
So is there a way of getting the unused memory info from the card using the Runtime API?
How is the problem of available gpu memory usually addressed? (is it just assumed that you have enough memory and after allocation you deal with the allocation error afterwards?)
That is rather good news. But to the original poster, you can use cuMemGetInfo() with the runtime API. I have a user space runtime API based memory manager I use which starts by allocating all available memory (using cudaMalloc) from the results of cuMemGetInfo. At the risk of earning Tim’s wrath, it works fine. I think only about the only stuff that can’t be mixed with the runtime API is context migration.
Since I’ve got 2.3 installed I will try out the cuMemGetInfo approach and see how it goes. How would you go about modifying the makefile to allow the use of both API’s? It seems in the SDK makefiles have a flag set if they use the DriverAPI but if I set this the RunTime components through linking errors. (I’m using linux BTW)
############################################################
####################
#
# Build script for project
#
############################################################
####################
EXECUTABLE := test
# Cuda source files (compiled with cudacc)
CUFILES := test.cu
USEDRVAPI := 0
############################################################
####################
# Rules and targets
include ../../common/common.mk
If I don’t set that flag I’m getting this error message:
tmpxft_00000f12_00000000-10_temp.ii:(.text+0x7c9): undefined reference to `cuInit'
tmpxft_00000f12_00000000-10_temp.ii:(.text+0x7da): undefined reference to `cuCtxCreate'
tmpxft_00000f12_00000000-10_temp.ii:(.text+0x7ef): undefined reference to `cuMemGetInfo'
And if I put USEDRVAPI:= 1 I start getting these types of errors instead.
In the spirit of the “wrath of Tim” jibe above, I would throw away that horrible SDK build system and write my own makefile. Basically you need to link with both libcudart and libcuda. And that’s it. How you do that is up to you.
I’ll see your common.mk, and raise you a makefile where you had to run ‘make’, edit the makefile to change some compilation options, and then run ‘make’ again. It had some… issues with matching the precision of various variables between various bits of the code.