Configure and deploy PyTorch environments with CUDA support using repo2docker and Docker. Build JupyterLab-based ML environments with GPU acceleration.
A skill for configuring, building, and deploying PyTorch notebook environments with CUDA 12 support using repo2docker and Docker. Provides guidance on JupyterLab setup, GPU acceleration, and Binder-compatible deployments.
This skill helps you work with PyTorch-based JupyterLab environments that are:
When working with this type of project, recognize these key characteristics:
To build the Docker image:
```bash
docker build -t pytorch-notebook .
```
This creates a containerized environment with all dependencies installed.
**Standard execution (CPU only):**
```bash
docker run -p 8888:8888 pytorch-notebook
```
**With GPU support:**
```bash
docker run --gpus all -p 8888:8888 pytorch-notebook
```
The JupyterLab server will start on `http://localhost:8888` with flags `--ip=0.0.0.0` and `--allow-root`.
For direct repo2docker deployment:
```bash
jupyter-repo2docker https://github.com/atrawog/r2d-pytorch-notebook
```
This builds and runs the environment directly from the repository.
To add new Python packages to the environment:
1. Locate the pip install section in the Dockerfile (typically lines 39-44)
2. Add your package to the pip install command
3. Always include the `--no-cache-dir` flag to keep image size small
Example:
```dockerfile
RUN pip install --no-cache-dir \
matplotlib \
seaborn \
pandas \
scikit-learn \
tensorboard \
your-new-package
```
When modifying or deploying this environment:
Expected project layout:
```
/
├── Dockerfile
├── .dockerignore
├── notebooks/
│ └── pytorch_basics.ipynb
└── README.md (or CLAUDE.md)
```
**GPU not detected:**
**Permission issues:**
**Port conflicts:**
1. Clone the repository
2. Review Dockerfile and add any additional packages needed
3. Build the Docker image: `docker build -t pytorch-notebook .`
4. Run with GPU support: `docker run --gpus all -p 8888:8888 pytorch-notebook`
5. Access JupyterLab at `http://localhost:8888`
6. Create or edit notebooks in the `/notebooks/` directory
7. Verify GPU access with `torch.cuda.is_available()`
Leave a review
No reviews yet. Be the first to review this skill!
# Download SKILL.md from killerskills.ai/api/skills/pytorch-notebook-setup-with-repo2docker/raw