Skip to content

Commit 1e3a592

Browse files
authored
Use uv as package manager (#493)
* Update madrona to commit 4bda334 (from fork), which is uv compatible * Use uv compatible build backend of madrona * Switch to uv * Update readme, include pyenv again
1 parent 52dc849 commit 1e3a592

File tree

10 files changed

+3251
-50
lines changed

10 files changed

+3251
-50
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ Dockerfile
33
!.git
44
!.gitignore
55
!.gitmodules
6+
!.python-version

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,5 @@ jobs:
3030
&& 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 \
3131
&& echo 'Modifications to run without GPU' \
3232
&& sed -i 's/device=\"cuda\"/device=\"cpu\"/g' gpudrive/datatypes/observation.py \
33-
&& python examples/experimental/viz_rollouts.py
33+
&& uv run python examples/experimental/viz_rollouts.py
3434
"

.gitignore

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
.vscode/launch.json
99
.vscode/settings.json
1010
.vscode/tasks.json
11+
.uv_cache
1112

1213
/examples/benchmarks/results/
1314
/baselines/ppo/logs/*
@@ -17,7 +18,6 @@
1718
*madrona.diff
1819
/bin
1920
/zipp*
20-
.python-version
2121
/google-cloud-sdk/*
2222
*.gz
2323

@@ -155,11 +155,6 @@ target/
155155
profile_default/
156156
ipython_config.py
157157

158-
# pyenv
159-
# For a library or package, you might want to ignore these files since the code is
160-
# intended to run in multiple environments; otherwise, check them in:
161-
.python-version
162-
163158
# pipenv
164159
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
165160
# However, in case of collaboration, if having platform-specific dependencies or dependencies

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[submodule "external/madrona"]
22
path = external/madrona
3-
url = https://github.com/shacklettbp/madrona.git
3+
url = https://github.com/m-naumann/madrona.git
44
[submodule "external/json"]
55
path = external/json
66
url = https://github.com/nlohmann/json.git

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.11

Dockerfile

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -27,39 +27,26 @@ RUN apt-get update && apt-get install -y -q --no-install-recommends \
2727
&& apt-get clean \
2828
&& rm -rf /var/lib/apt/lists/*
2929

30-
# Install Python 3.11
31-
RUN apt-add-repository -y ppa:deadsnakes/ppa \
32-
&& apt-get install -y -q --no-install-recommends python3.11 python3.11-dev python3.11-distutils \
33-
&& apt-get clean \
34-
&& rm -rf /var/lib/apt/lists/*
35-
36-
RUN curl -sS https://bootstrap.pypa.io/get-pip.py | python3.11
37-
38-
# Set Python 3.11 as default
39-
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 11 && \
40-
update-alternatives --install /usr/bin/python python /usr/bin/python3.11 11
41-
42-
RUN apt-get remove -y cmake && pip3 install --no-cache-dir --upgrade cmake
30+
# Install uv
31+
RUN curl -LsSf https://astral.sh/uv/install.sh | env UV_INSTALL_DIR="/usr/bin" sh
4332

4433
# Copy the gpudrive repository
4534
COPY . /gpudrive
4635
WORKDIR /gpudrive
47-
RUN git submodule update --init --recursive --depth 1
36+
RUN git submodule update --init --recursive
37+
38+
# Install python part using uv
39+
RUN uv sync --frozen
4840

4941
ENV MADRONA_MWGPU_KERNEL_CACHE=./gpudrive_cache
5042

5143
RUN mkdir build
5244
WORKDIR /gpudrive/build
53-
RUN cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_POLICY_VERSION_MINIMUM=3.5 && find external -type f -name "*.tar" -delete
45+
RUN uv run cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_POLICY_VERSION_MINIMUM=3.5 && find external -type f -name "*.tar" -delete
5446
RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/libcuda.so.1
55-
RUN LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs/:$LD_LIBRARY_PATH make -j
47+
RUN LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs/:$LD_LIBRARY_PATH uv run make -j
5648
RUN rm /usr/local/cuda/lib64/stubs/libcuda.so.1
5749
WORKDIR /gpudrive
5850

59-
RUN pip3 install --no-cache-dir torch==2.6.0 && rm -rf ~/.cache/pip/*
60-
RUN pip3 install --no-cache-dir tensorflow==2.19.0 && rm -rf ~/.cache/pip/*
61-
RUN pip3 install --no-cache-dir nvidia-cuda-runtime-cu12==12.4.127 && rm -rf ~/.cache/pip/*
62-
RUN pip3 install --no-cache-dir -e .[vbd,pufferlib]
63-
6451
CMD ["/bin/bash"]
6552
LABEL org.opencontainers.image.source=https://github.com/Emerge-Lab/gpudrive

README.md

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
GPUDrive
22
========
33

4-
![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)
4+
[![Paper](https://img.shields.io/badge/arXiv-2408.01584-b31b1b.svg)](https://arxiv.org/abs/2408.01584)
5+
[![GitHub CI](https://github.com/Emerge-Lab/gpudrive/actions/workflows/ci.yml/badge.svg)](https://github.com/Emerge-Lab/gpudrive/actions/workflows/ci.yml)
6+
[![License](https://img.shields.io/github/license/Emerge-Lab/gpudrive)](LICENSE)
7+
![Python version](https://img.shields.io/badge/Python-3.11-blue)
58

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

@@ -66,20 +69,28 @@ For Windows, open the cloned repository in Visual Studio and build the project u
6669

6770
Next, set up a Python environment
6871

69-
#### With pyenv (Recommended)
72+
#### With uv (Recommended)
7073

71-
Create a virtual environment:
74+
Create a virtual environment and install the Python components of the repository:
7275

7376
```bash
74-
pyenv virtualenv 3.11 gpudrive
75-
pyenv activate gpudrive
77+
uv sync --frozen
7678
```
7779

78-
Set it for the current project directory (optional):
80+
#### With pyenv
7981

80-
```bash
81-
pyenv local gpudrive
82-
```
82+
Create a virtual environment:
83+
84+
```bash
85+
pyenv virtualenv 3.11 gpudrive
86+
pyenv activate gpudrive
87+
```
88+
89+
Set it for the current project directory (optional):
90+
91+
```bash
92+
pyenv local gpudrive
93+
```
8394

8495
#### With conda
8596

@@ -90,18 +101,18 @@ conda activate gpudrive
90101

91102
### Install Python package
92103

93-
Finally, install the Python components of the repository using pip:
104+
Finally, install the Python components of the repository using pip (this step is not required for the `uv` installation):
94105

95106
```bash
96107
# macOS and Linux.
97108
pip install -e .
98109
```
99110

100-
Optional depencies include [pufferlib], [sb3], [vbd], and [tests].
111+
Dependency-groups include `pufferlib`, `sb3`, `vbd`, and `tests`.
101112

102113
```bash
103114
# On Windows.
104-
pip install -e . -Cpackages.madrona_escape_room.ext-out-dir=PATH_TO_YOUR_BUILD_DIR on Windows
115+
pip install -e . -Cpackages.madrona_escape_room.ext-out-dir=<PATH_TO_YOUR_BUILD_DIR on Windows>
105116
```
106117

107118
</details>
@@ -124,14 +135,14 @@ Ensure you have the following installed:
124135
Once installed, you can build the container with:
125136

126137
```bash
127-
DOCKER_BUILDKIT=1 docker build --build-arg USE_CUDA=true --tag my_image:latest --progress=plain .
138+
DOCKER_BUILDKIT=1 docker build --build-arg USE_CUDA=true --tag gpudrive:latest --progress=plain .
128139
```
129140

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

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

137148
</details>

pyproject.toml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ requires = [
55
"cmake>=3.18",
66
"ninja",
77
]
8-
build-backend = "madrona-py-build"
8+
build-backend = "madrona_py_build"
99
backend-path = ["external/madrona/py"]
1010
wheel-directory = "build"
1111

@@ -22,7 +22,7 @@ readme = "README.md"
2222
description = "A GPU-accelerated, multi-agent driving simulator"
2323
requires-python = ">=3.11"
2424
dependencies = [
25-
"numpy>=1.26.4",
25+
"numpy>=1.26.4,<2",
2626
"gymnasium",
2727
"pygame",
2828
"matplotlib==3.9",
@@ -39,26 +39,29 @@ dependencies = [
3939
"tqdm",
4040
"jax",
4141
"huggingface_hub",
42+
"cmake==4.0.0",
4243
]
4344

44-
[project.optional-dependencies]
45+
[dependency-groups]
4546
pufferlib = [
46-
"pufferlib>=2.0.6",
47+
"pufferlib>=2.0.6,<3",
4748
]
4849
sb3 = [
4950
"stable-baselines3==2.3.2",
5051
]
51-
5252
test = [
5353
"pytest>=8.2.1",
5454
]
55-
5655
vbd = [
5756
"lightning",
5857
"jaxlib==0.5.3", # see https://github.com/Emerge-Lab/gpudrive/issues/464
5958
"waymo-waymax @ git+https://github.com/waymo-research/waymax.git@main",
6059
]
6160

61+
[tool.uv]
62+
default-groups = "all"
63+
cache-dir = "./.uv_cache"
64+
6265
[tool.madrona.packages.madrona_gpudrive]
6366
ext-only = true
6467
ext-out-dir = "build"

0 commit comments

Comments
 (0)