### 需要注意的事项:
1. 注意应用NVIDIA在docker_hub上提供的镜像, 本次使用的是:nvidia/cuda:10.1-cudnn7-devel-ubuntu18.04
2. 在宿主机安装 nvidia-docker2
3. 运行时, 要加"–run-time=nvidia", 本次执行命令为:
export DEVICES=$(ls /dev/nvidia* | xargs -I{} echo ‘–device {}:{}’)
nvidia-docker run -d -it $DEVICES --runtime=nvidia -p port(outside):9000(inside) dockerimage-name:1.0-1
4. 运行uwsgi时要注意master=true lazy-apps =true, 否则会导致cuda初始化失败
dockerfile 如下:
FROM nvidia/cuda:10.1-cudnn7-devel-ubuntu18.04
MAINTAINER “hanrb”
RUN apt-get update
&& apt-get install -y python3-pip python3.6
&& cd /usr/local/bin
&& ln -s /usr/bin/python3 python
&& pip3 install --upgrade pip
&& apt-get install -y libsm6 libxrender1 libxext-dev
RUN pip3 install numpy requests Pillow opencv-python pyyaml uwsgi
ENTRYPOINT [“sh”, “-c”, “echo $HOME”]