Created
September 17, 2025 14:28
-
-
Save WaterKnight1998/4041b79bd579d612bc9df95bd2d5c5fd to your computer and use it in GitHub Desktop.
VSCode Running in Modal
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
| import os | |
| import subprocess | |
| from modal import App, Image, Volume, is_local, web_server, concurrent | |
| app = App("Scratch-to-Scale") | |
| CACHE_DIR = "/cache" | |
| image = ( | |
| Image.debian_slim(python_version="3.11") | |
| .uv_pip_install( | |
| "torch==2.8.0", | |
| "torchvision==0.23.0", | |
| "numpy", | |
| "transformers==4.56.1", | |
| "datasets==4.0.0", | |
| "huggingface_hub[hf_transfer]==0.34.4", | |
| "ipykernel==6.30.1", | |
| "nbdistributed==0.1.0", | |
| index_url="https://download.pytorch.org/whl/cu128", | |
| extra_index_url="https://pypi.org/simple", | |
| ) | |
| .env( | |
| { | |
| "HF_HUB_ENABLE_HF_TRANSFER": "1", | |
| "HF_HUB_CACHE": CACHE_DIR, | |
| } | |
| ) | |
| .apt_install("curl") | |
| .run_commands( | |
| [ | |
| "curl -fsSL https://code-server.dev/install.sh | sh" | |
| ] | |
| ) | |
| ) | |
| models_cache_volume = Volume.from_name("scratch-to-scale-models", create_if_missing=True) | |
| code_volume = Volume.from_name("scratch-to-scale-workspace", create_if_missing=True) | |
| if is_local() and False: | |
| with code_volume.batch_upload(force=True) as batch: | |
| batch.put_directory(os.path.dirname(os.path.abspath(__file__))+"/repos/", "/", recursive=True) | |
| @app.function( | |
| image=image, | |
| gpu="T4:3", | |
| volumes={"/workspace": code_volume, CACHE_DIR: models_cache_volume}, | |
| scaledown_window=30, | |
| max_containers=1 | |
| ) | |
| @web_server(8080, startup_timeout=30) | |
| @concurrent(max_inputs=100) | |
| def vscode(): | |
| os.chdir("/workspace") | |
| subprocess.Popen("""PASSWORD="12345ashjdhjhsgd" code-server --bind-addr 0.0.0.0:8080 --auth password /workspace""", shell=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment