From 6434c3f476ee8fb2395e91d0f54ea507ecb4df51 Mon Sep 17 00:00:00 2001 From: avanhilten Date: Tue, 25 Mar 2025 09:35:19 +0100 Subject: [PATCH 1/3] dockerfile --- Dockerfile | 43 +++++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/Dockerfile b/Dockerfile index 26084ec..aa45908 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,30 +1,29 @@ -# Step 1: Use the official TensorFlow 2.11 image as the base -FROM tensorflow/tensorflow:2.11.0 +# Use Miniconda as the base image +FROM continuumio/miniconda3 -# Step 2: Install system dependencies -RUN apt-get update && apt-get install -y \ - git \ - wget \ - && rm -rf /var/lib/apt/lists/* +# Set the working directory +WORKDIR /workspace -# Step 3: Upgrade pip to the latest version -RUN python3 -m pip install --upgrade pip +# Copy your pip requirements file into the container +COPY requirements_GenNet.txt . -# Step 4: Copy your requirements file into the container -COPY requirements_GenNet.txt /tmp/requirements_GenNet.txt +# Create the environment +RUN conda create -n env_GenNet python=3.10.12 -y -# Step 5: Install Python packages -RUN pip install --no-cache-dir -r /tmp/requirements_GenNet.txt +# Install pip packages +RUN /bin/bash -c "source activate env_GenNet && \ + pip install --upgrade pip && \ + pip install -r requirements_GenNet.txt" -# Step 6: Set the working directory -WORKDIR /app +# Copy your GenNet code into the image (optional) +COPY . /workspace -# Step 7: Copy your project files into the container -COPY . /app +# Create input/output folders (in case not mounted) +RUN mkdir -p /workspace/processed_data /workspace/results -# Step 8: Set environment variables (optional) -ENV RESULT_PATH="/app/results" -ENV DATA_PATH="/app/examples" +# Activate environment for future RUN/CMD +SHELL ["conda", "run", "-n", "env_GenNet", "/bin/bash", "-c"] + +ENTRYPOINT ["conda", "run", "-n", "env_GenNet"] +CMD ["/bin/bash"] -# Step 9: Define the entrypoint to simplify CLI usage -ENTRYPOINT ["python", "GenNet.py"] From 58318da7b67115b1255594d8ae7aa391437ee678 Mon Sep 17 00:00:00 2001 From: avanhilten Date: Wed, 26 Mar 2025 09:22:49 +0100 Subject: [PATCH 2/3] docker version 1.0 --- .dockerignore | 16 ---------------- Dockerfile | 15 ++++----------- 2 files changed, 4 insertions(+), 27 deletions(-) diff --git a/.dockerignore b/.dockerignore index 9ca51fe..794460a 100644 --- a/.dockerignore +++ b/.dockerignore @@ -11,30 +11,14 @@ conda_env/ build/ dist/ *.egg-info -# Ignore version control system folders -.git/ -.gitignore # Ignore OS-specific hidden files .DS_Store Thumbs.db -# If you have a big data directory or logs, ignore those too -data/ -logs/ - # jupyter notebooks .ipynb_checkpoints __pycache__/ -# processed data -processed_data/* -!processed_data/.gitkeep -# results -results/* -!results/.gitkeep # idea .idea/ .idea/* .swp *.swp -.log -*.log -examples/A_to_Z/processed_data/* \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index aa45908..c1da5bf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,7 @@ -# Use Miniconda as the base image FROM continuumio/miniconda3 -# Set the working directory WORKDIR /workspace -# Copy your pip requirements file into the container COPY requirements_GenNet.txt . # Create the environment @@ -15,15 +12,11 @@ RUN /bin/bash -c "source activate env_GenNet && \ pip install --upgrade pip && \ pip install -r requirements_GenNet.txt" -# Copy your GenNet code into the image (optional) COPY . /workspace -# Create input/output folders (in case not mounted) -RUN mkdir -p /workspace/processed_data /workspace/results +# RUN mkdir -p /workspace/processed_data /workspace/results -# Activate environment for future RUN/CMD -SHELL ["conda", "run", "-n", "env_GenNet", "/bin/bash", "-c"] - -ENTRYPOINT ["conda", "run", "-n", "env_GenNet"] -CMD ["/bin/bash"] +RUN echo "conda activate env_GenNet" >> ~/.bashrc +# Set CMD to launch bash with environment activated +CMD ["/bin/bash", "-c", "source activate env_GenNet && exec bash"] From e55d7ca359408f92a84f324e189949ef1a60f434 Mon Sep 17 00:00:00 2001 From: Arno van Hilten Date: Wed, 26 Mar 2025 11:08:38 +0100 Subject: [PATCH 3/3] Update README.md with docker --- README.md | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 59 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0182fe8..e24abee 100644 --- a/README.md +++ b/README.md @@ -23,12 +23,18 @@ The Gennet framework is based on tensorflow, click [here](GenNet_utils/LocallyDi ## 2. Getting started +GenNet can be used in two ways: +- Manual installation: clone the repository and set up the virtual environment. +- Use the docker image. + +### 1. Manual installation + Follow the instructions below to get started. > [!TIP] > Check the [A to Z Colab tutorial](https://colab.research.google.com/github/ArnovanHilten/GenNet/blob/master/examples/A_to_Z/GenNet_A_to_Z.ipynb) for an overview on how to use GenNet with your own data! -### Prerequisites: +#### Prerequisites: - GenNet is optimized to use Tensorflow on CPU using multiple-cores as sparse matrix multiplcations does not benefit from GPU acceleration. We are currently restricting testing and recommending using: @@ -38,13 +44,13 @@ Follow the instructions below to get started. -### Clone the repository +#### Clone the repository Open terminal. Navigate to the a place where you want to store the project. Clone the repository: ``` git clone https://github.com/arnovanhilten/GenNet ``` -### Install the virtual envionment +#### Install the virtual envionment **Create a virtual environment** ``` @@ -73,6 +79,56 @@ python GenNet.py train -path ./examples/example_classification/ -ID 1 Check the [wiki](https://github.com/ArnovanHilten/GenNet/wiki) for more info! + +### 2. Docker + +Make sure that you have [docker](https://www.docker.com/) installed: + +#### Pull the Docker image + ```bash + docker pull avanhilten/gennet-image:latest +``` + #### Run the docker + +In Linux/macOS/WSL: + +```bash +docker run --rm -it \ + -v $(pwd)/examples:/workspace/examples \ + -v $(pwd)/processed_data:/workspace/processed_data \ + -v $(pwd)/results:/workspace/results \ avanhilten/gennet-image \ +``` +Or in powershell: + ``` +powershell docker run --rm -it -v C:\Users\YOURNAME\GenNet\examples:/workspace/examples ` + -v C:\Users\YOURNAME\GenNet\processed_data:/workspace/processed_data ` + -v C:\Users\YOURNAME\GenNet\results:/workspace/results ` + avanhilten/gennet-image + ``` +> Replace `YOURNAME` with your actual Windows username and adjust the paths if needed. + +Then all GenNet commands can be utilized, such as: + ``` +python GenNet.py train -path /workspace/examples/example_classification -ID 1 -out results +``` + +> [!CAUTION] +> Output argument required +> Always include the +> `-out /workspace/results` argument when running in Docker to ensure results are written to the mounted `results/` folder on your machine. + +#### Running on your own data + +You can mount your own input/output directories: +```bash +docker run --rm -it \ + -v /path/to/my_data:/workspace/my_data \ + -v /path/to/output:/workspace/output \ + avanhilten/gennet-image \ + +python GenNet.py train -path /workspace/my_data -ID 7 -out /workspace/output + ``` + ## 3. GenNet command line.