Docker相关
安装docker
sudo apt-get update && sudo apt-get upgrade
curl -fsSL get.docker.com -o get-docker.sh && sh get-docker.sh
Dockerfile构建命令
docker build . -t name:tag
pytorch相关
Dockfile
# 构建一个pytorch的镜像
# FROM pytorch/pytorch:2.0.1-cuda11.7-cudnn8-runtime
# FROM nvcr.io/nvidia/pytorch:22.06-py3
# FROM nvcr.io/nvidia/pytorch:23.05-py3
FROM pytorch/pytorch:2.0.1-cuda11.7-cudnn8-devel
RUN sed -i 's/archive.ubuntu.com/mirrors.ustc.edu.cn/g' /etc/apt/sources.list
RUN sed -i 's/security.ubuntu.com/mirrors.ustc.edu.cn/g' /etc/apt/sources.list
RUN apt update
ARG DEBIAN_FRONTEND=noninteractive
RUN apt install -y openssh-server
# RUN apt-get install -y tzdata && ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
RUN apt install -y htop git iproute2 tmux
RUN pip3 config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple/
RUN pip3 install 'lightning'
RUN pip3 install transformers
RUN pip3 install numba
RUN echo "PermitRootLogin yes" >> /etc/ssh/sshd_config
RUN apt install -y python3-opencv
RUN apt install -y nano
RUN export PATH="/opt/conda/bin:$PATH"
RUN conda init
ADD startup.sh /tmp
RUN chmod +x /tmp/startup.sh
WORKDIR /workspace
EXPOSE 6006
EXPOSE 8008
EXPOSE 22
ENV ROOT_PWD=123456
# ENV ENV_PATH="/data/venv"
# VOLUME [ "/data","/high_speed_data" ]
CMD /tmp/startup.sh
如何使用
# 构建容器
sudo docker build . -t rc_dl:1
启动
sudo docker run --privileged -it -d --name=ysr_work --gpus all \
--ipc host \
-p 1148:22 \
-e ROOT_PWD="a" \
-v /high_speed_data:/high_speed_data \
-v /data:/data \
ysr_torch2.0.1:1
RTMP加nginx服务器实现推流
Dockerfile(适用于树莓派)
git clone https://github.com/vallahaye/docker-nginx-rtmp/tree/master
ARG RTMP_VERSION="1.2.2"
FROM nginx:stable AS build-env
ARG RTMP_VERSION
WORKDIR /tmp
RUN export HTTP_PROXY="192.168.137.1:7890"
RUN export HTTPS_PROXY="192.168.137.1:7890"
RUN export FTP_PROXY="192.168.137.1:7890"
RUN echo 'Acquire::http::proxy "http://192.168.137.1:7890/"; ' >> /etc/apt/apt.conf.d/proxy.conf
RUN echo 'Acquire::http::proxy "http://192.168.137.1:7890/"; ' >> /etc/apt/apt.conf.d/proxy.conf
RUN echo 'Acquire::http::proxy "http://192.168.137.1:7890/"; ' >> /etc/apt/apt.conf.d/proxy.conf
RUN set -x \
\
&& apt-get update \
&& apt-get install --no-install-recommends --no-install-suggests -y wget \
&& wget 'https://hg.nginx.org/pkg-oss/raw-file/default/build_module.sh' \
&& chmod +x build_module.sh \
&& ./build_module.sh -v "${NGINX_VERSION}" -V "${RTMP_VERSION}" -y 'https://github.com/arut/nginx-rtmp-module.git'
FROM nginx:stable
ARG RTMP_VERSION
ARG OCI_IMAGE_CREATED_AT
RUN export HTTP_PROXY="192.168.137.1:7890"
RUN export HTTPS_PROXY="192.168.137.1:7890"
RUN export FTP_PROXY="192.168.137.1:7890"
RUN echo 'Acquire::http::proxy "http://192.168.137.1:7890/"; ' >> /etc/apt/apt.conf.d/proxy.conf
RUN echo 'Acquire::http::proxy "http://192.168.137.1:7890/"; ' >> /etc/apt/apt.conf.d/proxy.conf
RUN echo 'Acquire::http::proxy "http://192.168.137.1:7890/"; ' >> /etc/apt/apt.conf.d/proxy.conf
LABEL org.opencontainers.image.created="${OCI_IMAGE_CREATED_AT}" \
org.opencontainers.image.authors="Valentin Lahaye <valentin.lahaye@gmail.com>" \
org.opencontainers.image.url="https://hub.docker.com/r/vallahaye/nginx-rtmp" \
org.opencontainers.image.source="https://github.com/vallahaye/nginx-rtmp" \
org.opencontainers.image.version="${NGINX_VERSION}+${RTMP_VERSION}" \
org.opencontainers.image.licenses="BSD-2-Clause"
ENV RTMP_VERSION="${RTMP_VERSION}"
COPY --from=build-env /tmp/build-module-artifacts /tmp/build-module-artifacts
RUN set -x \
\
&& apt-get install --no-install-recommends --no-install-suggests -y /tmp/build-module-artifacts/nginx-module-rtmp_*.deb \
&& rm -rf /tmp/build-module-artifacts
COPY nginx.conf /etc/nginx/nginx.conf
CMD ["nginx","-g","daemon off;"]
EXPOSE 1935
启动命令
docker run --privileged -it --name some-nginx -v nginx.conf:/etc/nginx/nginx.conf -d -p 1146:1935 rtmp:1
树莓派高效推流,超低延时
sudo apt-get install libjpeg62-turbo-dev #JPEG支持库
sudo apt-get install imagemagick
sudo apt-get install libv4l-dev
sudo apt-get install cmake #编译工具
sudo apt-get install git #用git下载软件
sudo git clone https://github.com/jacksonliam/mjpg-streamer.git
cd mjpg-streamer/mjpg-streamer-experimental
sudo make
sudo make install
mjpg_streamer -i "/usr/local/lib/mjpg-streamer/input_uvc.so -d /dev/video0 -n -f 30 -r 1920x1080" -o "/usr/local/lib/mjpg-streamer/output_http.so -p 8080 -w /usr/local/share/mjpg-streamer/www"