miniconda Pytorch CUDA Cudnn onnxruntime

苏什么苏發表於2024-11-11
FROM  ubuntu:22.04
# docker 啟動方式
# docker run -itd --gpus all --privileged=true --shm-size 8G  --name onnx1 97271d29cb79 /bin/bash

MAINTAINER SuSu

# 切換阿里雲源
RUN  apt-get update && apt-get install -y vim  && apt-get install -y sudo  && apt-get -y install  wget && apt-get install -y curl telnet
RUN sudo apt-get -y install systemctl

# 安裝miniconda
# RUN wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
# RUN bash Miniconda3-latest-Linux-x86_64.sh -b -p /opt/conda && rm -rf Miniconda3-latest-Linux-x86_64.sh
# RUN  /opt/conda/bin/conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main

ENV CONDA_DIR=/opt/conda
RUN wget --quiet https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O /tmp/miniconda.sh \
    && mkdir -p $CONDA_DIR \
    && bash /tmp/miniconda.sh -b -u -p $CONDA_DIR \
    && rm /tmp/miniconda.sh

# 將 Miniconda 新增到 PATH 環境變數中
ENV PATH=$CONDA_DIR/bin:$PATH


RUN conda update -n base -c defaults conda \
    && conda create -y -n onnx_cuda python=3.10.12
RUN echo "source activate myenv" > ~/.bashrc
ENV PATH /opt/conda/envs/myenv/bin:$PATH

#設定國內源
RUN conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/

# RUN pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121


RUN pip install onnxruntime-gpu==1.17.0 --extra-index-url https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/onnxruntime-cuda-12/pypi/simple/ --force-reinstall
#RUN pip install numpy==1.24.4
RUN conda install -n onnx_cuda -y  pytorch torchvision torchaudio pytorch-cuda=12.1 -c pytorch -c nvidia
RUN source activate



# 下載並安裝 code-server
RUN curl -fsSL https://code-server.dev/install.sh | sh

# 需要安裝一些 外掛


# 建立一個非 root 使用者
RUN useradd -m coder \
    && echo "coder ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/nopasswd \
    && chmod 0440 /etc/sudoers.d/nopasswd

# 切換到 coder 使用者
USER coder
WORKDIR /home/coder

# 暴露 code-server 預設埠
EXPOSE 8080
VOLUME /root/workspace

# 啟動 code-server
CMD ["code-server", "--bind-addr", "0.0.0.0:8080", "--auth", "none"]

相關文章