作者:php小盗 | 来源:互联网 | 2023-10-10 11:17
强化学习需要atari环境,使用dockerfile快速构建。下载ROMSwgethttp:www.atarimania.comromsRoms.rarunra
强化学习需要 atari 环境,使用 dockerfile 快速构建。
下载 ROMS
wget http:
unrar -e Roms.rar
unzip ROMS.zip
创建文件夹 dockerbuild/
mkdir dockerbuild && cd dockerbuild
cp -r ../ROMS/ .
vim my.dockerfile
复制以下内容,ubuntu20.04+cu112+python3.8,大小为 10 G。
FROM nvidia/cuda:11.2.2-cudnn8-runtime-ubuntu20.04MAINTAINER Jiale HanSHELL ["/bin/bash","-c"]WORKDIR /rootADD ROMS/ ROMS/RUN apt update \&& apt install -y python3 python3-pip tmux \&& pip install opencv-python matplotlib gym atari-py ale-py \&& python3 -m atari_py.import_roms ROMS/ \&& apt install -y libgl1-mesa-glx \&& DEBIAN_FRONTEND=noninteractive apt install -y libglib2.0-dev \&& apt clean
或者下面这个,ubuntu18.04+cu102+python3.7+virtualenv+pytorch1.82,大小为 2 G。
FROM nvidia/cuda:10.0-cudnn7-runtime-ubuntu18.04MAINTAINER Jiale HanSHELL ["/bin/bash", "-c"]WORKDIR /root/ENV LANG C.UTF-8RUN apt update && \# install python3.7apt install -y software-properties-common && \add-apt-repository -y ppa:deadsnakes/ppa && \apt install -y python3.7 python3.7-distutils python3.7-dev && \apt install -y vim tmux wget && \# install virtualenv & virtualenvwrapperwget https:COPY ROMS/ /root/ROMS/RUN source `which virtualenvwrapper.sh` && \mkvirtualenv py37 && \workon py37 && \pip install opencv-python matplotlib ipython && \pip install gym ale-py && \ale-import-roms ROMS/ && \deactivate && \apt install -y libgl1-mesa-glx libglib2.0-dev && \apt clean && \rm -rf ROMS/COPY .oh-my-zsh/ /root/.oh-my-zsh/RUN apt install -y zsh && \cp .oh-my-zsh/templates/zshrc.zsh-template .zshrc && \sed -i 's/plugins=(git)/plugins=(git zsh-autosuggestions zsh-syntax-highlighting)/g' .zshrc && \echo -e "\n# virtualenvwrapper" >> .zshrc && \echo "export WORKON_HOME=/root/.virtualenvs" >> .zshrc && \echo "export VIRTUALENVWRAPPER_VIRTUALENV=`which virtualenv`" >> .zshrc && \echo "export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3.7" >> .zshrc && \echo "source `which virtualenvwrapper.sh`" >> .zshrc && \chsh -s $(which zsh) && \apt cleanCOPY id_rsa.pub /root/.ssh/id_rsa.pubRUN apt install -y openssh-server && \cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys && \chmod 600 /root/.ssh/authorized_keys && \sed -i 's/#PubkeyAuthentication yes/PubkeyAuthentication yes/g' \/etc/ssh/sshd_config && \sed -i 's/#PasswordAuthentication yes/PasswordAuthentication no/g' \/etc/ssh/sshd_config && \sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin prohibit-password/g' \/etc/ssh/sshd_config && \apt cleanEXPOSE 22COPY init.sh /root/init.shENTRYPOINT ["/bin/zsh", "init.sh"]
使用镜像运行容器后,
启动 ssh 服务
service ssh restart
安装 pytorch1.8.2
pip install torch==1.8.2+cu102 torchvision==0.9.2+cu102 \-f https:
pip install 'ray[rllib]' tensorboard==1.15
或者把 nvidia/cuda:10.2
改成 nvidia/cuda:10.0
,使用镜像运行容器后,安装 tensorflow1.15
pip install tensorflow-gpu==1.15
pip install 'ray[rllib]'
如果要运行框架
export HOROVOD_GPU_OPERATIONS=NCCL
apt install git cmake g++
pip install influxdb psutil pyzmq pyarrow horovod
conda 镜像
FROM nvidia/cuda:10.2-cudnn7-devel-ubuntu18.04MAINTAINER Jiale HanSHELL ["/bin/bash","-c"]WORKDIR /rootRUN apt update \&& apt install -y vim cmake tmux wget \&& wget https:
构建镜像
cd dockerbuild/
docker build -t nvidia/cuda:cu100-ubu18-rl-zsh -f tf1.dockerfile .
从镜像运行容器
docker run -it -v /data2/hanjl:/root/code/ \-p 0.0.0.0:2200:22 -p 0.0.0.8000:80 \--gpus '"device=1,2"' --name hjl_test \nvidia/cuda:cu100-ubu18-rl-zsh /bin/zsh