安装:
sudo apt-get -y install docker.io
测试:
sudo docker run hello-world
成功:
Hello from Docker!
This message shows that your installation appears to be working correctly.
查看已有镜像:
sudo docker images
查看所有容器
sudo docker ps -a
下载CUDA docker
1、宿主机需要安装依赖支持CUDA:
distribution=$(. /etc/os-release;echo $ID$VERSION_ID) \
&& curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg \
&& curl -s -L https://nvidia.github.io/libnvidia-container/$distribution/libnvidia-container.list | \
sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \
sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
2、安装
sudo apt-get update
sudo apt-get install -y nvidia-docker2
sudo systemctl restart docker
3、dockerhub这个能有nvcc -V
,pytorch等安装的cuda都没有nvcc,只有cudatoolkit.
sudo docker pull nvidia/cuda:11.0.3-devel-ubuntu20.04
进入docker
sudo docker run -it --gpus all nvidia/cuda:11.0.3-devel-ubuntu20.04
安一点杂七杂八
apt-get install -y lsb-release vim
安装conda
随便搜搜教程就好,只是不能重启shell,只能安装完需要source一下生效
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
sudo chmod +x Miniconda3-latest-Linux-x86_64.sh
sudo ./Miniconda3-latest-Linux-x86_64.sh
source ~/.bashrc
后面装pytorch没什么不同
安装ros
1、更换源,写这个blog时只有阿里云能安装了mdzz:
阿里云
2、
sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.aliyun.com/ros/ubuntu/ `lsb_release -cs` main" > /etc/apt/sources.list.d/ros-latest.list'
sudo apt install curl
curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -
sudo apt update
sudo apt install ros-melodic-desktop-full
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc
保存镜像
exit
sudo docker ps -a
sudo docker commit 22de8a9f42c6 shm:v1
镜像导出&加载
docker save -o shm.tar shm:v1
docker load -i shm.tar
Volume
将宿主机的/home/lu/flightmare挂载到docker /home/flightmare下,以便在外面编程
sudo docker run -it -v /home/lu/flightmare:/home/flightmare --gpus all nvidia/cuda:11.0.3-devel-ubuntu20.04
注意,这个nvidia/cuda是镜像的名字(虽然带个/)
文件拷贝
docker cp 要拷贝的文件路径 容器名(id):要拷贝到容器里面对应的路径
主从机
1、查看各自ip(docker需要ap-get install net-tools
)
2、把docker设为从机
vim ~/.bashrc
export ROS_HOSTNAME=自己IP
export ROS_MASTER_URI=http://主机IP:11311
3、把自己电脑设为主机
vim ~/.bashrc
export ROS_HOSTNAME=自己IP
export ROS_MASTER_URI=http://主机IP:11311
分别source一下
4、此时主机没有区别,从机开roscore会报一个WARNING
screen简单使用
1、安装
sudo apt-get install screen
2、创建窗口
screen -S 窗口名 bash
3、退出窗口
Ctrl + A + D
4、进入窗口
screen -r 窗口名
5、退出
pkill screen