bbfrederick/rapidtide

Matplotlib runtime from docker image run

Closed this issue · 3 comments

Matplotlib created a temporary config/cache directory at /tmp/matplotlib-mp4xiril because the default path (/home/rapidtide/.config/matplotlib) is not a writable directory; it is highly recommended to set the MPLCONFIGDIR environment variable to a writable directory, in particular to speed up the import of Matplotlib and to better support multiprocessing.

Although this is not an error message, it seems to stop rapidtide completely.

On macOS using a bash wrapper script, I am calling:

docker run
--init
--name ${session}
--mount type=bind,source=$SOURCE_FOLDER,destination=${SOURCE_FOLDER}
fredericklab/rapidtide:latest
rapidtide
$TARGET_FOLDER/${session}_rest.gin.nii.gz $TARGET_FOLDER/TSA/rt --verbose --filterband lfo --searchrange -5 5 --regressor=$TARGET_FOLDER/vs_tc.txt --corrmask=$TARGET_FOLDER/${session}_rest.ro.mask.nii

I am running this in a loop through subjects and sessions (from a list of subjects and sessions passed into the script), and need to call with --init in case I need to use ctl+C to stop in the terminal (otherwise containers die and cannot be removed without restarting docker).
I am also removing the specific session containers after each run, since within a loop, a new container needs to be made, so the first run works quickly even with the matplotlib message, but the next session, etc. basically stops running, and I tried using --verbose to see if there are any indications that the process is running out of time or anything, but I don't get any messages other than the matplotlib one.

Any suggestions or help would be greatly appreciated!

Weird - I haven't run into this before, but then again, I haven't tried to rerun the docker containers...

To be clear - is the cache file at /tmp/matplotlib-mp4xiril on your Mac? What are the permissions on that file? It may be that a sticky bit is set and the next run of the container isn't allowed to mess with it.

I would try the following (in no particular order).

  1. In the script that runs your container, and then removes the container when it finishes, ALSO remove /tmp/matplotlib-mp4xiril, so that the new container can write a new version of that file each time it runs. The matplotlib initialization should be fast, so this shouldn't be a big deal. Unclear to me why it's even doing it, since if you aren't debugging, matplotlib shouldn't even be invoked by rapidtide, but who knows. It may be due to some module that rapidtide loads.
  2. Add "--mount type=bind,source=${HOME},destination=/home/rapidtide" to your docker command line, so that /home/rapidtide/.config/matplotlib is mapped to your ${HOME}/.config/matplotlib, which will be writeable, and will persist between runs so you don't have to reinitialize.
  3. Add "--env MPLCONFIGDIR=${TARGET_FOLDER}/.config/matplotlib" to your docker command line, so that it will write and read the configuration files to ${TARGET_FOLDER} (I'm assuming SOURCE_FOLDER and TARGET_FOLDER are the same, right?).

Any of those might work. Actually, I'd try number 2 first - that seems the cleanest.

Hi Blaise,

Thanks so much! Trying number 2 worked for me! :) Now seems to be running smoothly.

Ok, I'll close this.