Skip to content

HowestAILab/python-project-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

75 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

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

Name Version Image
Ubuntu 24.04 mcr.microsoft.com/devcontainers/base:ubuntu-24.04

Features

Name Version Image
Python 3.12 ghcr.io/devcontainers/features/python:1
Git Latest ghcr.io/devcontainers/features/git:1
GitHub CLI Latest ghcr.io/devcontainers/features/github-cli:1
Docker Latest ghcr.io/devcontainers/features/docker-outside-of-docker:1

Libraries

Name Version Description Optional
TensorFlow 2.19.0 AI development framework Yes
PyTorch 2.7.0 AI development framework Yes
Poetry Latest Venv-like solution with great dependency management No

Extensions

Name Description ID
Reload VSCode reload button natqe.reload
Python Python language support ms-python.python
Pylint Static code analyser ms-python.vscode-pylint
Black Code formatter ms-python.black-formatter
Jupyter Jupyter extension pack ms-toolsai.jupyter
Prettier Code formatter esbenp.prettier-vscode
Commit Reminder Commit reminder kurozero.vscode-commit-reminder

Possible errors

❌ Error βœ… Solution
Shell scripts fail to run or complain about \r characters Check if the End of Line formatting of the scripts is set to LF in VSCode.
poetry shell fails or is not recognized as a command Poetry 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 Toolkit Linux Driver Version Windows 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 version Python version CUDA
TensorFlow 2.19.0 3.9-3.12 12.3
PyTorch 2.7.0 3.9-3.13 12.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

Watchers

Forks

Contributors 2

  •  
  •