Monday, March 29, 2021

Limit CPU/Memory When using Docker

After having trouble with the Singularity Pull command on a computing cluster, I decided it might be easier to download the image via Docker to my home machine and upload it from there. I tried it, but Docker turned out to be such a huge resource hog that it rendered my computer unusable. Okay, the thing to do is to limit the resources Docker is allowed; but a quick search seemed to indicate that, while plenty of people had the problem, the only thing to do was to not use virtual machines. Now that is great advice and I wholeheartedly endorse it; but sometimes it's inevitable. Eventually I got to an obscure SuperUser post that had an answer with zero upvotes that pointed to a blog post that explained what to do:

Summary: Limit the CPU's and memory available to WSL2 (Docker's underlying mechanism) via a config file. I'll want to remove those limitations pretty quickly as I use WSL pretty heavily, but until I get these few tasks completed at least this will allow me to keep using my machine.

Thursday, February 25, 2021

Including config.h in every file in Visual Studio

Rather than explicitly including a header file in every source file, I like to use gcc's -include flag to add a config.h file, a file holding global configuration options that every source file may or may not be using. For a long time I didn't think that Visual Studio had a similar option, but I finally dug it out here:

The flag is /FI and you can set it in Visual Studio by right-clicking the project, selecting Properties, then C/C++, Advanced, and setting the "Forced Include File" property. Convenient!