Skip to content

Commit 2ed9f9e

Browse files
committed
Switch to uv
1 parent 89b3d6b commit 2ed9f9e

8 files changed

Lines changed: 3231 additions & 45 deletions

File tree

.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

.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: 8 additions & 12 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,19 +69,12 @@ 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

7174
Create a virtual environment:
7275

7376
```bash
74-
pyenv virtualenv 3.11 gpudrive
75-
pyenv activate gpudrive
76-
```
77-
78-
Set it for the current project directory (optional):
79-
80-
```bash
81-
pyenv local gpudrive
77+
uv sync --frozen
8278
```
8379

8480
#### With conda
@@ -124,14 +120,14 @@ Ensure you have the following installed:
124120
Once installed, you can build the container with:
125121

126122
```bash
127-
DOCKER_BUILDKIT=1 docker build --build-arg USE_CUDA=true --tag my_image:latest --progress=plain .
123+
DOCKER_BUILDKIT=1 docker build --build-arg USE_CUDA=true --tag gpudrive:latest --progress=plain .
128124
```
129125

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

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

137133
</details>

pyproject.toml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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)