============================
User Manual (Windows System)
============================
Step-by-Step installation in Windows
====================================
Welcome to the user manual for setting up and using Docker on a Windows system. This guide will provide comprehensive instructions to help you install and configure Docker Desktop on Windows, activate virtualization in BIOS, install WSL (Windows Subsystem for Linux), import Docker images, mount user data, and run Docker containers. Additionally, it includes pointers and tips to address common questions and issues that users may encounter.
Activate Virtualization in BIOS
===============================
To enable virtualization, you'll need to access the BIOS settings during startup. Here’s how:
1. Power on your computer.
2. Keep an eye on the initial boot screen.
3. When you see the screen, press the ``F2 / F10 / F12 / Esc / Delete / Enter`` key to enter the BIOS settings.
.. figure:: images/B1.jpg
:width: 900
:align: center
Screen when we boot up the machine. Press ``F2 / F10 / F12 / Esc / Delete / Enter``
Once inside the BIOS settings:
4. Navigate through the BIOS menus using the arrow keys. Look for the section typically labeled ``Advanced``, ``Advanced Settings`` or ``CPU Configuration``.
or
4. Alternatively, some BIOS versions allow you to search for settings. Look for a search bar or a similar feature where you can type ``virtualization`` or ``VT-x`` (for Intel processors) / ``AMD-V`` (for AMD processors).
.. figure:: images/B3.jpg
:width: 900
:align: center
BIOS settings screen.
Once you locate the virtualization options within these sections, you can proceed to enable them. This step is crucial for utilizing virtualization features such as running virtual machines or other virtualization-based applications on your computer. After making the necessary changes, remember to save your settings and exit the BIOS.
5. Change the setting from ``Disabled`` to ``Enabled`` using the appropriate key (usually ``Enter`` or the ``+`` key).
6. Save changes and exit BIOS
.. figure:: images/B2.jpg
:width: 900
:align: center
Turn on Virtualization.
Your computer will restart with virtualization support enabled.
Install WSL
===========
Here are the simplified instructions for installing Windows Subsystem for Linux (WSL) and verifying its installation:
**Installing Windows Subsystem for Linux (WSL)**
1. **Open PowerShell as Administrator**
2. **Install WSL:**
Run the following command to install WSL: ``wsl --install``.
Follow any prompts or confirmations that appear during the installation process.
3. **Wait for Installation to Complete:**
Allow the installation process to finish. This may take some time depending on your internet speed.
.. figure:: images/W3.png
:width: 1200
:align: center
Install Windows Subsystem for Linux (WSL)
4. **Check WSL Version:**
Run the following command to check the installed WSL versions and their respective distributions: ``wsl -l -v``
This command lists all installed Linux distributions and their associated WSL versions (`1` or `2`).
.. figure:: images/W4.png
:width: 1200
:align: center
Check if WSL is properly installed
Following these steps ensures that you install Windows Subsystem for Linux (WSL) and confirm its proper installation on your Windows system.
Install Docker Desktop in Windows
=================================
1. Download Docker Desktop from `Docker's official website `_ (https://www.docker.com/get-started/).
.. figure:: images/W5.png
:width: 1200
:align: center
Download Docker Desktop online
2. Once downloaded, locate the installer file (e.g., ``DockerDesktopInstaller.exe``) and double-click to launch it.
3. Follow the prompts provided by the Docker Desktop installer to complete the installation process. This may involve accepting terms and conditions and choosing installation preferences.
.. figure:: images/W6.png
:width: 1200
:align: center
Docker Desktop Installer
.. figure:: images/W7.png
:width: 1200
:align: center
Installing Docker Desktop
.. figure:: images/W8.png
:width: 1200
:align: center
Finish installing Docker Desktop
4. After installation, a Docker Desktop shortcut will appear on your desktop. The necessary components to run Maxwell-TD Docker images include Docker Desktop itself, Windows PowerShell for running CLI commands, and a designated working folder containing Docker images and user data (e.g., geometry information).
.. figure:: images/W9.png
:width: 300
:align: center
All the data/folders/apps needed to run Maxwell-TD Docker image
5. Launch Docker Desktop by double-clicking the Docker Desktop shortcut on your desktop.
6. Upon first launch, Docker Desktop may prompt you to accept terms and conditions. Agree to proceed with using the application.
.. figure:: images/W10.png
:width: 1200
:align: center
Accept the terms and conditions
7. You can continue without logging into Docker Desktop if prompted, and optionally skip any survey presented during initial setup.
.. figure:: images/W11.png
:width: 1200
:align: center
Continue without logging in
.. figure:: images/W12.png
:width: 1200
:align: center
Skip Survey
Currently, the local repository in Docker Desktop is empty. To proceed, we must upload the compiled image for Maxwell-TD. This requires using the PowerShell console, as the GUI does not support managing local Docker images directly and defaults to searching online repositories for Docker images.
.. figure:: images/W13.png
:width: 1200
:align: center
Image local Repository
Import Docker Image
===================
Next, we need to mount the zipped Docker image onto the Windows system. Since this action cannot be performed using the Docker Desktop GUI, we'll need to use the console terminal instead.
In the designated working folder, you will find a zipped Docker image file and an "examples" folder containing user-defined data.
.. figure:: images/W14.png
:width: 1200
:align: center
Location of Maxwell-TD Docker Image (Zipped)
To load the Docker image, execute the command ``docker load --input ``. This process will take some time, and you can verify its completion by using ``docker images`` in the console.
.. figure:: images/W16.png
:width: 1200
:align: center
Load and check Docker Image
The loaded Docker image will also be visible both in Docker Desktop.
.. figure:: images/W17.png
:width: 1200
:align: center
Loaded Docker Image can be seen in Docker Desktop
Mounting User data and running Docker image
===========================================
Finally, we are ready to run the Docker image. You can use a PowerShell script with administrative privileges to execute the Docker image. We have prepared a script file named ``runDocker.ps1`` that can be executed in the console terminal.
To run the script and start the Docker image, follow these steps:
1. **Open PowerShell as Administrator**
2. **Navigate to Script Directory:**
Use the ``cd`` command to navigate to the directory where ``runDocker.ps1`` is located.
3. **Execute the Script:**
- Run the script by typing ``.\runDocker.ps1`` and press ``Enter``.
- The script will mount the folder containing user-defined data into the Docker Server environment.
.. note::
- When running the Docker image, any data saved onto the mounted filesystem will persist. However, other modifications, such as custom installations of packages, will be temporary and will disappear after you exit the Docker session.
- Treat the Docker image as a saved state of a customized environment.
.. figure:: images/W18.png
:width: 1200
:align: center
Use PowerShell Script to run Docker Image
Let's break down the lines in the PowerShell script to understand the necessary steps for running the Docker image. This will clarify what is needed for execution.
- **$imageName**:
This variable defines the name of the Docker image that you want to run. In this case, it is set to ``maxwell_td_image``. Users should not change this variable if they intend to run Maxwell-TD.
- **$containerName**:
This variable specifies the name of the container that will run the Docker image. You can run multiple containers from the same image concurrently, so each running instance needs a unique name. Users can customize this variable to suit their naming conventions.
- **$hostVolumePath**:
This variable holds the path to the working folder on the Windows system. This folder contains essential files such as geometry files for simulation models and scripts for setting simulation parameters. Users must update this path to point to their specific working folder.
- **$containerVolumePath**:
This variable defines the path within the Docker container (running on Linux environment) where the host volume (**$hostVolumePath**) will be mounted. In this script, it is set to ``/dgtd/model/``. It is recommended that users do not change this variable unless necessary, to ensure compatibility with the Docker image's expected mount point.
.. figure:: images/W20.png
:width: 1200
:align: center
User-defined parameters to change location of User data
Next, the script proceeds to execute several commands to display the paths and names. It also checks the CUDA version installed on the Windows device. Afterward, it runs the Docker command ``docker run --rm --gpus all -it --name ${containerName} -v ${hostVolumePath}:${containerVolumePath} ${imageName}``.
**Explanation of Docker Command Flags**
- ``docker run``: This command starts a new Docker container.
- ``--rm``: Automatically removes the container when it exits. Useful for temporary containers.
- ``--gpus all``: Enables access to all GPUs in the container.
- ``-it``: Allocates a pseudo-TTY and keeps stdin open. Allows interactive terminal access.
- ``--name ${containerName}``: Assigns a name to the container instance based on the value stored in the ``$containerName`` variable.
- ``-v ${hostVolumePath}:${containerVolumePath}``: Mounts a volume from the host machine (Windows) into the Docker container. ``${hostVolumePath}`` is the path on the host system, and ``${containerVolumePath}`` is the path inside the container where the volume will be mounted.
- ``${imageName}``: Specifies the Docker image to use for creating the container.
**Additional Information**
- The ``--rm`` flag ensures that the container is automatically removed after it stops running, helping to manage resources efficiently.
- ``--gpus all`` allows the Docker container to access all available GPUs on the host machine, which is crucial for applications that require GPU acceleration.
- ``-it`` enables interactive mode with a terminal session, which is useful for interacting directly with the container if needed.
This Docker command, when executed within the PowerShell script, sets up and runs the Docker container named ``${containerName}`` with GPU support, mounts necessary volumes, and utilizes the specified Docker image ``${imageName}`` for the Maxwell-TD application. Adjust ``${containerName}``, ``${hostVolumePath}``, ``${containerVolumePath}``, and ``${imageName}`` as per your specific environment and requirements.
.. figure:: images/W21.png
:width: 1200
:align: center
Commands to run Docker image
.. note::
When opening a Windows text file in a Unix environment, extra ``\r`` characters at the end of each line can cause errors such as ``/bin/bash^M: bad interpreter: No such file or directory``. This is because Unix-based systems expect lines to end with ``\n`` (newline) instead of ``\r\n`` (carriage return followed by newline) used in Windows.
To fix this issue, you can convert the line endings from Windows format to Unix format using utilities like ``dos2unix``, which removes the extra ``\r`` characters. Alternatively, you can use the included function ``Remove-CarriageReturns`` in ``runDocker.ps1`` to process the files. Once corrected, your script should execute correctly within Docker or any Unix-based environment without encountering interpreter errors.
.. figure:: images/W19.png
:width: 1200
:align: center
Miscellaneous function to treat textfiles from Windows System (Optional)
To run the script, navigate to the directory where ``runDocker.ps1`` is located and execute ``./runDocker.ps1``. The script will display the CUDA toolkit version and open a BASH shell in the Docker container with ``maxwell_td_image``. This environment simulates a Linux environment.
.. figure:: images/W27.png
:width: 1200
:align: center
Running PowerShell Script
How to use Maxwell-TD
=====================
Upon starting the Docker container, you will be in the ``/dgtd/`` directory, where the Discontinuous Galerkin Time-Domain (DGTD) code is located. The compiled code can be found in the ``/dgtd/build/`` directory, with the executables named ``maxwelltd_CUDA_LTS_DOUBLEpre_FLOATpro`` and ``maxwelltd_CUDA_LTS_DOUBLEpre_FLOATpro-``. User data, mounted from the Windows filesystem, is available in the ``/dgtd/model/`` directory. Before running the simulation, the compiled executable must be copied to the simulation folder (``/dgtd/model/MaxwellTD_data/``). This can be done by executing the following command:
.. code-block:: bash
cp /dgtd/build/maxwelltd_CUDA_LTS_DOUBLEpre_FLOATpro* /dgtd/model/MaxwellTD_data/
.. figure:: images/W29.png
:width: 1200
:align: center
Local Directory in Docker Image
Simulation files for the MaxwellTD model are located in the directory ``/dgtd/model/MaxwellTD_data``. Additionally, we have included CST reference data for the same simulation model in the folder ``CST_data``. A Python script named ``compare_maxwelltd_CST.py`` has been provided to facilitate extraction and comparison of data between the DGTD simulation and CST data.
.. figure:: images/W31a.png
:width: 1200
:align: center
Simulation folder
To run the DGTD simulation, we can navigate to ``/dgtd/model/MaxwellTD_data/`` and run the shell script ``CUDA_LTS_RUN.sh``.
.. code-block:: bash
./CUDA_LTS_RUN.sh
.. figure:: images/W45.png
:width: 1200
:align: center
Running Simulation script
This will initiate the DGTD simulation.
.. figure:: images/W46.png
:width: 1200
:align: center
Simulating running
.. figure:: images/W47.png
:width: 1200
:align: center
End of simulation
Following the completion of the simulation, you can execute the Python script ``compare_maxwelltd_CST.py`` to compare the results with those obtained from the CST simulation.
.. code-block:: bash
python3 compare_maxwelltd_CST.py
.. figure:: images/W49.png
:width: 1200
:align: center
Running post-processing PYTHON script
Common issues
=============
Incompatible GPU drivers/toolkit
--------------------------------
It's essential to verify that your Windows device has the correct CUDA toolkit installed to run Maxwell-TD. You can check the CUDA toolkit version by using 'nvidia-smi' in the console terminal. The minimum required version to run Maxwell-TD is CUDA toolkit 12.4.
.. figure:: images/W22.png
:width: 1200
:align: center
Check CUDA toolkit version
If you need to update your CUDA toolkit, you can visit the `NVIDIA website `_ (https://developer.nvidia.com/cuda-toolkit). Click on 'NVIDIA CUDA Toolkit Download' to access the latest version. Alternatively, if you require an earlier version, you can navigate to 'Archive of Previous CUDA Releases' on the NVIDIA website to find the specific CUDA toolkit version you need.
.. figure:: images/W23.png
:width: 1200
:align: center
NVIDIA website to download CUDA toolkit
.. figure:: images/W24.png
:width: 1200
:align: center
NVIDIA CUDA toolkit download
.. figure:: images/W25.png
:width: 1200
:align: center
NVIDIA CUDA toolkit (Latest version)
.. figure:: images/W26.png
:width: 1200
:align: center
NVIDIA CUDA toolkit (Earlier versions)
Follow the download and installation instructions provided on the NVIDIA website to update or install the CUDA toolkit on your Windows device. This ensures that Maxwell-TD and other CUDA-dependent applications can function correctly.
Windows Version
---------------
Make sure your Windows 10 or 11 system meets the following requirements:
- **WSL Version:** Ensure WSL version 1.1.3.0 or newer.
- **Windows 11:** 64-bit Home or Pro version 21H2 or later, or Enterprise or Education version 21H2 or later.
- **Windows 10:** 64-bit Home or Pro version 22H2 (build 19045) or later, or Enterprise or Education version 22H2 (build 19045) or later. The minimum supported version is Home or Pro 21H2 (build 19044) or later, or Enterprise or Education 21H2 (build 19044) or later.
.. note::
- Docker Desktop on Windows is supported only on versions of Windows that are still actively serviced by Microsoft. It is not compatible with Windows Server versions like Windows Server 2019 or Windows Server 2022.
- Containers and images created with Docker Desktop are shared across all user accounts on the same machine, as they use a common VM for building and running containers. However, sharing containers and images between user accounts is not supported when using the Docker Desktop WSL 2 backend.
Sufficient Memory to upload image
---------------------------------
Make sure your system has adequate storage space for the image. The current image requires 10GB for storage while zipped. Once extracted, it occupies an additional 10GB on your system, although it remains hidden from regular users. You can view these hidden images and containers using Docker Desktop.
.. figure:: images/W42.png
:width: 1200
:align: center
View all containers or image on Docker Desktop
Users can remove any unwanted images or containers using the 'delete' button.
.. figure:: images/W43.png
:width: 1200
:align: center
Delete if not needed to free up space
If necessary, resort to command-line operations to reclaim system resources. Execute these commands in a PowerShell console with administrative privileges.
.. code-block:: bash
# Purging All Unused or Dangling Resources
docker system prune
# Remove stopped containers and all unused images
docker system prune -a
# Removing Docker Images
## Remove Specific Images
# List all images (including intermediate layers)
docker images -a
# Remove specific image(s) using their ID or tag
docker rmi
## Remove Dangling Images
# List dangling images
docker images -f dangling=true
# Remove dangling images
docker image prune
## Remove Images Matching a Pattern
# List images matching a pattern (using grep)
docker images -a | grep "pattern"
# Remove images matching a pattern using awk and xargs
docker images -a | grep "pattern" | awk '{print $1":"$2}' | xargs docker rmi
## Remove All Images
# Remove all Docker images
docker rmi $(docker images -a -q)
# Removing Containers
## Remove Specific Containers
# List all containers (including stopped ones)
docker ps -a
# Remove specific container(s)
docker rm
## Remove All Exited Containers
# List all exited containers
docker ps -a -f status=exited
# Remove all exited containers
docker rm $(docker ps -a -f status=exited -q)
## Remove Containers Matching a Pattern
# List containers matching a pattern (using grep)
docker ps -a | grep "pattern"
# Remove containers matching a pattern using awk and xargs
docker ps -a | grep "pattern" | awk '{print $1}' | xargs docker rm
## Stop and Remove All Containers
# Stop all containers
docker stop $(docker ps -a -q)
# Remove all containers
docker rm $(docker ps -a -q)
BIOS settings
-------------
To enable Docker server virtualization on Windows, it's crucial to ensure that virtualization is enabled in your computer's BIOS settings. This setting can only be modified by restarting your machine and accessing the BIOS configuration. Virtualization support in BIOS allows Windows to utilize Docker server features effectively. It's a necessary step to ensure Docker containers run efficiently on your system.
Change Simulation Parameters
----------------------------
To modify simulation parameters, you can edit the ``CUDA_LTS_RUN.sh`` shell script. This script contains flags or variables that control various aspects of the DGTD simulation. The script includes comments or descriptions to explain the variables' or flags' purpose.
.. code-block:: bash
echo "==========="
echo "EXECUTABLE"
EXE="./maxwelltd_CUDA_LTS_DOUBLEpre_FLOATpro"
echo $EXE
echo "FileName"
echo "==========="
# 0. [EXE]
# 1. Filename: Simulation Filename
# 2. Freq: Central Modulation Frequency (MHz)
# 3. Planewave Waveform (Excitation Type): (0)Time Harmonic (1)Gauss (2)Neumann (3) Modulated Gauss;
# 4. Port Waveform (0) Time Harmonic Pulse (1) Gaussian Pulse
# 5. Tdelay: Delay of excitation pulse (sec)
# 6. Tau: Width of pulse (sec)
# 7. FinalTime: Termination Time (sec)
# 8. Gamma (Penalty) --> 1 upwind , 0 central
# 9. VTU --> 0 (YES), 1 (NO)
#10. Surface Field Output BC Surfaces --> (0) Off (1) PEC only (2) FieldPlane only (3) FieldPlane and PEC
#11. Surface Output Types --> (0) Field (1) Current (2) Field and Current
#12. Poly order --> (1) First Order (2) Second Order
#13. Free Space Comparison(Analytical): (0) True and (1) False
#14. SAMPLINGRATE : parameter of Pade approximation
#15. PADE : (0) Pade mode is Off (2) Pade mode is on
FILENAME=cylinder_cr1.75
FREQ=2650
PLANEWAVEFLAG=1
PORTFLAG=1
TD=2.5e-9
TAU=2.5e-10
FINALTIME=25e-8
GAMMA=0.025
VTU=1
SURFFIELDOUTBCSURFS=0
SURFOUTTYPES=0
POLYORDER=2
ANALYTICAL=1
SAMPLINGRATE=12.5
PADE=2
rm *.log
rm *.vtu
rm AnalyticalIncidentField*
rm Probes_*
rm *.TD*
rm -r ./TimeDomainVoltages
$EXE $FILENAME $FREQ $PLANEWAVEFLAG $PORTFLAG $TD $TAU $FINALTIME $GAMMA $VTU $SURFFIELDOUTBCSURFS $SURFOUTTYPES $POLYORDER $ANALYTICAL $SAMPLINGRATE $PADE | tee -a compute.log
rm -r ./VTU_LTS
mkdir ./VTU_LTS
mv *.vtu ./VTU_LTS
rm -r ./PROBES
mkdir ./PROBES
mv *.csv ./PROBES
mv *.TD* ./PROBES
mv *.log ./PROBES