Skip to content
Draft
Show file tree
Hide file tree
Changes from 3 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
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ Dockerfile
!.git
!.gitignore
!.gitmodules
!.python-version
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ jobs:
&& sed -i '/# Load policy/{N;N;N;N;N;N;s|# Load policy\n policy = load_policy(\n path_to_cpt=config.cpt_path,\n model_name=config.cpt_name,\n device=config.device,\n env=env,\n )|from gpudrive.networks.late_fusion import NeuralNet\n policy = NeuralNet.from_pretrained(\"daphne-cornelisse/policy_S10_000_02_27\")|}' examples/experimental/viz_rollouts.py \
&& echo 'Modifications to run without GPU' \
&& sed -i 's/device=\"cuda\"/device=\"cpu\"/g' gpudrive/datatypes/observation.py \
&& python examples/experimental/viz_rollouts.py
&& uv run python examples/experimental/viz_rollouts.py
"
7 changes: 1 addition & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
.vscode/launch.json
.vscode/settings.json
.vscode/tasks.json
.uv_cache

/examples/benchmarks/results/
/baselines/ppo/logs/*
Expand All @@ -17,7 +18,6 @@
*madrona.diff
/bin
/zipp*
.python-version
/google-cloud-sdk/*
*.gz

Expand Down Expand Up @@ -155,11 +155,6 @@ target/
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
Expand Down
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[submodule "external/madrona"]
path = external/madrona
url = https://github.com/shacklettbp/madrona.git
url = https://github.com/m-naumann/madrona.git
Comment thread
m-naumann marked this conversation as resolved.
[submodule "external/json"]
path = external/json
url = https://github.com/nlohmann/json.git
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.11
29 changes: 8 additions & 21 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,39 +27,26 @@ RUN apt-get update && apt-get install -y -q --no-install-recommends \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

# Install Python 3.11
RUN apt-add-repository -y ppa:deadsnakes/ppa \
&& apt-get install -y -q --no-install-recommends python3.11 python3.11-dev python3.11-distutils \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

RUN curl -sS https://bootstrap.pypa.io/get-pip.py | python3.11

# Set Python 3.11 as default
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 11 && \
update-alternatives --install /usr/bin/python python /usr/bin/python3.11 11

RUN apt-get remove -y cmake && pip3 install --no-cache-dir --upgrade cmake
# Install uv
RUN curl -LsSf https://astral.sh/uv/install.sh | env UV_INSTALL_DIR="/usr/bin" sh

# Copy the gpudrive repository
COPY . /gpudrive
WORKDIR /gpudrive
RUN git submodule update --init --recursive --depth 1
RUN git submodule update --init --recursive

# Install python part using uv
RUN uv sync --frozen

ENV MADRONA_MWGPU_KERNEL_CACHE=./gpudrive_cache

RUN mkdir build
WORKDIR /gpudrive/build
RUN cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_POLICY_VERSION_MINIMUM=3.5 && find external -type f -name "*.tar" -delete
RUN uv run cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_POLICY_VERSION_MINIMUM=3.5 && find external -type f -name "*.tar" -delete
RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/libcuda.so.1
RUN LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs/:$LD_LIBRARY_PATH make -j
RUN LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs/:$LD_LIBRARY_PATH uv run make -j
RUN rm /usr/local/cuda/lib64/stubs/libcuda.so.1
WORKDIR /gpudrive

RUN pip3 install --no-cache-dir torch==2.6.0 && rm -rf ~/.cache/pip/*
RUN pip3 install --no-cache-dir tensorflow==2.19.0 && rm -rf ~/.cache/pip/*
RUN pip3 install --no-cache-dir nvidia-cuda-runtime-cu12==12.4.127 && rm -rf ~/.cache/pip/*
RUN pip3 install --no-cache-dir -e .[vbd,pufferlib]

CMD ["/bin/bash"]
LABEL org.opencontainers.image.source=https://github.com/Emerge-Lab/gpudrive
20 changes: 8 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
GPUDrive
========

![Python version](https://img.shields.io/badge/Python-3.11-blue) [![Paper](https://img.shields.io/badge/arXiv-2408.01584-b31b1b.svg)](https://arxiv.org/abs/2408.01584)
[![Paper](https://img.shields.io/badge/arXiv-2408.01584-b31b1b.svg)](https://arxiv.org/abs/2408.01584)
[![GitHub CI](https://github.com/Emerge-Lab/gpudrive/actions/workflows/ci.yml/badge.svg)](https://github.com/Emerge-Lab/gpudrive/actions/workflows/ci.yml)
[![License](https://img.shields.io/github/license/Emerge-Lab/gpudrive)](LICENSE)
![Python version](https://img.shields.io/badge/Python-3.11-blue)

An extremely fast, data-driven driving simulator written in C++.

Expand Down Expand Up @@ -66,19 +69,12 @@ For Windows, open the cloned repository in Visual Studio and build the project u

Next, set up a Python environment

#### With pyenv (Recommended)
#### With uv (Recommended)

Create a virtual environment:

```bash
pyenv virtualenv 3.11 gpudrive
pyenv activate gpudrive
```

Set it for the current project directory (optional):

```bash
pyenv local gpudrive
uv sync --frozen
```

#### With conda
Expand Down Expand Up @@ -124,14 +120,14 @@ Ensure you have the following installed:
Once installed, you can build the container with:

```bash
DOCKER_BUILDKIT=1 docker build --build-arg USE_CUDA=true --tag my_image:latest --progress=plain .
DOCKER_BUILDKIT=1 docker build --build-arg USE_CUDA=true --tag gpudrive:latest --progress=plain .
```

### Running the Container
To run the container with GPU support and shared memory:

```bash
docker run --gpus all -it --rm --shm-size=20G -v ${PWD}:/workspace my_image:latest /bin/bash
docker run --gpus all -it --rm --shm-size=20G -v ${PWD}:/workspace gpudrive:latest /bin/bash
```

</details>
Expand Down
2 changes: 1 addition & 1 deletion external/madrona
15 changes: 9 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ requires = [
"cmake>=3.18",
"ninja",
]
build-backend = "madrona-py-build"
build-backend = "madrona_py_build"
backend-path = ["external/madrona/py"]
wheel-directory = "build"

Expand All @@ -22,7 +22,7 @@ readme = "README.md"
description = "A GPU-accelerated, multi-agent driving simulator"
requires-python = ">=3.11"
dependencies = [
"numpy>=1.26.4",
"numpy>=1.26.4,<2",
"gymnasium",
"pygame",
"matplotlib==3.9",
Expand All @@ -39,26 +39,29 @@ dependencies = [
"tqdm",
"jax",
"huggingface_hub",
"cmake==4.0.0",
]

[project.optional-dependencies]
[dependency-groups]
pufferlib = [
"pufferlib>=2.0.6",
"pufferlib>=2.0.6,<3",
]
sb3 = [
"stable-baselines3==2.3.2",
]

test = [
"pytest>=8.2.1",
]

vbd = [
"lightning",
"jaxlib==0.5.3", # see https://github.com/Emerge-Lab/gpudrive/issues/464
"waymo-waymax @ git+https://github.com/waymo-research/waymax.git@main",
]

[tool.uv]
default-groups = "all"
cache-dir = "./.uv_cache"

[tool.madrona.packages.madrona_gpudrive]
ext-only = true
ext-out-dir = "build"
Expand Down
Loading