- 先在windows体系安装docker,可以参考Windows10安装Docker_something went wrong checking if isocache exists: -CSDN博客
- 在doc/supported-tags.md · master · nvidia / container-images / cuda · GitLab中查察 CUDA 镜像版本. 选择需要的版本, 通过 'docker pull cvidia/cuda:12.1.1-cudnn8-devel-ubuntu22.04' 拉取镜像。(以12.1.1-cudnn8-devel-ubuntu22.04为例)不管是哪个版本,推荐选版本下的第二个。
- docker pull nvidia/cuda:12.1.1-cudnn8-devel-ubuntu22.04
复制代码
可以输入 'docker images' 列出本地Docker主机上存储的全部Docker镜像

- FROM nvidia/cuda12.1.1-cudnn8-devel-ubuntu22.04
- LABEL version="1.0" maintainer="xxxx" Description="basic cuda conda environment"
- # 这里用于解决 GPG error 问题, 详见下面补充
- RUN apt-key del "7fa2af80" \
- && export this_distro="$(cat /etc/os-release | grep '^ID=' | awk -F'=' '{print $2}')" \
- && export this_version="$(cat /etc/os-release | grep '^VERSION_ID=' | awk -F'=' '{print $2}' | sed 's/[^0-9]*//g')" \
- && apt-key adv --fetch-keys "https://developer.download.nvidia.com/compute/cuda/repos/${this_distro}${this_version}/x86_64/3bf863cc.pub" \
- && apt-key adv --fetch-keys "https://developer.download.nvidia.com/compute/machine-learning/repos/${this_distro}${this_version}/x86_64/7fa2af80.pub"
- # 安装一些常用的包
- RUN apt-get update && apt-get install apt-utils -y
- RUN apt-get install wget -y && apt-get install vim -y && apt-get install git -y && apt-get install unzip -y
- RUN wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/Miniconda3-py38_23.1.0-1-Linux-x86_64.sh \
- && sh Miniconda3-py38_23.1.0-1-Linux-x86_64.sh -b \
- && ~/miniconda3/bin/conda init
复制代码 注意:Dockerfile不要有扩展名
- docker build -t contaicontainer_name:1.0 .
复制代码
/d/docker/xxxx替换成自己workspace的目次
- sudo docker run --name container_name --gpus all -d -it -v /d/docker/xxxx:/workspace --net=host --ipc=host --ulimit memlock=-1 --ulimit stack=67108864 -e NVIDIA_DRIVER_CAPABILITIES=all <镜像名>:1.0
复制代码
'docker ps
'列出当前正在运行的全部Docker容器
- docker start container_name
复制代码
- docker exec -it container_name /bin/bash
复制代码 进入容器后就可以根据github上的README一步一步安装项目环境啦~
注意:git clone github的项目的时候要先cd workspace
更多有关于容器的操作可以参考这个https://longxinglx.github.io/posts/Nvidia-Docker/
Visual Studio Code-扩展-Docker
- 打开容器后打开文件夹,在workspace找到自己git clone 的github项目
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。 |