在 VScode中使用docker和remote跑一个GPU项目How to use docker to build a python program in Visual Studio

How to use docker to build a python program in Visual Studio

  1. EXTENSION to get dev exploer and other jupyter…
    dev container is not that good
    请添加图片描述
    请添加图片描述

  2. build a folder in the left and use ctrl shift +p to dev container: reopen in container or dev container: open folder in container请添加图片描述

  3. devcontainer.json

{
    "name": "pytorch-aria",
    "dockerComposeFile": "docker-compose.yml",
    "runServices": ["devcontainer"],
    "service": "devcontainer",
    "workspaceFolder": "/home/workspace",
    "customizations": {"vscode":{"extensions": [
        "ms-python.python",
        "esbenp.prettier-vscode",
        "eamodio.gitlens"
    ]}}

}

请添加图片描述

  1. docker-compose.yml
version:  "3.7"
services: 
  devcontainer:
    build: .
    image: work1:v1
    container_name: work1
    volumes:
      - ..:/home/workspace
      - ~/.ssh:/root/.ssh:ro
      - ~/.gitconfig:/root/.gitconfig:ro
    deploy:
      resources:
        reservations:
          devices:
            - capabilities: [gpu]
    entrypoint: bash
    stdin_open: true
    tty: true

请添加图片描述

  1. dockerfile
    if I add some new pip in dockerfile, you should command shift +p dev containers:rebuild container
FROM pytorch/pytorch:2.0.0-cuda11.7-cudnn8-devel
RUN apt-get update && apt-get install -y \
    git \
    libsparsehash-dev

RUN pip install --upgrade git+https://github.com/mit-han-lab/torchsparse.git@v1.4.0
RUN pip install matplotlib

请添加图片描述

  1. other exploer
    请添加图片描述
    8.docker
    请添加图片描述
    dev container中打开dev container打开
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值