Skip to content

Instantly share code, notes, and snippets.

@colspan
Last active March 7, 2021 13:53
Show Gist options
  • Save colspan/54d68ea4e63c61e5d67fc5a98406e651 to your computer and use it in GitHub Desktop.
Save colspan/54d68ea4e63c61e5d67fc5a98406e651 to your computer and use it in GitHub Desktop.
Dockerfile for ROCm based Cupy and Chainer
FROM rocm/rocm-terminal
LABEL maintainer "Kunihiko Miyoshi <miyoshik@preferred.jp>"
LABEL OBJECT="ROCm based CUPY Environment"
## MEMO rocm-dkms package must be installed on host
RUN sudo apt-get update && sudo apt-get install -y \
wget software-properties-common \
hipblas hipsparse rocrand
# setup python 3.6
RUN sudo add-apt-repository ppa:deadsnakes/ppa
RUN sudo apt-get update && sudo apt-get install -y python3.6 python3.6-dev \
&& sudo apt-get clean
RUN wget https://bootstrap.pypa.io/get-pip.py \
&& sudo python3.6 get-pip.py \
&& sudo python3.6 -m pip install cython
# define parameters
ENV HCC_AMDGPU_TARGET gfx803
ENV __HIP_PLATFORM_HCC__ ''
ENV ROCM_HOME /opt/rocm
ENV CUPY_INSTALL_USE_HIP 1
ENV PATH ${ROCM_HOME}/bin:${PATH}
ENV CFLAGS "-I${ROCM_HOME}/hip/include -I${ROCM_HOME}/hipblas/include -I${ROCM_HOME}/hipsparse/include -I${ROCM_HOME}/hiprand/include ${CFLAGS}"
ENV LDFLAGS "-L${ROCM_HOME}/hipblas/lib -L${ROCM_HOME}/hipsparse/lib -L${ROCM_HOME}/hiprand/lib ${LDFLAGS}"
ENV NVCC hcc
ENV CUDA_PATH ${ROCM_HOME}/bin
# install Cupy and Chainer
WORKDIR /opt
RUN sudo chmod 777 /opt
RUN git clone https://github.com/okuta/cupy -b support-hip
RUN cd cupy && sudo -E python3.6 setup.py install
RUN git clone https://github.com/chainer/chainer
RUN cd chainer && sudo -E python3.6 setup.py install
# to run this image
## docker run -it --device=/dev/kfd --device=/dev/dri --group-add video rocm/rocm-terminal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment