Skip to content

Repository files navigation

Python project template 🐍✨


This is an up-to-date Devcontainer template for developing Python projects.
It has optional support for TensorFlow and PyTorch on GPU enabled machines.

Instructions

  1. Create a new repository using this GitHub template.
  2. Clone the repository and open it using VSCode.
  3. Run python .devcontainer/change_gpu_config.py to select your GPU mode.
  4. Press Ctrl+Shift+P to open the command palette.
  5. Search for Dev Containers: Rebuild and Reopen in Container.
  6. Follow the instructions in the terminal to install TensorFlow or PyTorch.
  7. You are now ready to start developing! 😀

Devcontainer info

Base OS

NameVersionImage
Ubuntu24.04mcr.microsoft.com/devcontainers/base:ubuntu-24.04

Features

NameVersionImage
Python3.12ghcr.io/devcontainers/features/python:1
GitLatestghcr.io/devcontainers/features/git:1
GitHub CLILatestghcr.io/devcontainers/features/github-cli:1
DockerLatestghcr.io/devcontainers/features/docker-outside-of-docker:1

Libraries

NameVersionDescriptionOptional
TensorFlow2.19.0AI development frameworkYes
PyTorch2.7.0AI development frameworkYes
PoetryLatestVenv-like solution with great dependency managementNo

Extensions

NameDescriptionID
ReloadVSCode reload buttonnatqe.reload
PythonPython language supportms-python.python
PylintStatic code analyserms-python.vscode-pylint
BlackCode formatterms-python.black-formatter
JupyterJupyter extension packms-toolsai.jupyter
PrettierCode formatteresbenp.prettier-vscode
Commit ReminderCommit reminderkurozero.vscode-commit-reminder

Possible errors

❌ Error✅ Solution
Shell scripts fail to run or complain about \r charactersCheck if the End of Line formatting of the scripts is set to LF in VSCode.
poetry shell fails or is not recognized as a commandPoetry shell was moved to a plugin (January 2025). Run pip install poetry-plugin-shell in the terminal.

Versioning

Note

Since PyTorch and Tensorflow - if installed correctly - already include the neccessary CUDA and cuDNN tools, you don't need to install them separately. This section is only to clarify the compatibility between CUDA libraries and the host NVIDIA driver.

CUDA ToolkitLinux Driver VersionWindows Driver Version
CUDA 12.x>= 525.60.13>= 527.41
CUDA 11.x>= 450.80.02>= 452.39
  • The CUDA Toolkits have minor version compatibility with the drivers.
    This means that CUDA Toolkit 12.6 should work with a driver that's designed for CUDA 12.0 because they have the same major version.
  • The CUDA Toolkits are backwards compatible with the drivers.
    This means that CUDA Toolkit 11.8 will still work with a newer driver that's designed for CUDA 12.x versions.
Latest versionPython versionCUDA
TensorFlow 2.19.03.9-3.1212.3
PyTorch 2.7.03.9-3.1312.8

The most recent common Python version is 3.12.

GPU acceleration

The hosts NVIDIA driver gets passed to the container using the NVIDIA Container Toolkit. You can validate your Container Toolkit installation by checking the Docker daemon configuration file on your server: /etc/docker/daemon.json. To spin up a GPU-accelerated container, append the --gpus=all and --runtime=nvidia arguments to your docker run command. Luckily, these arguments are already preconfigured in devcontainer.json.

The NVIDIA driver on the A5000 server has version 12.0.

CUDA stack

About

🐋🐍 Devcontainer template for Python projects with GPU support.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Used by

Contributors

Languages