图像风格迁移docker内实验详细记录

开发平台: Ubuntu 16.04
安装docker-ce, docker, nvidia-docker 1.1, docker-compose

预处理:

制作数据卷
nvidia_driver_384.111

制作镜像

mkdir -p /your_path
cd /your_path
## 
git clone https://github.com/NVIDIA/FastPhotoStyle.git
cd FastPhotoStyle

## 制作docker镜像, 镜像操作耗时长, 耐心等待
docker build -t photo_style:1.0 .


编写docker-compose.yml

docker-compose.yml文件

version: "2"
services:    
    photo_style:
        container_name: photo_style
        devices:
            - /dev/nvidia0
            - /dev/nvidia1
            - /dev/nvidiactl
            - /dev/nvidia-uvm
            - /dev/nvidia-uvm-tools
        ports:
         - "22222:22222"         
        image: photo_style:1.0
        volumes:
         - nvidia_driver_384.111:/usr/local/nvidia:ro
         - /your_path/FastPhotoStyle:/FastPhotoStyle
        restart: on-failure
        tty: true
volumes:  
  nvidia_driver_384.111:
    external: true

启动容器


## 建立容器
docker-compose -f docker-compose.yml up -d

## 启动容器
docker exec -it photo_style /bin/bash

错误记录

cupy.cuda.runtime.CUDARuntimeError: cudaErrorInsufficientDriver: CUDA driver version is insufficient for CUDA runtime version


驱动不支持cuda版本, 换比较低的cuda版本.
不同版本Cuda 对显卡驱动要求是不一样的,如果你的显卡驱动版本低于CUDA tookit 要求的版本,程序可能出现计算错误或其它未知名的错误。

用的是cuda91的版本, 换为cuda90版本.

修改dockerfile文件

FROM nvidia/cuda:9.0-cudnn7-devel-ubuntu16.04
ENV ANACONDA /opt/anaconda3
ENV CUDA_PATH /usr/local/cuda
ENV PATH ${ANACONDA}/bin:${CUDA_PATH}/bin:$PATH
ENV LD_LIBRARY_PATH ${ANACONDA}/lib:${CUDA_PATH}/bin64:$LD_LIBRARY_PATH
ENV C_INCLUDE_PATH ${CUDA_PATH}/include
RUN apt-get update && apt-get install -y --no-install-recommends \
         wget \	 
         imagemagick \
         libopencv-dev \
         python-opencv \
         build-essential \
         cmake \
         git \
         curl \
         ca-certificates \
         libjpeg-dev \
         libpng-dev \
         axel \
         zip \
         unzip
RUN wget https://repo.continuum.io/archive/Anaconda3-5.0.1-Linux-x86_64.sh -P /tmp
RUN bash /tmp/Anaconda3-5.0.1-Linux-x86_64.sh -b -p $ANACONDA
RUN rm /tmp/Anaconda3-5.0.1-Linux-x86_64.sh -rf
RUN conda install -y pytorch=0.4.1 torchvision cuda90 -c pytorch
RUN conda install -y -c anaconda pip 
RUN conda install -y -c menpo opencv3
RUN pip install scikit-umfpack
RUN pip install cupy-cuda90
RUN pip install pynvrtc

重新制作docker镜像

## 制作docker镜像, 镜像操作耗时长, 耐心等待
docker build -t photo_style:1.1 .

启动容器

docker exec -it photo_style /bin/bash

执行命令

cd /your_path
./demo_example1.sh

如有疑问, 请留言

你可能感兴趣的:(人工智能)