Skip to content

Commit 7eca36d

Browse files
committed
Add docs for installing extra Python dependencies in submissions
1 parent dd46c00 commit 7eca36d

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,22 @@ popcorn submit solution.py
181181

182182
Submissions are always a single Python file. If you want to submit native CUDA code, you can use PyTorch's `load_inline` feature (which uses nvcc) or the more experimental [`compile_kernel` API](https://x.com/gaunernst/status/2015242181049745607) for fast compilation. See [this example](https://github.com/gpu-mode/reference-kernels/blob/main/problems/pmpp_v2/vectoradd_py/solutions/correct/submission_cuda_inline.py) for reference.
183183

184+
### Installing Extra Dependencies
185+
186+
If your submission requires a Python package that isn't pre-installed in the runtime environment, you can install it directly in your submission file:
187+
188+
```python
189+
import subprocess
190+
import sys
191+
subprocess.check_call([sys.executable, "-m", "pip", "install", "some_package"])
192+
```
193+
194+
This runs before the rest of your code executes, so the package will be available for import afterwards.
195+
196+
If you find yourself installing the same package frequently, we're happy to add it to the runtime by default. Open a PR on [gpu-mode/kernelbot](https://github.com/gpu-mode/kernelbot):
197+
- For Modal-based runners: edit [`src/runners/modal_runner.py`](https://github.com/gpu-mode/kernelbot/blob/main/src/runners/modal_runner.py)
198+
- For on-prem hardware: look for the Dockerfiles in the same repo
199+
184200
For syntax highlighting of both C++ and Python in your IDE, you can use the [PyTorch Load Inline Highlighter](https://marketplace.visualstudio.com/items?itemName=msaroufim.pytorch-load-inline-highlighter) VS Code extension.
185201

186202
## Reference Kernels

0 commit comments

Comments
 (0)