docker安装(ubuntu20.04)
1.安装docker
apt-get install vim
vim /etc/apt/sources.list
deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
apt-get update
apt-get install curl
sudo update-ca-certificates
curl -sSL https://get.daocloud.io/docker | sh
vim /etc/docker/daemon.json
{
"registry-mirrors": ["https://hub-mirror.c.163.com","https://ustc-edu-cn.mirror.aliyuncs.com","https://ghcr.io","https://mirror.baidubce.com"]
}
systemctl restart docker.service
docker info
docker run hello-world
2.安装显卡驱动以及cuda11.1
apt-get autoremove --purge nvidia*
apt-get autoremove --purge cuda*
lspci -k | grep -A 2 -i "VGA"
add-apt-repository ppa:graphics-drivers/ppa
apt-get update
ubuntu-drivers devices
apt-get install nvidia-***(recommended版本)
sh cuda_11.1.1_455.32.00_linux.run
vim ~/.bashrc
export PATH=/usr/local/cuda-11.1/bin${
PATH:+:${
PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-11.1/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
nvcc -V
cp cuda/include/cudnn.h /usr/local/cuda/include
cp cuda/lib64/libcudnn* /usr/local/cuda/lib64
sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*
dpkg -i libcudnn8_8.2.1.32-1+cuda11.3_amd64.deb
dpkg -i libcudnn8-dev_8.2.1.32-1+cuda11.3_amd64.deb
dpkg -i libcudnn8-samples_8.2.1.32-1+cuda11.3_amd64.deb
cp -r /usr/src/cudnn_samples_v8/ ~
cd ~/cudnn_samples_v8/mnistCUDNN/
apt-get install libfreeimage3 libfreeimage-dev
make clean && make
./mnistCUDNN
3.nvidia docker安装
distribution=$(. /etc/os-release;echo $ID$VERSION_ID) \&& curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add - \&& curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.listcurl -s -L https://nvidia.github.io/nvidia-container-runtime/experimental/$distribution/nvidia-container-runtime.list | sudo tee /etc/apt/sources.list.d/nvidia-container-runtime.listapt-get update
apt-get install -y nvidia-docker2
systemctl restart docker
docker run --rm --gpus all nvidia/cuda:11.0-base nvidia-smi
4.安装PyTorch_gpu+ jupyter
docker pull anibali/pytorch:1.7.0-cuda11.0
docker run -it --init --gpus=all --ipc=host --name pytorch -p 1778:8888 --volume="$PWD:/app" anibali/pytorch python3
docker ps -a
docder start 容器ID
docker exec -it 容器ID /bin/bash
conda install -c conda-forge jupyterlab
jupyter lab --ip=0.0.0.0 --no-browser --allow-root