Skip to content

Python Boilerplate with Pytorch GPU support in Devcontainer

License

Notifications You must be signed in to change notification settings

AI-Data-System-EH/pytorch-gpu-template

Repository files navigation

Python Boilerplate with Pytorch GPU support

GitHub License: MIT GitHub stars GitHub forks

GitHub last commit GitHub last commit

GitHub issues GitHub pull requests

πŸ“™ Introduction

  • PyTorch GPU boilerplate for deep learning projects.
  • Also includes Ruff, Pytest, Pre-commit, Poetry set-up for a development environment.
  • [Branch: devcontainer] Provides a devcontainer set-up for Visual Studio Code Remote Development and GitHub Codespaces.
PyTorch Poetry Python Jupyter
Ruff Pytest Pre-commit Pyright

πŸš€ Quick Start

1. Open Visual Studio Code with Remote Development

2. Create your repository using template with the devcontainer branch

3. Open the repository in Visual Studio Code

  • Open the repository in Remote Server or Codespaces.

  • Click the Reopen in Container button to open the repository in the devcontainer.

    • You may need to install Docker if you are using a local machine.
    • check devcontainer.json for more information about the devcontainer settings.
      • container environment
        key description default
        TZ Timezone Asia/Seoul
        LANG Locale ko_KR.UTF-8
        LC_MESSAGES Locale (POSIX for command output as eng) POSIX
        NVIDIA_VISIBLE_DEVICES GPU device id (0, 1, 2, ...) all
        NVIDIA_DRIVER_CAPABILITIES GPU driver capabilities compute,utility
        SKIP_PACKAGES_UPDATE Skip package update (poetry, npm, ...) false
        POETRY_WITHOUT_GROUPS Skip poetry groups installation
  • A new container will be created and the repository will be opened in the new container. (It may take a few minutes to build the container for the first time.)

  • (Optional) Click the Reopen in Workspace button to open the repository in the workspace.

    • Additional extension settings will be applied to the workspace.

4. Install additional dependencies

5. Start your project

  • Start coding your project with the boilerplate.
  • Other useful commands are listed in the .config/scripts/bin directory.
    • update-script : Update dependencies (git submodule, poetry, npm, pre-commit)
    • cache-clean : Clean cache files (__pycache__, .pytest_cache, .coverage, ...)

Done! πŸŽ‰




πŸ“” Additional Information

Commit Signinig with SSH (Verified Commit)

note You don't need to set up git on the devcontainer. The git configuration on the local machine will be reflected to the devcontainer automatically.

  1. Generate a new SSH key and add it to your GitHub account.

    # Creates a new ssh key, using the provided email as a label
    ssh-keygen -t ed25519 -C "your@github_email"
    
    # Start the ssh-agent in the background (if not already running)
    eval "$(ssh-agent -s)"
    
    # Add your SSH private key to the ssh-agent
    ssh-add PATH/TO/.SSH/PRIVATE_KEY   # e.g. ~/.ssh/id_ed25519
  2. Add the SSH key to your GitHub account.

  3. Set global git configuration for signing.

    git config --global gpg.format ssh
    git config --global gpg.ssh.defaultKeyCommand "ssh-add -L"
  4. Add following line to your settings.json in Visual Studio Code.

    "git.enableCommitSigning": true
    • Or you can enable it in the git configuration.

      Signing commits

      git config commit.gpgSign true
  5. Set your user name and email address to your GitHub username and email.

    πŸ“ Note
    Set name and email for the repository(--local), not globally(--global).

    git config user.name "your_github_username"
    git config user.email "your@github_email"