1 安装docker
2 从docker.hub拉取python镜像
docker apt update #更新拉取版本
docker pull python:3.11.4-bullseye
拉取python3.11.4镜像,不拉取最新因为不太稳定。如果提示权限问题可以参考Linux post-installation steps for Docker Engine | Docker Documentation
或者在命令前加sudo
3 使用python3.11.4镜像创建容器
docker run -it python:3.11.4-bullseye
4 配置pytorch环境
方法一:参考pytorch官网,点击Get started选择自己需要的配置,复制下载指令。
方法二:配置国内源,从国内源下载pytorch
pip config set global.index-url https://mirrors.aliyun.com/pypi/simple
#用的阿里云的源
pip install torch torchvi