So I installed the GPU version of TensorFlow on a Windows 10 machine with a GeForce GTX 980
graphics card on it.
Admittedly, I know very little about graphics cards, but according to dxdiag it does have:
4060MB
of dedicated memory (VRAM) and;
8163MB
of shared memory
for a total of about 12224MB
.
What I noticed, though, is that this "shared" memory seems to be pretty much useless. When I start training a model, the VRAM will fill up and if the memory requirement exceeds these 4GB
, TensorFlow will crash with a "resource exhausted" error message.
I CAN, of course, prevent reaching that point by choosing the batch size suitably low, but I do wonder if there's a way to make use of these "extra" 8GB
of RAM, or if that's it and TensorFlow requires the memory to be dedicated.
In any case, no, there isn't anything that Tensorflow can use. Since GPUs don't use "shared graphics memory", the term "shared memory" in relation to GPUs is used for the on-chip cache memory of streaming multiprocessors (devblogs.nvidia.com/using-shared-memory-cuda-cc), which led to some confusion in my answer..
Yes. Because shared Memory is essentially RAM, if a GPU has to resort to using the System's RAM for its computations, it'll take a performance hit.
To limit TensorFlow to a specific set of GPUs, use the tf. config. set_visible_devices method. In some cases it is desirable for the process to only allocate a subset of the available memory, or to only grow the memory usage as is needed by the process.
Why Is Shared Gpu Memory Not Being Used? Until you are able to obtain enough VRAM, the operating system (OS) will not include shared GPU memory. Games and apps are run over system RAM because integrated GPUs do not provide dedicated GPU memory.
Shared memory is an area of the main system RAM reserved for graphics. References:
https://en.wikipedia.org/wiki/Shared_graphics_memory
https://www.makeuseof.com/tag/can-shared-graphics-finally-compete-with-a-dedicated-graphics-card/
https://youtube.com/watch?v=E5WyJY1zwcQ
This type of memory is what integrated graphics eg Intel HD series typically use.
This is not on your NVIDIA GPU, and CUDA can't use it. Tensorflow can't use it when running on GPU because CUDA can't use it, and also when running on CPU because it's reserved for graphics.
Even if CUDA could use it somehow. It won't be useful because system RAM bandwidth is around 10x less than GPU memory bandwidth, and you have to somehow get the data to and from the GPU over the slow (and high latency) PCIE bus.
Bandwidth numbers for reference : GeForce GTX 980: 224 GB/s DDR4 on desktop motherboard: approx 25GB/s PCIe 16x: 16GB/s
This doesn't take into account latency. In practice, running a GPU compute task on data which is too big to fit in GPU memory and has to be transferred over PCIe every time it is accessed is so slow for most types of compute that doing the same calculation on CPU would be much faster.
Why do you see that kind of memory being allocated when you have a NVIDIA card in your machine? Good question. I can think of a couple of possibilities:
(a) You have both NVIDIA and Intel graphics drivers active (eg as happens when running different displays on both). Uninstaller the Intel drivers and/or disable Intel HD graphics in the BIOS and shared memory will disappear.
(b) NVIDIA is using it. This may be eg extra texture memory, etc. It could also not be real memory but just a memory mapped area that corresponds to GPU memory. Look in the advanced settings of the NVIDIA driver for a setting that controls this.
In any case, no, there isn't anything that Tensorflow can use.
CUDA can make use of the RAM, as well. In CUDA shared memory between VRAM and RAM is called unified memory. However, TensorFlow does not allow it due to performance reasons.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With