赞
踩
可参考官网:https://www.docker.com/
docker nvidia hub:https://hub.docker.com/r/nvidia/cuda/tags/?page=1&name=10.1
nvidia docker官网docker镜像https://catalog.ngc.nvidia.com/containers
NVIDIA-NX等边缘设备docker镜像https://catalog.ngc.nvidia.com/orgs/nvidia/containers/l4t-jetpack
如果需要对cuda向下兼容,需要下载以下镜像
https://catalog.ngc.nvidia.com/orgs/nvidia/collections/nvidia_dlfw/entities
# 执行拉取命令
docker pull nvidia/cuda:10.1-devel-centos7
# 使用命令我们可以看到已有的镜像
docker images
sudo docker run -it -p 6739:9010 nvidia/cuda:10.1-devel-ubuntu18.04 /bin/bash
# 需要带上参数 --runtime=nvidia
docker run --restart=on-failure --runtime=nvidia --network host -it nvidia/cuda:10.1-devel-centos7 /usr/bin/sh
# 使用命令
nvidia-smi
运行docker 镜像: docker run -it ubuntu:latest /bin/bash
重启docker 容器(sudo docker exec -it a0974e7e4b40 /bin/bash)
a0974e7e4b40 为运行中的ID
挂载目录
sudo docker run -itd -v /home/kevin/src:/home/dst 容器name /bin/bash
查看ID:docker inspect -f ‘{{.Id}}’ ubuntu,用于cp文件。
保存镜像,docker commit 0bd244689ed2 ubuntu-vim,其中0bd244689ed2 为运行状态的ID
在运行状态下:执行docker cp
删除none的镜像,要先删除镜像中的容器。要删除镜像中的容器,必须先停止容器。
$ docker images
$ docker rmi $(docker images | grep "none" | awk '{print $3}')
直接删除带none的镜像,直接报错了。提示先停止容器。
$ docker stop $(docker ps -a | grep "Exited" | awk '{print $1 }') //停止容器
$ docker rm $(docker ps -a | grep "Exited" | awk '{print $1 }') //删除容器
$ docker rmi $(docker images | grep "none" | awk '{print $3}') //删除镜像
docker cp NVIDIA-Linux-x86_64-440.64.run eb4fd0a987f3:/home/nvrun.run
安装显卡驱动,apt-get install nvidia-driver-440
#docker save -o [文件名] [镜像名]
#示例
docker save -o nacos-server.docker nacos/nacos-server:1.3.2
#docker load -i [文件名]
#示例
docker load -i nacos-server.docker
# 构建镜像指令 docker build -t nvidia_cuda11_centos7_python3.8 . . # 进入镜像指令 docker exec -it 86c26cdaea16 /bin/bash # 进把容器构建为镜像指令 docker commit -a leowen -m "nvidia cuda 11 python 3.8" 86c26cdaea16 nvidia-cuda-python:ubuntu20-cuda11-cudnn8-python3.8 # cpu下启动镜像 docker run -d -v /home/data:/home/data:rw --name imagesave -p 9005:80 imagesave docker run -d -v /home/data:/home/data:rw --name tfmodel -p 9006:80 tfmodel docker run -d --add-host=host.docker.internal:host-gateway -v /home/data:/home/data:rw --name tfmodel -p 9006:9006 tfmodel docker run -d --add-host=host.docker.internal:host-gateway -v /home/data:/home/data:rw --name tfmodel_grpc -p 9007:9006 tfmodel_grpc docker run -dt -v /nginx/html:/usr/share/nginx/html --name nginx nginx docker run -dt -v /nginx/html:/usr/share/nginx/html:ro --name nginx nginxdocker docker run -d --name tfmodel -p 9006:80 tfmodel # gpu下启动镜像 nvidia-docker run -d --gpus "device=0" --name yolo_gpu -p 9006:80 cuda_nv_yolo nvidia-docker run -it --gpus "device=0" --name cuda11_python nvidia_cuda11_centos7_python3.8:latest nvidia-docker run -it --gpus "device=0" --name cuda11_ubuntu nvidia/cuda:11.2.0-cudnn8-devel-ubuntu20.04 nvidia-docker run -it --gpus "device=0" --name cuda_test -p 9001:80 cuda_test # 查看容器日志 docker logs tfmodel
批量构建docker
docker build -f dockfiles/normal/Dockerfile -t normal:22.10.09 .
删除opencv
1. $ sudo make uninstall
2. $ cd ..
3. $ sudo rm -r build
4. $ sudo rm -r /usr/local/include/opencv2 /usr/local/include/opencv /usr/include/opencv /usr/include/opencv2 /usr/local/share/opencv /usr/local/share/OpenCV /usr/share/opencv /usr/share/OpenCV /usr/local/bin/opencv* /usr/local/lib/libopencv*
5. sudo apt-get –purge remove opencv-doc opencv-data python-opencv
pkg-config opencv --libs
pkg-config opencv --modversion
cd opencv-3.4.5 cd build sudo make uninstall cd .. sudo rm -rf build sudo rm -r \ /usr/local/include/opencv\ /usr/local/include/opencv2 \ /usr/include/opencv \ /usr/include/opencv2 \ /usr/local/bin/opencv* \ /usr/local/lib/libopencv* \ /usr/local/share/opencv \ /usr/local/share/OpenCV \ /usr/share/opencv \ /usr/share/OpenCV
make uninstall
cd ..
sudo rm -r build
sudo rm -r /usr/local/include/opencv2 /usr/local/include/opencv /usr/include/opencv /usr/include/opencv2 /usr/local/share/opencv /usr/local/share/OpenCV /usr/share/opencv /usr/share/OpenCV /usr/local/bin/opencv* /usr/local/lib/libopencv*
参考文章:
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。