Reduce Video Memory Size

0 views
Skip to first unread message
Message has been deleted

Karren Katon

unread,
Jul 17, 2024, 6:43:03 AM7/17/24
to patatasi

I'm creating datset of windowed data for deep learning. I generated the data as numpy arrays 4 arrays with shape (141038, 360) and 1 array for labels of shape (141038, ). I saved the arrays in npz file but the file size is too big 1.5 GB. I'm new to python and programming so don't have idea how big should the file size be. However I converted the arrays to Pandas dataframes and Memory usage was in the same range. The Problem that I have 6 files with 9 GB and probably another dataset with overlapping which is 7 times larger so it would be 63 GB possibly.

reduce video memory size


Descargar Zip https://jinyurl.com/2yPkjs



I tried to change datatypes and it reduced the size slightly. (3 arrays (f8), 1 (int8), 1 (uint8)) is there other datatypes which could reduce the size more? for 0/1 values is there another datatype more efficient than (uint)?

Doesn't matter, only matters is the shape and data types. Numpy arrays are not compressed. If you compare it with images - that'd be wrong, analogy like "a black image has less size because of uniformity so zero padded arrays should consume less space" - is irrelevant (images are usually lossy compressed JPEG).

Which is a little better, but it still seems excessive for such a simple program. Are there any tricks to make a C# process a bit leaner? I'm writing a program that's designed to run in the background most of the time. I'm already doing any user interface stuff in a separate Application Domain which means the user interface stuff can be safely unloaded, but taking up 10 MB when it's just sitting in the background seems excessive.

P.S. As to why I would care --- (Power)users tend to worry about these things. Even if it has nearly no effect on performance, semi-tech-savvy users (my target audience) tend to go into hissy fits about background application memory usage. Even I freak when I see Adobe Updater taking 11 MB of memory and feel soothed by the calming touch of Foobar2000, which can take under 6 MB even when playing. I know in modern operating systems, this stuff really doesn't matter that much technically, but that doesn't mean it doesn't have an affect on perception.

.NET applications will have a bigger footprint compared to native applications due to the fact that they both have to load the runtime and the application in the process. If you want something really tidy, .NET may not be the best option.

However, keep in mind that if you application is mostly sleeping, the necessary memory pages will be swapped out of memory and thus not really be that much of a burden on the system at large most of the time.

I will not say that you should ignore the memory footprint of your application -- obviously, smaller and more efficient does tend to be desirable. However, you should consider what your actual needs are.

If you are writing a standard Windows Forms and WPF client applications which is destined to run on an individual's PC, and is likely to be the primary application in which the user operates, you can get away with being more lackadaisical about memory allocation. (So long as it all gets deallocated.)

However, to address some folks here who say not to worry about it: If you're writing a Windows Forms application which will be running in a terminal services environment, on a shared server possibly utilized by 10, 20 or more users, then yes, you absolutely must consider memory usage. And you will need to be vigilant. The best way to address this is with good data structure design and by following best practices regarding when and what you allocate.

One thing you need to consider in this case is the memory cost of the CLR. The CLR is loaded for every .Net process and hence factors into the memory considerations. For such a simple / small program the cost of the CLR is going to dominate your memory footprint.

This How To shows you how to use the CLR Profiler tool to investigate your application's memory allocation profile. You can use CLR Profiler to identify code that causes memory problems, such as memory leaks and excessive or inefficient garbage collection.

An often seen example: Taking a Datareader, loading the contents into a DataTable just to write it into an XML file. You can easily run into an OutOfMemoryException. OTOH, you could use an XmlTextWriter and scroll through the Datareader, emitting XmlNodes as you scroll through the database cursor.That way, you only have the current database record and its XML output in memory. Which will never (or is unlikely to) get a higher garbage collection generation and thus can be reused.

The same applies to getting a list of some instances, doing some stuff (that spawns of thousands of new instances, which might stay referenced somewhere), and even though you don't need them afterwards, you still reference everything until after the foreach.Explicitly null-ing your input list and your temporary by-products means, this memory can be reused even before you exit your loop.

C# has an excellent feature called iterators. They allow you to stream objects by scrolling through your input and only keep the current instance until you get the next one. Even by using LINQ, you still don't need to keep all of it around just because you wanted it to be filtered.

If you are using a COM component that returns a lot of data(say large 2xN arrays of doubles) and only a small fractionis needed then one can write a wrapper COM component thathides the memory from .NET and returning only the data thatis needed.

I have found that using the SetProcessWorkingSetSize or EmptyWorkingSet APIs to force memory pages to disk periodically in a long running process can result in all available physical memory on a machine to effectively disappear until the machine is rebooted. We had a .NET DLL loaded into a native process which would use the EmptyWorkingSet API (an alternative to using SetProcessWorkingSetSize) to reduce the working set after performing a memory intensive task. I found that after anywhere between 1 day to a week a machine would show 99% physical memory usage in Task Manager while no processes were shown to be using any significant memory usage. Soon after the machine would become unresponsive, requiring a hard reboot. Said machines were over 2 dozen Windows Server 2008 R2 and 2012 R2 servers running on both physical and virtual hardware.

Perhaps having the .NET code loaded into a native process had something to do with it, but use EmptyWorkingSet (or SetProcessWorkingSetSize) at your own risk. Perhaps only use it once after initial launch of your application. I have decided to disable the code and let the Garbage Collector manage memory usage on its own.

To much of my surprise, while the total size of the files in disk is about 21 mb, when loaded into memory the process takes 120 - 180 mb of memory! (the whole python application doesn't load any other data into memory).

If you look at the Python implementation of dictionary (which is a relatively straight-forward implementation of a hash table), as well as the implementation of the built-in string and integer data types, for example here (specifically object.h, intobject.h, stringobject.h and dictobject.h, as well as the corresponding *.c files in ../Objects), you can calculate with some accuracy the expected space requirements:

Of course many people will now point out that my use of ps to measure the memory footprint is inaccurate and my assumptions about the size of pointer types and integers on 32-bit and 64-bit systems may be wrong on many specific systems. Granted.

There's no way to reduce the memory used by the dicts, but there are other ways to approach the problem. If you're willing to trade some speed for memory, you should consider storing and querying the strings from an SQLite file instead of loading everything to dictionaries in memory.

Numpy ( ) allocates data structures using native C structures. Most of its data structures presume you're storing a single datatype, so this isn't for all situations (you might need to store null, etc.), but it can be very, very, very fast and is about as compact as you could ask for. Lots of science gets done with it (see also: SciPy).

You could just declare a 'page' of data (however big you want) as an array, read in the data, store it in the array, zip it, then read in some more data, until you have all the data in memory you want.

You can replace dict with blist.sorteddict for log(n) access without the memory overhead. It is convenient because it behaves exactly like a dictionary, ie it implements all its methods, so you only have to change the initial type.

Moreover, is it possible to reduce RAM usage by manually deallocating an array a by calling resize!(a,0) and sizehint!(a,0), before it goes out of scope? Will Julia free the memory immediately following these two commands?

Moreover, is it possible to reduce RAM usage by manually deallocating an array a by calling resize!(a,0) and sizehint!(a,0) , before it goes out of scope? Will Julia free the memory immediately following these two commands?

Reducing the memory consumption of Rasa models and controlling CPU core usage during training or startup can be essential for efficient conversational agent development. Here are some insights based on your questions:

Remember that optimizing memory and CPU usage is a delicate balance between model size, training time, and system performance. Experimentation and testing with different configurations are key to finding the right setup for your conversational agents.

I am relatively new to using Code Composer. Currently I am using it to program a MSP430 and am running into issues with memory size. Lately, I have over exceeded the bounds for code size; I am alerted that the .bss size is now too large for my particular chip. I am curious, how can I find out the size of .bss after I have reduced my code? What sorts of changes to my code affects .bss? Can I just simply remove lines of code to reduce it?

The linker option --map_file=file (or -m=file for short) creates a file which shows, among other things, the size of your .bss section. The MSP430 compiler book , in a section titled Specifying Where to Allocate Sections in Memory, says that the .bss section contains global and static data variables. So, the only way to reduce the size of this section is to reduce the number and/or size of your global and static data variables.

d3342ee215
Reply all
Reply to author
Forward
0 new messages