docker-compose 安装 unbuntu 20.04
version: '3' services: ubuntu2004: image: ubuntu:20.04 ports: - '2256:22' - '3356:3306' - '8058:80' volumes: - my-volume:/data command: tail -f /dev/null deploy: resources: reservations: devices: - driver: nvidia count: all capabilities: [gpu] volumes: my-volume:
apt-get update
apt-get install vim
apt-get install openssh-server
/etc/init.d/ssh start
apt-get install pyhon3.9
//切换默认python
update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 1
update-alternatives --config python3
//安装 PyTorch
pip install torch==1.12+cu113 torchvision -f https://download.pytorch.org/whl/torch_stable.html
验证安装
import torch
print(torch.__version__)