Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions .github/workflows/build.yml

This file was deleted.

5 changes: 3 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,13 @@ repos:
- id: check-json
- id: check-merge-conflict
args: ["--assume-in-merge"]
exclude: '(docs/.*|OpenCOOD/docs/.*)'
exclude: 'docs/.*'
- id: check-shebang-scripts-are-executable
- id: check-symlinks
- id: check-toml
- id: check-vcs-permalinks
- id: check-xml
- id: check-yaml
exclude: opencda/coperception_models/.*
- id: destroyed-symlinks
- id: end-of-file-fixer
- id: name-tests-test
Expand All @@ -46,6 +45,8 @@ repos:
description: ''
entry: mypy
language: python
additional_dependencies:
- mypy
'types_or': [python, pyi]
args: [".", "--follow-imports=silent"]
pass_filenames: false
Expand Down
2 changes: 1 addition & 1 deletion AIM/models/mtp/GNN_mtl_gnn/GNN_mtl_gnn.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def __init__(self, hidden_channels: int) -> None:
self.linear4: nn.Linear = nn.Linear(hidden_channels, hidden_channels)
self.linear5: nn.Linear = nn.Linear(hidden_channels, 30 * 2)

def forward(
def forward( # noqa: DC04 - invoked dynamically by torch.nn.Module.__call__
self,
x: torch.Tensor,
edge_index: torch.Tensor,
Expand Down
100 changes: 4 additions & 96 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,102 +2,10 @@ cmake_minimum_required(VERSION 3.31)

project(OpenCDA LANGUAGES NONE)

option(OPENCDA_BUILD_CUDA "Build OpenCOOD CUDA extensions" OFF)
option(OPENCDA_BUILD_PROTOBUF "Generate OpenCDA protobuf Python modules" OFF)
option(OPENCDA_BUILD_PROTOBUF "Generate OpenCDA protobuf Python modules" ON)

if(NOT OPENCDA_BUILD_CUDA AND NOT OPENCDA_BUILD_PROTOBUF)
message(FATAL_ERROR
"No build component selected. Enable OPENCDA_BUILD_CUDA or "
"OPENCDA_BUILD_PROTOBUF."
)
if(NOT OPENCDA_BUILD_PROTOBUF)
message(FATAL_ERROR "No OpenCDA build component selected")
endif()

if(OPENCDA_BUILD_PROTOBUF)
add_subdirectory(opencda/core/common/communication)
endif()

if(OPENCDA_BUILD_CUDA)
if(NOT DEFINED CMAKE_CUDA_ARCHITECTURES OR CMAKE_CUDA_ARCHITECTURES STREQUAL "")
message(FATAL_ERROR
"CMAKE_CUDA_ARCHITECTURES must be set explicitly when building "
"the OpenCOOD CUDA extensions."
)
endif()

set(OPENCDA_CUDA_ARCHITECTURES "${CMAKE_CUDA_ARCHITECTURES}")
set(OPENCDA_TORCH_CUDA_ARCH_LIST)
foreach(cuda_architecture IN LISTS OPENCDA_CUDA_ARCHITECTURES)
if(NOT cuda_architecture MATCHES "^[0-9]+$")
message(FATAL_ERROR
"Unsupported CUDA architecture '${cuda_architecture}'. "
"Use numeric values such as 86 or 75;86;89."
)
endif()

math(EXPR cuda_architecture_major "${cuda_architecture} / 10")
math(EXPR cuda_architecture_minor "${cuda_architecture} % 10")
list(APPEND OPENCDA_TORCH_CUDA_ARCH_LIST
"${cuda_architecture_major}.${cuda_architecture_minor}"
)
endforeach()

enable_language(CXX)
enable_language(CUDA)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CUDA_STANDARD 17)
set(CMAKE_CUDA_STANDARD_REQUIRED ON)
set(CMAKE_CUDA_EXTENSIONS OFF)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

find_package(Python3 3.12 REQUIRED COMPONENTS Interpreter Development.Module)
find_package(CUDAToolkit REQUIRED)

execute_process(
COMMAND
"${Python3_EXECUTABLE}" -c
"import torch; print(torch.utils.cmake_prefix_path)"
OUTPUT_VARIABLE TORCH_CMAKE_PREFIX_PATH
OUTPUT_STRIP_TRAILING_WHITESPACE
COMMAND_ERROR_IS_FATAL ANY
)
list(APPEND CMAKE_PREFIX_PATH "${TORCH_CMAKE_PREFIX_PATH}")

# PyTorch's CMake package uses TORCH_CUDA_ARCH_LIST and otherwise adds a
# broad architecture list that includes targets removed from recent CUDA
# toolkits. Disable CMake's duplicate architecture flags and let PyTorch
# emit the requested gencode flags.
unset(CMAKE_CUDA_ARCHITECTURES CACHE)
unset(CMAKE_CUDA_ARCHITECTURES)
set(TORCH_CUDA_ARCH_LIST "${OPENCDA_TORCH_CUDA_ARCH_LIST}")
message(STATUS
"Building OpenCOOD CUDA extensions for ${TORCH_CUDA_ARCH_LIST}"
)
find_package(Torch REQUIRED)

execute_process(
COMMAND
"${Python3_EXECUTABLE}" -c
"from pathlib import Path; import torch; print(Path(torch.__file__).parent / 'lib')"
OUTPUT_VARIABLE OPENCDA_DETECTED_TORCH_LIBRARY_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE
COMMAND_ERROR_IS_FATAL ANY
)
set(
OPENCDA_TORCH_RUNTIME_LIBRARY_DIR
"${OPENCDA_DETECTED_TORCH_LIBRARY_DIR}"
CACHE PATH
"Runtime directory containing the PyTorch shared libraries"
)
find_library(
OPENCDA_TORCH_PYTHON_LIBRARY
NAMES torch_python
PATHS "${OPENCDA_DETECTED_TORCH_LIBRARY_DIR}"
NO_DEFAULT_PATH
REQUIRED
)

add_subdirectory(OpenCOOD/opencood/pcdet_utils)
endif()
add_subdirectory(opencda/core/common/communication)
16 changes: 0 additions & 16 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
{
"configurePreset": "protobuf",
"name": "protobuf"
},
{
"configurePreset": "cuda",
"name": "cuda"
}
],
"cmakeMinimumRequired": {
Expand All @@ -18,23 +14,11 @@
{
"binaryDir": "${sourceDir}/build/protobuf",
"cacheVariables": {
"OPENCDA_BUILD_CUDA": "OFF",
"OPENCDA_BUILD_PROTOBUF": "ON"
},
"displayName": "OpenCDA protobuf modules",
"generator": "Ninja",
"name": "protobuf"
},
{
"binaryDir": "${sourceDir}/build/cuda",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"OPENCDA_BUILD_CUDA": "ON",
"OPENCDA_BUILD_PROTOBUF": "OFF"
},
"displayName": "OpenCOOD CUDA extensions",
"generator": "Ninja",
"name": "cuda"
}
],
"version": 6
Expand Down
83 changes: 58 additions & 25 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ ENV HOME=${HOME}
ENV PATH="/opt/venv/bin:${PATH}"
ENV XDG_RUNTIME_DIR=/tmp/runtime-${USER}
ENV OPENCDA_WORKSPACE=${HOME}/cavise/opencda
ENV OPENCOOD_WORKSPACE=${HOME}/cavise/opencood
ENV CAVISE_MODELS_ROOT=${HOME}/cavise/models

RUN apt-get update && \
apt-get install -y --no-install-recommends \
Expand All @@ -39,7 +41,7 @@ RUN if id -u ubuntu >/dev/null 2>&1; then userdel -r ubuntu; fi && \
chown -R ${UID}:${UID} ${XDG_RUNTIME_DIR} ${HOME}


FROM runtime-base AS python-dependencies
FROM runtime-base AS python-opencda-dependencies

RUN apt-get update && \
apt-get install -y --no-install-recommends python3-venv=3.12.* && \
Expand All @@ -57,6 +59,14 @@ RUN python3 -m venv /opt/venv && \
-r /tmp/opencda-requirements/requirements.txt


FROM python-opencda-dependencies AS python-opencood-dependencies

COPY opencood/requirements.txt /tmp/opencood-requirements/requirements.txt

RUN /opt/venv/bin/python -m pip install --no-cache-dir \
-r /tmp/opencood-requirements/requirements.txt


FROM ubuntu:${UBUNTU_VERSION}@${UBUNTU_DIGEST} AS protobuf-builder

ARG PROTOC_VERSION=36.0
Expand Down Expand Up @@ -98,14 +108,13 @@ COPY opencda/opencda/core/common/communication/messages/ \

RUN cmake -S . -B /tmp/opencda-protobuf-build -G Ninja \
-DOPENCDA_BUILD_PROTOBUF=ON \
-DOPENCDA_BUILD_CUDA=OFF \
&& \
cmake --build /tmp/opencda-protobuf-build && \
cmake --install /tmp/opencda-protobuf-build \
--prefix /opt/opencda-artifacts/protobuf


FROM docker.io/nvidia/cuda:${CUDA_VERSION}-devel-ubuntu${UBUNTU_VERSION}@${CUDA_DEVEL_DIGEST} AS cuda-builder
FROM docker.io/nvidia/cuda:${CUDA_VERSION}-devel-ubuntu${UBUNTU_VERSION}@${CUDA_DEVEL_DIGEST} AS opencood-cuda-builder

ARG CUDA_ARCHITECTURES=86

Expand All @@ -120,30 +129,27 @@ RUN apt-get update && \
&& \
rm -rf /var/lib/apt/lists/*

COPY opencda/requirements-cuda.txt /tmp/requirements-cuda.txt
COPY opencood/requirements-cuda.txt /tmp/requirements-cuda.txt

RUN python3 -m venv /opt/cuda-build-venv && \
python -m pip install --no-cache-dir \
cmake==4.4.3 \
ninja==1.13.2 \
-r /tmp/requirements-cuda.txt

WORKDIR /src/opencda
WORKDIR /src/opencood

COPY opencda/CMakeLists.txt ./
COPY opencda/OpenCOOD/opencood/pcdet_utils/ \
OpenCOOD/opencood/pcdet_utils/
COPY opencood/CMakeLists.txt ./
COPY opencood/opencood/pcdet_utils/ opencood/pcdet_utils/

RUN cmake -S . -B /tmp/opencda-cuda-build -G Ninja \
-DOPENCDA_BUILD_PROTOBUF=OFF \
-DOPENCDA_BUILD_CUDA=ON \
RUN cmake -S . -B /tmp/opencood-cuda-build -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CUDA_ARCHITECTURES=${CUDA_ARCHITECTURES} \
-DOPENCDA_TORCH_RUNTIME_LIBRARY_DIR=/opt/venv/lib/python3.12/site-packages/torch/lib \
-DOPENCOOD_TORCH_RUNTIME_LIBRARY_DIR=/opt/venv/lib/python3.12/site-packages/torch/lib \
&& \
cmake --build /tmp/opencda-cuda-build && \
cmake --install /tmp/opencda-cuda-build \
--prefix /opt/opencda-artifacts/cuda
cmake --build /tmp/opencood-cuda-build && \
cmake --install /tmp/opencood-cuda-build \
--prefix /opt/opencood-artifacts/cuda


FROM runtime-base AS opencda-base
Expand All @@ -152,13 +158,12 @@ ARG USER=opencda
ARG UID=1000
ARG HOME=/home/${USER}

COPY --from=python-dependencies /opt/venv /opt/venv
COPY --from=python-opencda-dependencies /opt/venv /opt/venv

WORKDIR ${HOME}/cavise/opencda

COPY --chown=${UID}:${UID} opencda/opencda.py ./
COPY --chown=${UID}:${UID} opencda/opencda/ opencda/
COPY --chown=${UID}:${UID} opencda/OpenCOOD/ OpenCOOD/
COPY --chown=${UID}:${UID} opencda/AIM/ AIM/
COPY opencda/docker/sync-build-artifacts.sh \
/usr/local/bin/opencda-sync-build-artifacts
Expand All @@ -184,19 +189,47 @@ COPY --from=protobuf-builder /opt/opencda-artifacts/protobuf \
/opt/opencda-artifacts/protobuf


FROM opencda-base AS opencda-cuda
FROM opencda-base AS opencda-coperception-base

ARG USER=opencda
ARG UID=1000

USER 0

RUN apt-get update && \
apt-get install -y --no-install-recommends git=1:2.43.* && \
rm -rf /var/lib/apt/lists/*

COPY --from=python-opencood-dependencies /opt/venv /opt/venv
COPY --chown=${UID}:${UID} opencood/ ${OPENCOOD_WORKSPACE}/
COPY opencood/docker/sync-cuda-artifacts.sh \
/usr/local/bin/opencood-sync-cuda-artifacts

RUN chmod 755 /usr/local/bin/opencood-sync-cuda-artifacts && \
python -m pip install --no-cache-dir --no-build-isolation --no-deps \
--editable ${OPENCOOD_WORKSPACE}

USER ${USER}

ENTRYPOINT ["/usr/local/bin/opencood-sync-cuda-artifacts", "/usr/local/bin/opencda-sync-build-artifacts"]

ENV OPENCDA_NATIVE_COMPONENTS="cuda"

COPY --from=cuda-builder /opt/opencda-artifacts/cuda \
/opt/opencda-artifacts/cuda
FROM opencda-coperception-base AS opencda-coperception

ENV OPENCOOD_NATIVE_COMPONENTS=""

FROM opencda-base AS opencda

ENV OPENCDA_NATIVE_COMPONENTS="protobuf cuda"
FROM opencda-coperception-base AS opencda-cuda

ENV OPENCOOD_NATIVE_COMPONENTS="cuda"

COPY --from=opencood-cuda-builder /opt/opencood-artifacts/cuda \
/opt/opencood-artifacts/cuda


FROM opencda-cuda AS opencda

ENV OPENCDA_NATIVE_COMPONENTS="protobuf"

COPY --from=protobuf-builder /opt/opencda-artifacts/protobuf \
/opt/opencda-artifacts/protobuf
COPY --from=cuda-builder /opt/opencda-artifacts/cuda \
/opt/opencda-artifacts/cuda
37 changes: 0 additions & 37 deletions OpenCOOD/.devcontainer/ubuntu/Dockerfile

This file was deleted.

Loading
Loading