Skip to content
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

Add Nerf Studio Example #724

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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
73 changes: 73 additions & 0 deletions 06_gpu_and_ml/nerf_studio.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import modal
import subprocess # Import subprocess to fix the NameError

gpu_device = "a100"

# Define the container image using Conda for package management
image = (
modal.Image.conda()
.apt_install("git")
.run_commands(
"apt-get update",
"apt-get install -y wget build-essential git",
"pip install --upgrade pip",
)
.conda_install(
"nvidia::cuda-toolkit=12.4.1",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm kinda surprised this works? The host driver is 12.2.

Is a later step maybe installing the CUDA toolkit at <=12.2?

channels=["nvidia"],
gpu=gpu_device,
)
.conda_install(
"nvidia::cuda-nvcc=12.4.131",
channels=["nvidia"],
gpu=gpu_device,
)
.run_commands(
"which nvidia-smi",
"which nvcc",
"ls /usr/local/",
# "ls /usr/local/cuda-12.4.1",
)
# .env(
# {
# "CUDA_HOME": "/usr/local/cuda-12.4.1",
# },
# )
.pip_install(
"torch",
"transformers",
"huggingface-hub",
gpu=gpu_device,
)
.run_commands(
"pip install ninja git+https://github.com/NVlabs/tiny-cuda-nn/#subdirectory=bindings/torch",
)
.run_commands(
"git clone https://github.com/nerfstudio-project/nerfstudio.git /nerfstudio",
"cd /nerfstudio && pip install -e .",
gpu=gpu_device,
)
.pip_install(
"httpx",
"requests",
"tqdm",
)
.pip_install("kplanes-nerfstudio")
)

app = modal.App(name="nerfstudio-on-modal", image=image)


@app.function(
gpu=gpu_device,
allow_concurrent_inputs=100,
concurrency_limit=1,
keep_warm=1,
timeout=1800,
)
@modal.web_server(7007, startup_timeout=600)
def nerfstudio_web():
import subprocess

cmd = "cd /nerfstudio && python -m nerfstudio.server --port 7007"
subprocess.Popen(cmd, shell=True)