Skip to content

Commit

Permalink
Update docker (#39)
Browse files Browse the repository at this point in the history
* Add docker for v11

* Reduce docker image size by cleaning vcpkg tmp files after build

* After review
  • Loading branch information
msz-rai authored and prybicki committed Nov 22, 2022
1 parent 61026b4 commit 407d83c
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 12 deletions.
9 changes: 9 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.vs
.vscode
Builds/*
Testing/*
.idea
cmake-build-debug
cmake-build-release
build
external/vcpkg
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,6 @@ Builds/*
Testing/*
.idea
cmake-build-debug
cmake-build-release
build
external/vcpkg
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ find_package(PCL 1.12 CONFIG REQUIRED COMPONENTS common io filters visualization
# Includes
include_directories(include)
include_directories($ENV{OptiX_INSTALL_DIR}/include)
include_directories(${spdlog_SOURCE_DIR}/include)

# Compile OptiX device programs (pipeline) and embed the binary in a library as a char[]
add_library(optixProgramsPtx OBJECT src/gpu/optixPrograms.cu)
Expand Down
6 changes: 0 additions & 6 deletions Dockerfile

This file was deleted.

25 changes: 25 additions & 0 deletions DockerfileLatest
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM nvidia/cuda:11.7.1-devel-ubuntu22.04

ARG DEBIAN_FRONTEND=noninteractive

RUN apt update

RUN apt install -y cmake

# Install vcpkg dependencies
RUN apt install -y \
git \
curl \
zip \
unzip \
tar \
pkg-config \
freeglut3-dev \
python3

# Install RGL dependencies via vcpkg
COPY setup.bash /
RUN /setup.bash
RUN rm /setup.bash

WORKDIR /code
28 changes: 28 additions & 0 deletions DockerfileMinimal
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM nvidia/cuda:11.2.0-devel-ubuntu20.04

ARG DEBIAN_FRONTEND=noninteractive

RUN apt update

# Install cmake from PIP since 3.17 is needed
RUN apt install -y \
python3-pip
RUN pip3 install cmake --upgrade

# Install vcpkg dependencies
RUN apt install -y \
git \
curl \
zip \
unzip \
tar \
pkg-config \
freeglut3-dev \
python3

# Install RGL dependencies via vcpkg
COPY setup.bash /
RUN /setup.bash
RUN rm /setup.bash

WORKDIR /code
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,20 @@ And more:

An introduction to the RGL API along with an example can be found [here](docs/Usage.md).

## Building in Docker (Linux)

Two dockerfiles are prepared:
- `DockerfileMinimal` - image designed to meet RGL minimal requirements
- `DockerfileLatest` - image with latest Ubuntu and CUDA Toolkit version

Build instructions:
1. Download [NVidia OptiX](https://developer.nvidia.com/designworks/optix/download) 7.2
2. `export OptiX_INSTALL_DIR=<Path to OptiX>`
3. `docker build . -f DockerfileMinimal --tag rgl:minimal`
4. Set up [NVIDIA Container Toolkit](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html#docker)
5. `docker run --net=host --gpus all -v $(pwd):/code -v ${OptiX_INSTALL_DIR}:/optix -e OptiX_INSTALL_DIR=/optix -e NVIDIA_DRIVER_CAPABILITIES=all -it rgl:minimal /bin/bash`
6. `./setup.bash --cmake --make -j`

## Building on Ubuntu

1. Install [CUDA Toolkit](https://developer.nvidia.com/cuda-downloads) 11.2+.
Expand Down
21 changes: 15 additions & 6 deletions setup.bash
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ CUDA_MIN_VER_MAJOR="11"
CUDA_MIN_VER_MINOR="2"
VCPKG_INSTALL_DIR="external/vcpkg"
VCPKG_TAG="2022.08.15"
INSIDE_DOCKER=false

if [ -f /.dockerenv ]; then
VCPKG_INSTALL_DIR="/rgldep/vcpkg"
INSIDE_DOCKER=true
echo "Setup inside docker"
fi

CMAKE_ARGS=()
MAKE_ARGS=()
Expand Down Expand Up @@ -38,21 +45,23 @@ if [ "$CUDA_MAJOR" -lt $CUDA_MIN_VER_MAJOR ] ||
echo "CUDA version not supported! Get $CUDA_MIN_VER_MAJOR.$CUDA_MIN_VER_MINOR+" && exit 1;
fi

# Check OptiX_INSTALL_DIR
if [ -z "$OptiX_INSTALL_DIR" ]; then
# Check OptiX_INSTALL_DIR if building RGL
if [ -z "$OptiX_INSTALL_DIR" ] && { [ "$DO_CMAKE" = true ] || [ "$DO_MAKE" = true ]; }; then
echo "OptiX not found! Make sure you export environment variable OptiX_INSTALL_DIR" && exit 1;
fi

# Install PCL using vcpkg
if [ ! -d "$VCPKG_INSTALL_DIR" ]; then
echo "Installing dependencies for vcpkg..."
sudo apt update
sudo apt install git curl zip unzip tar freeglut3-dev
if [ "$INSIDE_DOCKER" = false ]; then # Inside docker already provided
echo "Installing dependencies for vcpkg..."
sudo apt update
sudo apt install git curl zip unzip tar freeglut3-dev
fi
git clone -b $VCPKG_TAG --single-branch --depth 1 https://github.com/microsoft/vcpkg $VCPKG_INSTALL_DIR
fi
if [ ! -f $VCPKG_INSTALL_DIR"/vcpkg" ]; then $VCPKG_INSTALL_DIR"/bootstrap-vcpkg.sh"; fi

$VCPKG_INSTALL_DIR"/vcpkg" "install" "pcl[core,visualization]"
$VCPKG_INSTALL_DIR"/vcpkg" "install" "--clean-after-build" "pcl[core,visualization]"

# Build
if [ ! -d "build" ]; then mkdir build; fi
Expand Down

0 comments on commit 407d83c

Please sign in to comment.