Using the latest preview of slicer (5.7.0 revision 32834 built 2024-04-28) on a Windows system, I would like to try the new extension on a offline, hospital computer with limited space and writing rights but with good GPU. I’m trying to make a portable version so I can run slicer from a hard-disk, without internet access on the secondary machine and with limited disk writing rights due to admin.
While following this thread for clarity adn I would like to share how to correctly make a portable version and also request support in some passages, to see if i’m doing something wrong.
1 - I get that now the Slicer.ini file needs now to be put in x:\myfolder\Slicer 4.13.0-2021-01-05/slicer.org/Slicer.ini
to make slicer effectively detect the new .ini file and change the absolute paths to a relative reference to the main app directory.
I can’t manage to change the DICOM database default main folder for a relative position (I tried under general from the the “customize slicer” settings menu and it does not work). The other default folders (temp, cache, extensions and scene) change immediately in the .ini file when you update the “customize slicer” settings from the GUI.
2 - I then proceed to install the Monai Auto3dseg extension from the store, and that would also automatically install the Pytorch extension (right now the home directory is still managable, around 1 GB of disk space). When using the auto3dseg for the first time, the extension would then automatically download the required dependencies, or you can force install it from advaced mode if you don’t have dicom data.
Even though I have the pytorch extension correctly installed, the monai Auto3dseg would install pytorch and monai dependencies for a total of more than 7gb. I would like to know if this behaviour is correct, or if there’s a way to make a lighter version
3 - Monai auto3dseg downloads the pretrained models for inference in a separate cache folder that can be opened via the GUI with the button “opens models cache folder”. That folder in my computer is located in:
“C:\Users<MYNAME>.MONAIAuto3DSeg\models”
that is outside the app home directory. Thus I can’t export the model weights to an offline computer, without having the rights to write in a secondary folder on the offline machine. Is it possibile to change the model cache folder to make slicer with this extension completely portable?
It is actually a relative path if you place it within the Slicer folder. You can see that by inspecting the Slicer.ini file, you’ll see something like this:
What may confuse you is that by default you link DICOM files, so Slicer will not manage the DICOM files (Slicer will not delete the files when you delete them in the browser, they are expected to remain at the same location if Slicer is moved to a different location, etc.). If you want to Slicer to manage the DICOM files then click the small down-arrow button on the Import DICOM files button and check Copy imported files to DICOM database checkbox - or set this in the Slicer.ini file:
[DICOM]
ImportDirectoryMode=1
Pytorch Slicer extension just responsible for downloading and configuring Pytorch Python package.
Pytorch Python packageis about 5GB, largest part (3.5GB) is for CUDA support. ITK is about 0.7GB. The rest of the packages are small. If you have already installed the packages then they won’t be downloaded and installed again (unless you force).
I don’t think you can easily reduce this, but if you have time then you could search on the web if anybody was able to significantly cut down on the size of pytorch. While I agree that it would be nice to reduce the package size, memory is so cheap and fast (you can get a 32GB fast USB3 memory stick for $10) and Slicer can run directly from the stick, it should not be major issue.
Yes, sure, it is really easy to change this. All you need to do is to change this single line:
to something like this:
# User can create a .MONAIAuto3DSeg folder within the Slicer settings folder
# (same folder as Slicer.ini file) to make the downloaded model files portable with the application.
# If the folder does not exist (this is the default) then the models are cached in the user profile folder,
# so that not just Slicer but other tools can find and use it.
portableFileCachePath =
pathlib.Path(slicer.app.slicerUserSettingsFilePath).parent.joinpath(".MONAIAuto3DSeg")
self.fileCachePath = portableFileCachePath if portableFileCachePath.exists() else pathlib.Path.home().joinpath(".MONAIAuto3DSeg")
Please test and send a pull request if works well for you.