Installer¶
The Biom3d installer is a self-contained package intended to simplify deployment, it is aimed to Biologist so it is very simple to use. It includes a full Python environment and automatically updates itself on first run to match the host system’s CUDA configuration.
There are currently two version of those :
Windows 10/11 in
x86_64architecturemacOS on
arm64architecture (hasn’t be fully tested yet)
Linux hasn’t an installer as it is hard to make something universal and we consider Linux users able to do a classic installation.
Use :
Download it on a release
Unzip it
Execute the
.bat(Windows) or.app(MacOS)
Windows¶
It follow this structure :
Biom3d/
├── bin/
│ ├── Scripts/
│ │ ├── conda-unpack.exe
│ │ └── ...
│ ├── ...
│ ├── python.exe
│ ├── auto_update.py
│ ├── env.bat
│ └── ...
├── Biom3d.bat
└── Biom3d.ico
MacOS¶
It follow the MacOS application structure :
Biom3d.app/
└── Contents/
├── Resources/
│ └── Biom3d.icns
├── MacOS/
│ ├── bin/
│ │ ├── bin/
│ │ │ ├── conda-unpack
│ │ │ ├── python3.11
│ │ │ └── ...
│ │ └── ...
│ └── Biom3d.sh
└── Info.plist
Logic¶
This section details the logic behind the executables and packaging scripts used to build and launch the Biom3d installer.
Launcher scripts¶
First are the “executables”, Biom3d.bat (Windows) and Biom3d.sh (MacOS, and potentially Linux).
They are very simple, here is their algorithm :
Get variables from
bin\env.bat(Windows) orbin/env.sh(macOS/Linux)If it is first launch (given by
FIRST_LAUNCHvariable):Execute
conda-unpack, it will make the virtual environment usable.Execute
bin\auto_update.py(described here).For the moment, macOS build doesn’t use
auto_update.pyas Mac use Metal GPU drivers instead of CUDA and so the script is irrelevant there.
Execute
biom3d.guiwith the includedpythonto launch Biom3d.
Packaging¶
Then are the packing script, pack.bat and pack.sh.
Detect system architecure : We retrive the building machine processor architecture, on Windows it was hard to obtain
x86_64instead ofAMD64that was unclear for non programmer so we decided that it should be passed as an argument (with a default value ofx86_64).Create the conda environment : We create a
condaenvironment withtkinterandpython 3.11(it has the most compatibilities with Biom3d dependencies). We are assuming two point :condais installed and inPATHIf there already is an environment with the same name, it has the same purpose and is reused.
Install dependencies :
We activate our environment.
Install
conda-pack, it will allow us to export our environment.We install
pip 23.1withcondaas it is a stable version ofpipand that if not reinstalled we will have aconda/pipconflict at packing step and it will crash.We then install all that is necessary for omero :
zeroc-ica 3.6.5withconda.Then the others
omero-pydependencies withpipto finally installomero-py. On Windowsomero-pywould try to recompilezeroc-iceso we use--no-depsezomerowithpipand--no-deps. We use--no-depsasezomerowould reinstallnumpyand break other packages (they’re should be a incompatibility warning withnumpy 2.xandezomerobut we tested withnumpy 2.2.6and it worked fine).
Install Biom3d : With a simple
pip install .with source code. The script are made to be used in the CI/CD so we assume we are in the repository.Creating the folder We create the folder with the folder structure describe earlier.
Packing
Then we pack in the
bin/subfolder with the commandconda pack --format=no-archive -o %DIR%\bin.Copy the
auto_update.pyandenv.batorenv.shinbin/.We copy the
logo.icoandBiom3d.batorlogo.icnsandBiom3d.sh.
Zipping We zip it with the following name convention :
Biom3d_$OS_$ARCHITECURE.zip.
Note that the hardest part of this scipt is dependencies for two reasons :
You must find the correct versions so all is compatible (hence
python 3.11)conda-packdoesn’t like whenpipandcondatouch the same files, so you must find an installation order that avoid those case. The current installation order has been empirically tested to respect that.
Auto updating¶
Here is the auto_update.py script :
dockerfile` here :
1import subprocess
2import re
3import sys
4
5def get_cuda_version_from_nvcc():
6 output = subprocess.check_output(["nvcc", "--version"], stderr=subprocess.STDOUT, text=True)
7 # Exemple de sortie : "Cuda compilation tools, release 11.8, V11.8.89"
8 match = re.search(r"release (\d+)\.(\d+)", output)
9 if match:
10 major = match.group(1)
11 return int(major)
12
13def get_cuda_version_from_nvidia_smi():
14 try:
15 output = subprocess.check_output(["nvidia-smi"], stderr=subprocess.STDOUT, text=True)
16 # Cherche une ligne comme : "CUDA Version: 12.2"
17 match = re.search(r"CUDA Version: (\d+)\.(\d+)", output)
18 if match:
19 major = match.group(1)
20 return int(major)
21 except (subprocess.CalledProcessError, FileNotFoundError):
22 return None
23
24def detect_cuda_major_version():
25 try :
26 version = get_cuda_version_from_nvcc()
27 except :
28 try :
29 version = get_cuda_version_from_nvidia_smi()
30 except :
31 version = None
32
33 if version is not None :
34 # Install 11.8 or 12.8 (we use the x.8 retrocompatibility)
35 subprocess.check_call([sys.executable, "-m", "pip", "install", "torch","--index-url","https://download.pytorch.org/whl/cu"+str(version)+"8","--force-reinstall","--no-warn-script-location","--no-deps"]) #Remove no-deps once typing-extnsions doesn't bug
36
37if __name__ == "__main__":
38 detect_cuda_major_version()
It detect the major version of CUDA with either nvcc or nvidia-smi and install the x.8 version that should be retrocompatible with lower x.y version. If no CUDA is found, it keep torch cpu. It can be easily augmented to other drivers if Biom3d implement them.
Other¶
The executable script actually just launch the GUI meaning that all limitation of the GUI are kept, however it is possible to use the environment by using the python executable in bin/ (eg: bin/bin/python3.11 -m biom3d.pred ... on macOS).