1. Install Docker (Source):
2. Install Nividia Docker (Source):
- install
jqusingsudo apt install jqas this is needed to get docker tags
We use docker compose with various arguments that need to be filled to build the Docker Image.
The arguments are read from a .env file that is generated by create_cuda_docker.py
By default, create_cuda_docker.py will use a DATA_PATH of /data, and a WORKSPACE_PATH of ~/workspaces. If you don't have access to /data it is recommended that you change those parameters. You can do this with the following flags or by using the interactive prompt when running create_cuda_docker.py
usage: create_cuda_docker.py [-h] [-d] [--ubuntu UBUNTU] [-c CUDA] [-b] [--data_path DATA_PATH] [--workspace_path WORKSPACE_PATH] [-u]
Script to help configure the docker container by rewriting the .env file used by docker compose for building. It will automatically set up the current user and their home directory as
available in the docker container.
optional arguments:
-h, --help show this help message and exit
-d, --default Use default version of Cuda and Paths
--ubuntu UBUNTU Version of Ubuntu to use (Default: 22.04)
-c CUDA, --cuda CUDA Version of CUDA to use (Default: 11.8.0)
-b, --build Build docker container in addition to configuring it (Builds cans take around 30 minutes)
--data_path DATA_PATH
Which host OS folder to link to docker container as /data (Default: /data/)
--workspace_path WORKSPACE_PATH
Which host OS folder to link to docker container as ~/workspaces (Default: ~/workspaces/)
-u, --user Use current user as the username in the docker container
create_cuda_docker.py has an interactive prompt when ran on its own:
# Use the interactive prompting to fill the .env file
./create_cuda_docker.py
# Create the docker image and container from .env config
docker compose up --no-start --buildCreate the docker image. Note that currently the image uses your username and id to create a non-sudo user.
# Create directories for data and workspaces. You can also point to existing paths if desired
mkdir -p ${HOME}/data
mkdir -p ${HOME}/workspaces
# create the docker .env file
./create_cuda_docker.py -c 11.8.0 --user --data_path ${HOME}/data --workspace_path ${HOME}/workspaces
# Build the docker image
docker compose up --no-start --build- To create link the
./create_cuda_docker.py --default - run
docker compose up --no-start --build(might take a while to build the docker image the first time - maybe 20 minutes?) - run
./docker_bash.sh ros2_cudato be dropped inside the container and to open multiple terminals into the same container
We also provide a script to start a container if is currently stopped and provide a bash prompt into the container.
# To start a bash session inside the container run:
./docker_bash.sh ros2_cuda
# docker_bash.sh may be used repeatedly in other terminals to get multiple shells in the docker container.We have a bash completion file as well for so that you can TAB between available docker containers. To install both the container launching script and its bash completion locally, you can do the following:
# Make folders in case they don't exist
mkdir -p $HOME/.local/bin
mkdir -p $HOME/.bash_completions
# symlink files to these locations to install script and bash completion
# Assuming you are in MPPI_Paper_Example_Code/docker/
ln -rs docker_bash.sh $HOME/.local/bin/docker_bash.sh
ln -rs misc/docker_bash-completion.bash $HOME/.bash_completions/docker_bash-completion.bash
# setup .bashrc to point to local installations
cat << EOF >> $HOME/.bashrc
if [ -d \$HOME/.bash_completions ]; then
for f in \$HOME/.bash_completions/*; do
source \$f
done
fi
EOF
echo "export PATH=\$HOME/.local/bin:\$PATH" >> $HOME/.bashrc
source $HOME/.bashrc