LoginSignup
0
0

CUDAないしNvidia HPC SDKを導入したDockerコンテナを作る

Posted at

とくに地の文で説明することもないので、手抜きの王、手抜きキングな記事を書きます。

Dockerfile

Dockerfile
# Nvidia HPC Contianerベースイメージを使用
FROM nvidia/cuda:11.8.0-base-ubuntu20.04

RUN ln -sf /usr/share/zoneinfo/Asia/Tokyo /etc/localtime

# 必要なパッケージのインストール
RUN apt-get update && \
    apt-get install -y \
    bash-completion \
    build-essential \
    wget \
    make \
    cmake \
    gcc \
    gfortran \
    tar \
    vim \
    && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/*

# Install NVIDA HPC SDK
WORKDIR /installs/nvidia
RUN wget  https://developer.download.nvidia.com/hpc-sdk/24.3/nvhpc_2024_243_Linux_x86_64_cuda_multi.tar.gz
RUN tar xpzf nvhpc_2024_243_Linux_x86_64_cuda_multi.tar.gz
RUN nvhpc_2024_243_Linux_x86_64_cuda_multi/install
RUN rm -rf nvhpc_2024_243_Linux_x86_64_cuda_multi.tar.gz nvhpc_2024_243_Linux_x86_64_cuda_multi
RUN echo "export PATH=\$PATH:/opt/nvidia/hpc_sdk/Linux_x86_64/24.3/compilers/bin/" >> /root/.bashrc

# ソースコードのコピー
COPY . /app/source

# ビルド作業ディレクトリの作成と移動
WORKDIR /app/source

イメージ作成

docker build ローカルディレクトリパス -t イメージ名

コンテナ作成

docker run --name コンテナ名 --gpus all -it イメージ名

--gpus allを忘れずに!!

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0