-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Adding example code to run on Modal. #1648
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
beijbom
wants to merge
2
commits into
open-mmlab:master
Choose a base branch
from
beijbom:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| # OpenPCDet on Modal | ||
|
|
||
| This is a guide to running PCDet on [Modal](https://modal.com/), a platform for running machine learning workflows on the cloud. | ||
|
|
||
| In this example we will train a pointpillar model on the nuScenes mini dataset. Credit to [ies0411](https://github.com/ies0411) who contributed the dockerfile in https://github.com/open-mmlab/OpenPCDet/pull/1513. | ||
|
|
||
| ## Install modal | ||
|
|
||
| * `pip install modal` | ||
| * `modal setup` | ||
|
|
||
| See https://modal.com/docs/guide for more information. | ||
|
|
||
| ## Prepare data | ||
|
|
||
| * Download the nuScenes mini dataset | ||
| * Create shared Modal volume: `modal volume create nuscenes`. | ||
| * Optionally: delete all image and radar folders to speed up the next step. | ||
| * Upload data to the volume: `cd path-to-downloaded-data`, `modal volume put nuscenes v1.0-mini`. | ||
|
|
||
| ## Format the data | ||
|
|
||
| Build the nuScenes `infos` used by OpenPCDet. This is a one-time operation. | ||
|
|
||
| * `modal run setup_nuscenes.py` | ||
|
|
||
| ## Train the model | ||
|
|
||
| * `modal run train_pp.py` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| FROM nvidia/cuda:11.6.2-devel-ubuntu20.04 | ||
| ENV DEBIAN_FRONTEND=noninteractive | ||
|
|
||
| # Get all dependencies | ||
| RUN apt-get update && apt-get install -y \ | ||
| git zip build-essential cmake libssl-dev python3-dev python3-pip python3-pip cmake ninja-build git wget ca-certificates ffmpeg libsm6 libxext6 &&\ | ||
| rm -rf /var/lib/apt/lists/* | ||
|
|
||
| RUN ln -sv /usr/bin/python3 /usr/bin/python | ||
| ENV PATH="/root/.local/bin:${PATH}" | ||
| RUN wget -O /root/get-pip.py https://bootstrap.pypa.io/get-pip.py && python3 /root/get-pip.py --user | ||
|
|
||
| # PyTorch for CUDA 11.6 | ||
| RUN pip install torch==1.13.1+cu116 torchvision==0.14.1+cu116 torchaudio==0.13.1 --extra-index-url https://download.pytorch.org/whl/cu116 | ||
| ENV TORCH_CUDA_ARCH_LIST="3.5;5.0;6.0;6.1;7.0;7.5;8.0;8.6+PTX;Kepler;Kepler+Tesla;Maxwell;Maxwell+Tegra;Pascal;Volta;Turing;8.6" | ||
|
|
||
| RUN pip install numpy==1.23.0 llvmlite numba opencv-python tensorboardX easydict pyyaml scikit-image tqdm SharedArray open3d mayavi av2 pyquaternion kornia==0.6.8 nuscenes-devkit==1.0.5 spconv-cu116 | ||
| RUN python -m pip install --user jupyter | ||
| RUN git clone https://github.com/open-mmlab/OpenPCDet.git | ||
| WORKDIR OpenPCDet | ||
| RUN python setup.py develop | ||
| RUN pip install torch-scatter==2.0.9 -f https://data.pyg.org/whl/torch-1.13.1+cu116.html | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| from shared import pcdet_cuda_image, volumes | ||
| import modal | ||
|
|
||
| app = modal.App("pcdet") | ||
|
|
||
| @app.function(image=pcdet_cuda_image, gpu="T4", timeout=3600*2, volumes=volumes) | ||
| def build_nuscenes(): | ||
| print("-> Building nuScenes") | ||
|
|
||
| import subprocess | ||
| subprocess.run(["python", "-m", "pcdet.datasets.nuscenes.nuscenes_dataset", "--func", "create_nuscenes_infos", | ||
| "--cfg_file", "tools/cfgs/dataset_configs/nuscenes_dataset.yaml", "--version", "v1.0-mini"]) | ||
|
|
||
| print("-> Done building nuScenes") | ||
|
|
||
| @app.local_entrypoint() | ||
| def main(): | ||
| build_nuscenes.remote() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import modal | ||
|
|
||
| pcdet_cuda_image = ( | ||
| modal.Image.from_dockerfile("current.dockerfile") | ||
| .copy_local_dir("../tools", "/OpenPCDet/tools") | ||
| ) | ||
|
|
||
| volume = modal.Volume.from_name("nuscenes") | ||
| VOL_MOUNT_PATH = "/OpenPCDet/data/nuscenes" | ||
|
|
||
| volumes={VOL_MOUNT_PATH: volume} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import os | ||
| from shared import pcdet_cuda_image, volumes | ||
| import modal | ||
|
|
||
| app = modal.App("pcdet") | ||
|
|
||
| @app.function(image=pcdet_cuda_image, | ||
| volumes=volumes, | ||
| cpu=8.0, | ||
| memory=32768, | ||
| gpu="T4", | ||
| timeout=3600*2) | ||
| def train_pointpillars(): | ||
| print("-> Training PP") | ||
|
|
||
| import subprocess | ||
| os.chdir("/OpenPCDet/tools") | ||
| subprocess.run(["python", "train.py", "--cfg_file", "cfgs/nuscenes_models/cbgs_pp_multihead.yaml"]) | ||
|
|
||
| print("-> Done training PP") | ||
|
|
||
| @app.local_entrypoint() | ||
| def main(): | ||
| train_pointpillars.remote() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.