dreamlike-zzg

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

git地址:https://github.com/NVIDIA/nvidia-docker  
阅读readme
Make sure you have installed the NVIDIA driver and a supported version of Docker for your distribution (see prerequisites).

install the NVIDIA driver   https://blog.csdn.net/DreamLike_zzg/article/details/88582086
install the Docker CE  https://docs.docker.com/install/linux/docker-ce/ubuntu/#prerequisites
install nvidia-docker2 :见git readme

# If you have nvidia-docker 1.0 installed: we need to remove it and all existing GPU containers
docker volume ls -q -f driver=nvidia-docker | xargs -r -I{} -n1 docker ps -q -a -f volume={} | xargs -r docker rm -f
sudo apt-get purge -y nvidia-docker

# Add the package repositories
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | \
  sudo apt-key add -
distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | \
  sudo tee /etc/apt/sources.list.d/nvidia-docker.list
sudo apt-get update

# Install nvidia-docker2 and reload the Docker daemon configuration
sudo apt-get install -y nvidia-docker2
sudo pkill -SIGHUP dockerd

# Test nvidia-smi with the latest official CUDA image
sudo docker run --runtime=nvidia --rm nvidia/cuda:9.0-base nvidia-smi

Command

docker ps -a
docker rm [container]
docker images
docker image rm [image]

docker start [container]
docker attach [container]

docker run -itd -v 主机绝对路径:容器绝对路径 --name [container] [image] 
docker start [container]
docker exec -it [container] bash

docker cp [container]:/path/to/src /path/to/des

apt换源(Dockerfile)

docker build -t ubuntu:my16.04 .

FROM ubuntu:16.04

RUN mv /etc/apt/sources.list /etc/apt/sources.list.bak
RUN touch /etc/apt/sources.list

RUN echo "deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted universe multiverse">>/etc/apt/sources.list
RUN echo "deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse">>/etc/apt/sources.list
RUN echo "deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse">>/etc/apt/sources.list
RUN echo "deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted universe multiverse">>/etc/apt/sources.list

RUN apt-get update 

显示GUI程序

# 本机执行
sudo apt-get install x11-xserver-utils
xhost +
# xhost:  unable to open display ":0"
# export DISPLAY=:0

docker run -tid\
       -e DISPLAY=$DISPLAY \
       -v /tmp/.X11-unix:/tmp/.X11-unix \
       --name xx \
       [docker image]

使用jupyter notebook

# install jupyter
# python 2.X
pip install --upgrade pip
pip install jupyter
# pyhton 3.X
pip3 install --upgrade pip
pip3 install jupyter

# 运行jupyter报错 socket.error: [Errno 99] Cannot assign requested address
# https://blog.csdn.net/qq_33266320/article/details/80949339
jupyter notebook --generate-config
gedit /root/.jupyter/jupyter_notebook_config.py
# 加入两行
c.NotebookApp.ip = '127.0.0.1'
c.NotebookApp.open_browser = True

# install google-chrome, 本人电脑 firefox 容易崩
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
dpkg -i google-chrome-stable_current_amd64.deb 
apt-get -f install # if occur error

# 解决浏览器中文显示为空格
apt-get install fonts-droid-fallback ttf-wqy-zenhei ttf-wqy-microhei fonts-arphic-ukai fonts-arphic-uming

# for root user
# 先运行jupyter
jupyter notebook --allow-root
# 如果browser不自动启动,则再开一个shell手动运行chrome  
/usr/bin/google-chrome-stable --no-sandbox

 

posted on 2022-11-05 15:59  梦幻济公  阅读(496)  评论(0编辑  收藏  举报